diff options
| author | Michael Goulet <michael@errs.io> | 2023-12-05 16:32:47 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-04-09 12:17:34 -0400 |
| commit | ee78eab62be926b69236c9a344fbcec2b3355bbd (patch) | |
| tree | 9055cc675d283252e119cfbe49285575f72c5ad3 /compiler | |
| parent | 2d813547bfec8b2829bf411794811df17de52df5 (diff) | |
| download | rust-ee78eab62be926b69236c9a344fbcec2b3355bbd.tar.gz rust-ee78eab62be926b69236c9a344fbcec2b3355bbd.zip | |
Lint redundant lifetimes in impl header
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/wfcheck.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index cc7c41cb387..01f87ecdebb 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -2028,19 +2028,20 @@ fn lint_redundant_lifetimes<'tcx>( | DefKind::TraitAlias | DefKind::Fn | DefKind::Const - | DefKind::Impl { of_trait: false } => { + | DefKind::Impl { of_trait: _ } => { // Proceed } DefKind::AssocFn | DefKind::AssocTy | DefKind::AssocConst => { let parent_def_id = tcx.local_parent(owner_id); if matches!(tcx.def_kind(parent_def_id), DefKind::Impl { of_trait: true }) { - // Don't check for redundant lifetimes for trait implementations, - // since the signature is required to be compatible with the trait. + // Don't check for redundant lifetimes for associated items of trait + // implementations, since the signature is required to be compatible + // with the trait, even if the implementation implies some lifetimes + // are redundant. return; } } - DefKind::Impl { of_trait: true } - | DefKind::Mod + DefKind::Mod | DefKind::Variant | DefKind::TyAlias | DefKind::ForeignTy |
