mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 05:33:27 +00:00
don't call type_of
on generic params
This commit is contained in:
parent
b033883e2b
commit
1cf95a9d50
1 changed files with 5 additions and 0 deletions
|
@ -207,6 +207,11 @@ impl<'tcx> LateLintPass<'tcx> for MissingFieldsInDebug {
|
|||
if let ItemKind::Impl(Impl { of_trait: Some(trait_ref), self_ty, items, .. }) = item.kind
|
||||
&& let Res::Def(DefKind::Trait, trait_def_id) = trait_ref.path.res
|
||||
&& let TyKind::Path(QPath::Resolved(_, self_path)) = &self_ty.kind
|
||||
// don't trigger if self is a generic parameter, e.g. `impl<T> Debug for T`
|
||||
// this can only happen in core itself, where the trait is defined,
|
||||
// but it caused ICEs in the past:
|
||||
// https://github.com/rust-lang/rust-clippy/issues/10887
|
||||
&& !matches!(self_path.res, Res::Def(DefKind::TyParam, _))
|
||||
&& cx.match_def_path(trait_def_id, &[sym::core, sym::fmt, sym::Debug])
|
||||
// don't trigger if this impl was derived
|
||||
&& !cx.tcx.has_attr(item.owner_id, sym::automatically_derived)
|
||||
|
|
Loading…
Reference in a new issue