Skip to content

Commit a6136d8

Browse files
committed
Simplify super_traits_of
1 parent b02a905 commit a6136d8

File tree

1 file changed

+4
-48
lines changed

1 file changed

+4
-48
lines changed

compiler/rustc_typeck/src/collect.rs

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,54 +1128,10 @@ fn super_traits_of(tcx: TyCtxt<'_>, trait_def_id: DefId) -> Lrc<FxHashSet<DefId>
11281128
continue;
11291129
}
11301130

1131-
if trait_did.is_local() {
1132-
let trait_hir_id = tcx.hir().local_def_id_to_hir_id(trait_did.expect_local());
1133-
1134-
let item = match tcx.hir().get(trait_hir_id) {
1135-
Node::Item(item) => item,
1136-
_ => bug!("super_trait_of {} is not an item", trait_hir_id),
1137-
};
1138-
1139-
let (generics, supertraits) = match item.kind {
1140-
hir::ItemKind::Trait(.., ref generics, ref supertraits, _) => {
1141-
(generics, supertraits)
1142-
}
1143-
hir::ItemKind::TraitAlias(ref generics, ref supertraits) => (generics, supertraits),
1144-
_ => span_bug!(item.span, "super_predicates invoked on non-trait"),
1145-
};
1146-
1147-
for supertrait in supertraits.iter() {
1148-
let trait_ref = supertrait.trait_ref();
1149-
if let Some(trait_did) = trait_ref.and_then(|trait_ref| trait_ref.trait_def_id()) {
1150-
stack.push(trait_did);
1151-
}
1152-
}
1153-
1154-
let icx = ItemCtxt::new(tcx, trait_did);
1155-
// Convert any explicit superbounds in the where-clause,
1156-
// e.g., `trait Foo where Self: Bar`.
1157-
// In the case of trait aliases, however, we include all bounds in the where-clause,
1158-
// so e.g., `trait Foo = where u32: PartialEq<Self>` would include `u32: PartialEq<Self>`
1159-
// as one of its "superpredicates".
1160-
let is_trait_alias = tcx.is_trait_alias(trait_did);
1161-
let self_param_ty = tcx.types.self_param;
1162-
for (predicate, _) in icx.type_parameter_bounds_in_generics(
1163-
generics,
1164-
item.hir_id,
1165-
self_param_ty,
1166-
OnlySelfBounds(!is_trait_alias),
1167-
None,
1168-
) {
1169-
if let ty::PredicateAtom::Trait(data, _) = predicate.skip_binders() {
1170-
stack.push(data.def_id());
1171-
}
1172-
}
1173-
} else {
1174-
let generic_predicates = tcx.super_predicates_of(trait_did);
1175-
for (predicate, _) in generic_predicates.predicates {
1176-
if let ty::PredicateAtom::Trait(data, _) = predicate.skip_binders() {
1177-
stack.push(data.def_id());
1178-
}
1131+
let generic_predicates = tcx.super_predicates_of(trait_did);
1132+
for (predicate, _) in generic_predicates.predicates {
1133+
if let ty::PredicateAtom::Trait(data, _) = predicate.skip_binders() {
1134+
stack.push(data.def_id());
11791135
}
11801136
}
11811137
}

0 commit comments

Comments
 (0)