-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NLL: bad error message when converting anonymous lifetime to 'static
#46983
Comments
So, the NLL region checking errors currently uses the "nice region error" routines if it can: rust/src/librustc_mir/borrow_check/nll/region_infer/mod.rs Lines 990 to 996 in 27ede55
If not, it fallback to this bad error message. This is the same basic strategy that the lexical region error reporting takes: rust/src/librustc/infer/error_reporting/mod.rs Lines 303 to 340 in 27ede55
You'll note that the error message you get without
I think the ideal way to address this would be to make a "nice region error" that covers this case. Note that if we used a named lifetime like #![feature(nll)]
fn foo<'a>(x: &u32) -> &'a u32 {
&*x
}
fn main() {}
I believe this error is produced by the rust/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs Lines 20 to 120 in 27ede55
The problem here is that the code is written to detect the case of one anonymous region and one region for which rust/src/librustc/infer/error_reporting/nice_region_error/util.rs Lines 202 to 212 in 27ede55
I think the simplest fix here would be to make that method return true for the (Also, it appears that |
I'll tackle this one. |
…ous lifetime to `'static`
NLL: bad error message when converting anonymous lifetime to `'static` Fixes #46983. r? @nikomatsakis
I'm not certain that this was resolved completely.
We need to check that we are producing usable output, especially when invoking the compiler without |
Note in particular that I don't expect this to be considered fixed until the output at ui/underscore-lifetime/dyn-trait-underscore.nll.stderr has been made legible. At the time of this writing that stderr file indicates that we emit:
and messages that say "free region ``" are not considered legible to end users. |
I'll look into this one (again). |
@davidtwco and I had a discussion about how to fix this (and many other region errors besides) which is available here https://youtu.be/Vj0FuKTVP94. |
…vements, r=nikomatsakis NLL: bad error message when converting anonymous lifetime to `'static` Contributes to #46983. This PR doesn't introduce fantastic errors, but it should hopefully lay some groundwork for diagnostic improvements. r? @nikomatsakis
Okay we are declaring this now "fixed" because the output of
|
The FIXME was added in 46984 when the diagnostic message looked like this: // FIXME(rust-lang#46983): error message should be better &s.0 //~ ERROR free region `` does not outlive free region `'static` The message was improved in 90667 and now looks like this: &s.0 //~ ERROR lifetime may not live long enough but the FIXME was not removed. The issue 46983 about that diagnostics should be improved has been closed. We can remove the FIXME now.
… r=cjgillot Remove FIXME about NLL diagnostic that is already improved The FIXME was added in rust-lang#46984 when the diagnostic message looked like this: // FIXME(rust-lang#46983): error message should be better &s.0 //~ ERROR free region `` does not outlive free region `'static` The message was improved in rust-lang#90667 and now looks like this: &s.0 //~ ERROR lifetime may not live long enough but the FIXME was not removed. The issue rust-lang#46983 about that diagnostics should be improved has been closed. We can remove the FIXME now. (This PR was made for rust-lang#44366.)
UPDATE: Mentoring instructions here.
Tested at 5165ee9 and current playpen
Error message:
The text was updated successfully, but these errors were encountered: