-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-higher-rankedArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)NLL-diagnosticsWorking towards the "diagnostic parity" goalWorking towards the "diagnostic parity" goalP-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
teor2345
Metadata
Metadata
Assignees
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-higher-rankedArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)NLL-diagnosticsWorking towards the "diagnostic parity" goalWorking towards the "diagnostic parity" goalP-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.