Rollup merge of #61824 - rust-lang:single_derive, r=eddyb

in which we decline to lint single-use lifetimes in `derive`d impls

Resolves #53738.

r? @eddyb
This commit is contained in:
Mazdak Farrokhzad 2019-06-15 17:45:04 +02:00 committed by GitHub
commit eb188f1317
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View file

@ -1586,6 +1586,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,