Open
Description
With the removal of the leak check the MIR type checker is now responsible for reporting higher-ranked lifetime errors in full NLL mode. The error messages are not currently very helpful, since they weren't user visible until now.
The following code (play):
#![feature(nll)]
fn main() {
let x: fn(&'static ()) = |_| {};
let y: for<'a> fn(&'a ()) = x;
}
gives the following output
error: higher-ranked subtype error
--> <source>:19:12
|
19 | let x: fn(&'static ()) = |_| {};
| ^^^^^^^^^^^^^^^
error: aborting due to previous error
Compiler returned: 1
In migrate mode or with AST borrowck the error is much clearer:
error[E0308]: mismatched types
--> <source>:20:33
|
20 | let y: for<'a> fn(&'a ()) = x;
| ^ one type is more general than the other
|
= note: expected type `for<'a> fn(&'a ())`
found type `fn(&'static ())`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
Compiler returned: 1
cc @rust-lang/wg-compiler-nll