Skip to content

Commit

Permalink
Remove redundant check
Browse files Browse the repository at this point in the history
  • Loading branch information
mu001999 committed Nov 25, 2023
1 parent 412c984 commit e04db20
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions compiler/rustc_passes/src/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,16 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
}
hir::ItemKind::ForeignMod { .. } => {}
hir::ItemKind::Trait(..) => {
// mark dependent traits live
for impl_def_id in self.tcx.all_impls(item.owner_id.to_def_id()) {
if let Some(local_def_id) = impl_def_id.as_local()
&& let ItemKind::Impl(impl_ref) =
self.tcx.hir().expect_item(local_def_id).kind
{
// skip items
// mark dependent traits live
intravisit::walk_generics(self, impl_ref.generics);
// mark dependent parameters live
intravisit::walk_path(self, impl_ref.of_trait.unwrap().path);
}
}

Expand All @@ -396,15 +399,16 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
// mark corresponing ImplTerm live
let def_id = trait_item.owner_id.to_def_id();
if let Some(trait_def_id) = self.tcx.trait_of_item(def_id) {
// for assoc fn without self, mark the trait live
// mark the trait live
self.check_def_id(trait_def_id);

for impl_def in self.tcx.all_impls(trait_def_id) {
if let Some(impl_def_id) = impl_def.as_local()
&& let ItemKind::Impl(impl_ref) =
self.tcx.hir().expect_item(impl_def_id).kind
{
self.check_def_id(impl_def);
// mark self_ty live
intravisit::walk_ty(self, impl_ref.self_ty);
for impl_item in impl_ref.items {
if Some(def_id) == impl_item.trait_item_def_id {
self.check_def_id(impl_item.id.owner_id.to_def_id());
Expand Down

0 comments on commit e04db20

Please sign in to comment.