You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following falls over at the moment, but works with the commented version of the closure:
fnmain(){let f = |&x| x asu64;// <-- doesn't work// let f = |&x: &_| x as u64; // <-- does worktest_me0(&f);test_me1(&f);}fntest_me0<F:Fn(&u32) -> u64>(func:&F) -> u64{func(&0)}fntest_me1<F:Fn(&u32) -> u64>(func:&F) -> u64{func(&1)}
@eddyb's thinking is that a &x pattern may not result in a &T type hint, same for &mut x. His thinking was that way back when &x would also match &mut which is no longer possible, but attempts to get playbot to verify this for us in public did not go as planned.
In any case, it was there determined that &x: _ and &x: &_ should be identical, and that this is not expected. :)
The text was updated successfully, but these errors were encountered:
frankmcsherry
changed the title
Type inference for closure get confused without trivial help
Type inference for closure gets confused without trivial help
Aug 14, 2015
#27828 is basically the same issue, and has a bunch more examples, so I'm going to close this one. I've left a note over there that this example matters too, thanks!
The following falls over at the moment, but works with the commented version of the closure:
@eddyb's thinking is that a
&x
pattern may not result in a&T
type hint, same for&mut x
. His thinking was that way back when&x
would also match&mut
which is no longer possible, but attempts to get playbot to verify this for us in public did not go as planned.In any case, it was there determined that
&x: _
and&x: &_
should be identical, and that this is not expected. :)The text was updated successfully, but these errors were encountered: