diff options
| author | Michael Goulet <michael@errs.io> | 2023-08-22 09:00:49 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-22 09:00:49 -0700 |
| commit | e9897c3a7101abd6539dcaa2e87a9588b1c9b0d9 (patch) | |
| tree | 7b34c5f71c14d81fb6da5398878bd31a6adf51cc /compiler/rustc_lint/src | |
| parent | 6c7678d3289c7ccae1f70ddcb1f7327465cbca24 (diff) | |
| parent | b1c609e2a6716cb76d2690d86d2d9c255cacbb18 (diff) | |
| download | rust-e9897c3a7101abd6539dcaa2e87a9588b1c9b0d9.tar.gz rust-e9897c3a7101abd6539dcaa2e87a9588b1c9b0d9.zip | |
Rollup merge of #115011 - compiler-errors:warn-on-elided-assoc-ct-lt, r=cjgillot
Warn on elided lifetimes in associated constants (`ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT`) Elided lifetimes in associated constants (in impls) erroneously resolve to fresh lifetime parameters on the impl since #97313. This is not correct behavior (see #38831). I originally opened #114716 to fix this, but given the time that has passed, the crater results seem pretty bad: https://github.com/rust-lang/rust/pull/114716#issuecomment-1682091952 This PR alternatively implements a lint against this behavior, and I'm hoping to bump this to deny in a few versions.
Diffstat (limited to 'compiler/rustc_lint/src')
| -rw-r--r-- | compiler/rustc_lint/src/context.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index f73797415bc..aabefb729f3 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -966,6 +966,14 @@ pub trait LintContext: Sized { Applicability::MachineApplicable ); } + BuiltinLintDiagnostics::AssociatedConstElidedLifetime { elided, span } => { + db.span_suggestion_verbose( + if elided { span.shrink_to_hi() } else { span }, + "use the `'static` lifetime", + if elided { "'static " } else { "'static" }, + Applicability::MachineApplicable + ); + } } // Rewrap `db`, and pass control to the user. decorate(db) |
