-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Closed
Labels
A-type-systemArea: Type systemArea: Type system
Description
Minimal example: http://is.gd/dJjKjV
fn f<T: Iterator<Item=i32>>(i: T) -> i32 {
g(i.take_while(|_| false))
}
fn g<T: Iterator<Item=i32>>(i: T) -> i32 {
f(i.take_while(|_| false))
}
fn main() {
f([2].iter().cloned());
}If you change take_while() to take(), it gives the following error:
<anon>:1:1: 1:1 error: overflow evaluating the requirement `*const i32 : core::marker::Sized` [E0275]
<anon>:1 fn f<T: Iterator<Item=i32>>(i: T) -> i32 {
^
<anon>:1:1: 1:1 note: consider adding a `#![recursion_limit="128"]` attribute to your crate
<anon>:1 fn f<T: Iterator<Item=i32>>(i: T) -> i32 {
^
<anon>:1:1: 1:1 note: required because it appears within the type `core::slice::Iter<i32>`
<anon>:1 fn f<T: Iterator<Item=i32>>(i: T) -> i32 {
^
<anon>:1:1: 1:1 note: required because it appears within the type `core::iter::Cloned<core::slice::Iter<i32>>`
<anon>:1 fn f<T: Iterator<Item=i32>>(i: T) -> i32 {
^
<anon>:1:1: 1:1 note: required because it appears within the type `core::iter::Take<core::iter::Cloned<core::slice::Iter<i32>>>`
<anon>:1 fn f<T: Iterator<Item=i32>>(i: T) -> i32 {
^
<anon>:1:1: 1:1 note: required because it appears within the type `core::iter::Take<core::iter::Take<core::iter::Cloned<core::slice::Iter<i32>>>>`
<anon>:1 fn f<T: Iterator<Item=i32>>(i: T) -> i32 {
^
<anon>:1:1: 1:1 note: required because it appears within the type `core::iter::Take<core::iter::Take<core::iter::Take<core::iter::Cloned<core::slice::Iter<i32>>>>>`
<anon>:1 fn f<T: Iterator<Item=i32>>(i: T) -> i32 {
(and so on)
The error seems to be a correct behavior. The only difference between take() and take_while() is that the latter takes lambda as argument. Why does it behave differently?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-type-systemArea: Type systemArea: Type system
Type
Fields
Give feedbackNo fields configured for issues without a type.