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
{{ message }}
Repository navigation
Expected type for closure arguments not inferred through two nested func calls #16473
/home/nmatsakis/tmp/foo.rs:7:20: 7:47 error: mismatched types: expected `core::option::Option<|&mut Foo|>` but found `core::option::Option<|&mut Foo|>` (expected concrete lifetime, but found bound lifetime parameter )
which occurs because we did not propagate the expected type and thus instantiated the type of the closure parameter with a fresh variable, rather than using a bound region. Another solution to this issue would be finding a better way to decide when we can generalize lifetimes in closure parameters, rather than relying on the closure type.
There is a workaround: just manually annotate the parameter type.
mismatched types: expected `|&[u8]| -> collections::vec::Vec<u8>`, found `|&[_]| -> collections::vec::Vec<_>` (expected concrete lifetime, found bound lifetime parameter )
As you can see, explicitly typing the closure param as &_ fixes the issue. My intuition is similar to yours: there's a problem when propagating the expected type.
Activity
alvaro-cuesta commentedon Nov 2, 2014
Found a similar bug, but wanted to check since I'm not sure if it's a simplified version of this issue or I should open a new one.
Test case (playpen):
Yields error:
As you can see, explicitly typing the closure param as
&_fixes the issue. My intuition is similar to yours: there's a problem when propagating the expected type.seanmonstar commentedon Apr 22, 2015
Assuming this is what is causing this playpen to fail: http://is.gd/E7sskd
This makes the easy case for a hyper Server fail, which would be a major bummer for those trying hyper at 1.0.0:
steveklabnik commentedon Nov 29, 2016
Triage: @seanmonstar s playpen still fails today.
steveklabnik commentedon Sep 24, 2018
Triage: no change
Spoonbender commentedon Mar 22, 2022
Triage: no change
Auto merge of rust-lang#16473 - SomeoneToIgnore:kb/remove-resolve-stu…
Fix panic/assert message detection in edition 2015/2018 (rust-lang#16473