{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/38133","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/38133/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/38133/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/38133/events","html_url":"https://github.com/rust-lang/rust/issues/38133","id":193203141,"number":38133,"title":"Iterator adaptors should allow unsized function fields","user":{"login":"nagisa","id":679122,"avatar_url":"https://avatars.githubusercontent.com/u/679122?v=3","gravatar_id":"","url":"https://api.github.com/users/nagisa","html_url":"https://github.com/nagisa","followers_url":"https://api.github.com/users/nagisa/followers","following_url":"https://api.github.com/users/nagisa/following{/other_user}","gists_url":"https://api.github.com/users/nagisa/gists{/gist_id}","starred_url":"https://api.github.com/users/nagisa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nagisa/subscriptions","organizations_url":"https://api.github.com/users/nagisa/orgs","repos_url":"https://api.github.com/users/nagisa/repos","events_url":"https://api.github.com/users/nagisa/events{/privacy}","received_events_url":"https://api.github.com/users/nagisa/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-02T19:53:05Z","updated_at":"2016-12-02T20:01:50Z","closed_at":null,"body":"For example `::std::iter::Map<::std::ops::Range<u8>, Fn(u8) -> u32>` is fully technically possible type, except `Map` doesn't allow for unsized `F`, because it is not marked as such."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/264548832","html_url":"https://github.com/rust-lang/rust/issues/38133#issuecomment-264548832","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/38133","id":264548832,"user":{"login":"bluss","id":3209739,"avatar_url":"https://avatars.githubusercontent.com/u/3209739?v=3","gravatar_id":"","url":"https://api.github.com/users/bluss","html_url":"https://github.com/bluss","followers_url":"https://api.github.com/users/bluss/followers","following_url":"https://api.github.com/users/bluss/following{/other_user}","gists_url":"https://api.github.com/users/bluss/gists{/gist_id}","starred_url":"https://api.github.com/users/bluss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bluss/subscriptions","organizations_url":"https://api.github.com/users/bluss/orgs","repos_url":"https://api.github.com/users/bluss/repos","events_url":"https://api.github.com/users/bluss/events{/privacy}","received_events_url":"https://api.github.com/users/bluss/received_events","type":"User","site_admin":false},"created_at":"2016-12-02T20:01:49Z","updated_at":"2016-12-02T20:01:49Z","body":"Doing that while preserving map's `fold` implementation requires specialization and meets the ICE in #36848\r\n\r\n> error: internal compiler error: ../src/librustc/traits/specialize/mod.rs:130: find_method: translate_substs returned Substs { params: [&str, str::SplitTerminator<char>, str::LinesAnyMap] } which contains inference types/regions\r\n\r\n\r\n```diff\r\ndiff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs\r\nindex 2e08508..3a054f0 100644\r\n--- a/src/libcore/iter/mod.rs\r\n+++ b/src/libcore/iter/mod.rs\r\n@@ -976,13 +976,13 @@ unsafe impl<A, B> TrustedLen for Zip<A, B>\r\n #[must_use = \"iterator adaptors are lazy and do nothing unless consumed\"]\r\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\r\n #[derive(Clone)]\r\n-pub struct Map<I, F> {\r\n+pub struct Map<I, F: ?Sized> {\r\n     iter: I,\r\n     f: F,\r\n }\r\n \r\n #[stable(feature = \"core_impl_debug\", since = \"1.9.0\")]\r\n-impl<I: fmt::Debug, F> fmt::Debug for Map<I, F> {\r\n+impl<I: fmt::Debug, F: ?Sized> fmt::Debug for Map<I, F> {\r\n     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {\r\n         f.debug_struct(\"Map\")\r\n             .field(\"iter\", &self.iter)\r\n@@ -991,7 +991,7 @@ impl<I: fmt::Debug, F> fmt::Debug for Map<I, F> {\r\n }\r\n \r\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\r\n-impl<B, I: Iterator, F> Iterator for Map<I, F> where F: FnMut(I::Item) -> B {\r\n+impl<B, I: Iterator, F: ?Sized> Iterator for Map<I, F> where F: FnMut(I::Item) -> B {\r\n     type Item = B;\r\n \r\n     #[inline]\r\n@@ -1003,7 +1003,10 @@ impl<B, I: Iterator, F> Iterator for Map<I, F> where F: FnMut(I::Item) -> B {\r\n     fn size_hint(&self) -> (usize, Option<usize>) {\r\n         self.iter.size_hint()\r\n     }\r\n+}\r\n \r\n+#[stable(feature = \"rust1\", since = \"1.0.0\")]\r\n+impl<B, I: Iterator, F> Iterator for Map<I, F> where F: FnMut(I::Item) -> B {\r\n     fn fold<Acc, G>(self, init: Acc, mut g: G) -> Acc\r\n         where G: FnMut(Acc, Self::Item) -> Acc,\r\n     {\r\n@@ -1013,7 +1016,7 @@ impl<B, I: Iterator, F> Iterator for Map<I, F> where F: FnMut(I::Item) -> B {\r\n }\r\n \r\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\r\n-impl<B, I: DoubleEndedIterator, F> DoubleEndedIterator for Map<I, F> where\r\n+impl<B, I: DoubleEndedIterator, F: ?Sized> DoubleEndedIterator for Map<I, F> where\r\n     F: FnMut(I::Item) -> B,\r\n {\r\n     #[inline]\r\n@@ -1023,7 +1026,7 @@ impl<B, I: DoubleEndedIterator, F> DoubleEndedIterator for Map<I, F> where\r\n }\r\n \r\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\r\n-impl<B, I: ExactSizeIterator, F> ExactSizeIterator for Map<I, F>\r\n+impl<B, I: ExactSizeIterator, F: ?Sized> ExactSizeIterator for Map<I, F>\r\n     where F: FnMut(I::Item) -> B\r\n {\r\n     fn len(&self) -> usize {\r\n@@ -1036,16 +1039,16 @@ impl<B, I: ExactSizeIterator, F> ExactSizeIterator for Map<I, F>\r\n }\r\n \r\n #[unstable(feature = \"fused\", issue = \"35602\")]\r\n-impl<B, I: FusedIterator, F> FusedIterator for Map<I, F>\r\n+impl<B, I: FusedIterator, F: ?Sized> FusedIterator for Map<I, F>\r\n     where F: FnMut(I::Item) -> B {}\r\n \r\n #[unstable(feature = \"trusted_len\", issue = \"37572\")]\r\n-unsafe impl<B, I, F> TrustedLen for Map<I, F>\r\n+unsafe impl<B, I, F: ?Sized> TrustedLen for Map<I, F>\r\n     where I: TrustedLen,\r\n           F: FnMut(I::Item) -> B {}\r\n \r\n #[doc(hidden)]\r\n-unsafe impl<B, I, F> TrustedRandomAccess for Map<I, F>\r\n+unsafe impl<B, I, F: ?Sized> TrustedRandomAccess for Map<I, F>\r\n     where I: TrustedRandomAccess,\r\n           F: FnMut(I::Item) -> B,\r\n {\r\n```"}}
{"actor":{"display_login":"bluss"}}