{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/26026","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/26026/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/26026/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/26026/events","html_url":"https://github.com/rust-lang/rust/issues/26026","id":85415643,"number":26026,"title":"Type checker drops the ball with IntoIterator","user":{"login":"Gankro","id":1136864,"avatar_url":"https://avatars.githubusercontent.com/u/1136864?v=3","gravatar_id":"","url":"https://api.github.com/users/Gankro","html_url":"https://github.com/Gankro","followers_url":"https://api.github.com/users/Gankro/followers","following_url":"https://api.github.com/users/Gankro/following{/other_user}","gists_url":"https://api.github.com/users/Gankro/gists{/gist_id}","starred_url":"https://api.github.com/users/Gankro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gankro/subscriptions","organizations_url":"https://api.github.com/users/Gankro/orgs","repos_url":"https://api.github.com/users/Gankro/repos","events_url":"https://api.github.com/users/Gankro/events{/privacy}","received_events_url":"https://api.github.com/users/Gankro/received_events","type":"User","site_admin":false},"labels":[{"id":149689562,"url":"https://api.github.com/repos/rust-lang/rust/labels/A-associated-items","name":"A-associated-items","color":"d7e102","default":false},{"id":37544,"url":"https://api.github.com/repos/rust-lang/rust/labels/A-typesystem","name":"A-typesystem","color":"d7e102","default":false},{"id":209363,"url":"https://api.github.com/repos/rust-lang/rust/labels/I-papercut","name":"I-papercut","color":"e10c02","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2015-06-05T04:22:38Z","updated_at":"2016-11-29T20:54:01Z","closed_at":null,"body":"Note that this is the current definition of IntoIterator:\n\n``` rust\npub trait IntoIterator {\n    type Item;\n    type IntoIter: Iterator<Item=Self::Item>;\n\n    fn into_iter(self) -> Self::IntoIter;\n}\n```\n\nSo we try to make a type that can be instantiated with any IntoIter, storing its Iterator:\n\n``` rust\npub struct Internal<I> {\n    iter: I\n}\n\nimpl<I> Internal<I> {\n    fn new<It: IntoIterator<IntoIter=I>>(iterable: It) -> Self {\n        let iter = iterable.into_iter();\n        Internal { iter: iter }\n    }\n}\n```\n\n```\n<anon>:7:29: 7:40 error: the trait `core::iter::Iterator` is not implemented for the type `I` [E0277]\n<anon>:7         let iter = iterable.into_iter();\n                                     ^~~~~~~~~~~\n<anon>:7:29: 7:40 note: `I` is not an iterator; maybe try calling `.iter()` or a similar method\n<anon>:7         let iter = iterable.into_iter();\n                                     ^~~~~~~~~~~\n```\n\nCompletely nonsensical. Nothing is asking I to be an Iterator, except for IntoIterator's _own definiton_, which proves that it is in fact an Iterator. But ok, let's try to assert that it is:\n\n``` rust\npub struct Internal<I> {\n    iter: I\n}\n\nimpl<I: Iterator> Internal<I> {\n    fn new<It: IntoIterator<IntoIter=I>>(iterable: It) -> Self {\n        let iter = iterable.into_iter();\n        Internal { iter: iter }\n    }\n}\n```\n\n```\n<anon>:7:29: 7:40 error: type mismatch resolving `<I as core::iter::Iterator>::Item == <It as core::iter::IntoIterator>::Item`:\n expected trait `core::iter::Iterator`,\n    found trait `core::iter::IntoIterator` [E0271]\n<anon>:7         let iter = iterable.into_iter();\n                                     ^~~~~~~~~~~\n```\n\nAgain nothing is demanding this by IntoIterator, which is already proving it. This works, though:\n\n``` rust\npub struct Internal<I> {\n    iter: I\n}\n\nimpl<I: Iterator> Internal<I> {\n    fn new<It: IntoIterator<IntoIter=I, Item=I::Item>>(iterable: It) -> Self {\n        let iter = iterable.into_iter();\n        Internal { iter: iter }\n    }\n}\n```\n\nWhich shouldn't be necessary.\n"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/263695528","html_url":"https://github.com/rust-lang/rust/issues/26026#issuecomment-263695528","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/26026","id":263695528,"user":{"login":"steveklabnik","id":27786,"avatar_url":"https://avatars.githubusercontent.com/u/27786?v=3","gravatar_id":"","url":"https://api.github.com/users/steveklabnik","html_url":"https://github.com/steveklabnik","followers_url":"https://api.github.com/users/steveklabnik/followers","following_url":"https://api.github.com/users/steveklabnik/following{/other_user}","gists_url":"https://api.github.com/users/steveklabnik/gists{/gist_id}","starred_url":"https://api.github.com/users/steveklabnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steveklabnik/subscriptions","organizations_url":"https://api.github.com/users/steveklabnik/orgs","repos_url":"https://api.github.com/users/steveklabnik/repos","events_url":"https://api.github.com/users/steveklabnik/events{/privacy}","received_events_url":"https://api.github.com/users/steveklabnik/received_events","type":"User","site_admin":false},"created_at":"2016-11-29T20:54:01Z","updated_at":"2016-11-29T20:54:01Z","body":"Triage: same issue, slightly different error message today:\r\n\r\n```text\r\nerror[E0277]: the trait bound `I: std::iter::Iterator` is not satisfied\r\n --> <anon>:6:5\r\n  |\r\n6 |     fn new<It: IntoIterator<IntoIter=I>>(iterable: It) -> Self {\r\n  |     ^ trait `I: std::iter::Iterator` not satisfied\r\n  |\r\n  = help: consider adding a `where I: std::iter::Iterator` bound\r\n  = note: required by `std::iter::IntoIterator`\r\n```"}}
{"actor":{"display_login":"steveklabnik"}}