use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_hir::intravisit::FnKind;
-use rustc_hir::{BindingAnnotation, Body, FnDecl, GenericArg, HirId, ItemKind, Node, PatKind, QPath, TyKind};
+use rustc_hir::{BindingAnnotation, Body, FnDecl, GenericArg, HirId, ItemKind, Impl, Node, PatKind, QPath, TyKind};
use rustc_infer::infer::TyCtxtInferExt;
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::{self, TypeFoldable};
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
if matches!(
item.kind,
- ItemKind::Impl { of_trait: Some(_), .. } | ItemKind::Trait(..)
+ ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..)
) {
return;
}
.filter(|p| !p.is_global())
.filter_map(|obligation| {
// Note that we do not want to deal with qualified predicates here.
- if let ty::PredicateKind::Atom(ty::PredicateAtom::Trait(pred, _)) = obligation.predicate.kind() {
- if pred.def_id() == sized_trait {
- return None;
+ let binder = obligation.predicate.bound_atom();
+ match binder.skip_binder() {
+ ty::PredicateAtom::Trait(pred, _) if !binder.has_escaping_bound_vars() => {
+ if pred.def_id() == sized_trait {
+ return None;
+ }
+ Some(pred)
}
- Some(pred)
- } else {
- None
+ _ => None,
}
})
.collect::<Vec<_>>();