Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upExpected type for closure arguments not inferred through two nested func calls #16473
Comments
This comment has been minimized.
This comment has been minimized.
alvaro-cuesta
commented
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): fn process_123(processor: |&[u8]| -> Vec<u8>) -> Vec<u8> {
processor(&[1, 2, 3])
}
fn main() {
let make_vec = |input/*: &_*/| { // UNCOMMENT THIS TO FIX
let mut vector = Vec::new();
vector.push_all(input);
vector
};
assert_eq!(process_123(make_vec), vec![1, 2, 3]);
}Yields error:
As you can see, explicitly typing the closure param as |
steveklabnik
added
the
A-closures
label
Jan 27, 2015
This comment has been minimized.
This comment has been minimized.
|
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: Server::http(|req, res| {
}).listen(8080); |
seanmonstar
referenced this issue
Apr 22, 2015
Closed
Incomprehensible error message when inference fails for closure #24680
This comment has been minimized.
This comment has been minimized.
|
Triage: @seanmonstar s playpen still fails today. |
Mark-Simulacrum
added
the
A-inference
label
May 16, 2017
Mark-Simulacrum
added
the
C-bug
label
Jul 21, 2017
This comment has been minimized.
This comment has been minimized.
|
Triage: no change |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nikomatsakis commentedAug 13, 2014
Test case:
This yields an error:
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.