Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2681,6 +2681,12 @@ fn lint_redundant_lifetimes<'tcx>(
owner_id: LocalDefId,
outlives_env: &OutlivesEnvironment<'tcx>,
) {
// Items produced by external macros (e.g. derived impls) reuse the lifetime spans of the
// macro input, so the usual external macro check on the lint span does not catch them.
if tcx.def_span(owner_id).in_external_macro(tcx.sess.source_map()) {
return;
}

let def_kind = tcx.def_kind(owner_id);
match def_kind {
DefKind::Struct
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// FIXME: Bring back duplication of the `#[expect]` attribute when deriving.
//
// Make sure we properly copy the `#[expect]` attr to the derived code and that no
// unfulfilled expectations are trigerred.
// Make sure `#[expect]` on an item with a derive is fulfilled when the lint is only emitted on the
// item itself, and not also on the derived impl, which reuses the lifetime spans of the input.
//
// See <https://github.com/rust-lang/rust/issues/150553> for rational.

//@ check-fail
//@ check-pass

#![deny(redundant_lifetimes)]

Expand All @@ -14,7 +12,6 @@ use std::fmt::Debug;
#[derive(Debug)]
#[expect(redundant_lifetimes)]
pub struct RefWrapper<'a, T>
//~^ ERROR redundant_lifetimes
where
'a: 'static,
T: Debug,
Expand Down

This file was deleted.

Loading