in which we decline to lint single-use lifetimes in derive
d impls
Resolves #53738.
This commit is contained in:
parent
cdd743755a
commit
17653dd3da
2 changed files with 18 additions and 0 deletions
|
@ -1591,6 +1591,17 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
|||
continue;
|
||||
}
|
||||
|
||||
if let Some(parent_def_id) = self.tcx.parent(def_id) {
|
||||
if let Some(parent_hir_id) = self.tcx.hir()
|
||||
.as_local_hir_id(parent_def_id) {
|
||||
// lifetimes in `derive` expansions don't count (Issue #53738)
|
||||
if self.tcx.hir().attrs_by_hir_id(parent_hir_id).iter()
|
||||
.any(|attr| attr.check_name(sym::automatically_derived)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut err = self.tcx.struct_span_lint_hir(
|
||||
lint::builtin::SINGLE_USE_LIFETIMES,
|
||||
id,
|
||||
|
|
|
@ -18,4 +18,11 @@ enum Bar<'f> {
|
|||
|
||||
trait Baz<'f> { }
|
||||
|
||||
// `Derive`d impls shouldn't trigger a warning, either (Issue #53738).
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Quux<'a> {
|
||||
priors: &'a u32,
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
Loading…
Reference in a new issue