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 suggestions to change/fix trait object lifetime bound #96277

Closed
marmeladema opened this issue Apr 21, 2022 · 0 comments · Fixed by #96385
Closed

[NLL] Loss of suggestions to change/fix trait object lifetime bound #96277

marmeladema opened this issue Apr 21, 2022 · 0 comments · Fixed by #96385
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

For tests like:

In NLL mode, we loose suggestions to change trait object lifetime bound like:

help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
   |
LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'a> {
   |                                                            ~~

or

help: alternatively, add an explicit `'static` bound to this reference
   |
LL | fn g<'a, T: 'static>(v: Box<(dyn A<T> + 'static)>) -> Box<dyn X + 'static> {
   |                         ~~~~~~~~~~~~~~~~~~~~~~~~~

The latter mentions a reference which is a bit wrong in this case since only Box-es are involved but it can probably be solved separately.
In any case, we should re-instate those suggestions in NLL mode.

@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 21, 2022
@rustbot rustbot added A-NLL Area: Non-lexical lifetimes (NLL) NLL-diagnostics Working towards the "diagnostic parity" goal labels Apr 21, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Apr 26, 2022
…bound-suggestions, r=jackh726

Recover most `impl Trait` and `dyn Trait` lifetime bound suggestions under NLL

This is done by replacing the duplicated (and very partial) implementation from borrowck with one inspsired from `NiceRegionError::try_report_static_impl_trait` and by re-using `suggest_new_region_bound`.

Fixes rust-lang#96277

r? `@jackh726`
compiler-errors added a commit to compiler-errors/rust that referenced this issue Apr 26, 2022
…bound-suggestions, r=jackh726

Recover most `impl Trait` and `dyn Trait` lifetime bound suggestions under NLL

This is done by replacing the duplicated (and very partial) implementation from borrowck with one inspsired from `NiceRegionError::try_report_static_impl_trait` and by re-using `suggest_new_region_bound`.

Fixes rust-lang#96277

r? ``@jackh726``
@bors bors closed this as completed in dc1f98c Apr 27, 2022
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

Successfully merging a pull request may close this issue.

2 participants