Skip to content
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] Loss of span for consider adding an explicit lifetime bound suggestions #96332

Open
marmeladema opened this issue Apr 23, 2022 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-NLL Area: Non-lexical lifetimes (NLL) NLL-diagnostics Working towards the "diagnostic parity" goal T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@marmeladema
Copy link
Contributor

In tests like:

Under NLL we rightfully suggest to add a lifetime bound:

   |
LL |     Box::new(B(&*v)) as Box<dyn X>
   |              ^^^^^^
   |
   = help: consider adding an explicit lifetime bound `T: 'static`...

but the actual span where the lifetime bound should be added is lost when we compare to non-nll mode:

LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
   |          - help: consider adding an explicit lifetime bound...: `T: 'static`

This is a diagnostic regression that should be fixed.

@rustbot label +A-NLL +NLL-diagnostics

@marmeladema marmeladema added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 23, 2022
@rustbot rustbot added A-NLL Area: Non-lexical lifetimes (NLL) NLL-diagnostics Working towards the "diagnostic parity" goal labels Apr 23, 2022
@marmeladema marmeladema changed the title [NLL] Loss of span for adding lifetime bound suggestions [NLL] Loss of span for consider adding an explicit lifetime bound suggestions Apr 23, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 24, 2022
…suggestions, r=jackh726

Improve span for `consider adding an explicit lifetime bound` suggestions under NLL

Because NLL borrowck is run after typeck, `in_progress_typeck_results` was always `None` which was preventing the retrieval of the span to which the suggestion is suppose to add the lifetime bound.
We now manually pass the `LocalDefId` owner to `construct_generic_bound_failure` so that under NLL, we give the owner id of the current body.

This helps with rust-lang#96332
@jackh726
Copy link
Member

jackh726 commented Jun 4, 2022

I think this can be closed now, after #96352

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-NLL Area: Non-lexical lifetimes (NLL) NLL-diagnostics Working towards the "diagnostic parity" goal T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants