Skip to content

Commit e04db20

Browse files
committed
Remove redundant check
1 parent 412c984 commit e04db20

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

compiler/rustc_passes/src/dead.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -378,13 +378,16 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
378378
}
379379
hir::ItemKind::ForeignMod { .. } => {}
380380
hir::ItemKind::Trait(..) => {
381-
// mark dependent traits live
382381
for impl_def_id in self.tcx.all_impls(item.owner_id.to_def_id()) {
383382
if let Some(local_def_id) = impl_def_id.as_local()
384383
&& let ItemKind::Impl(impl_ref) =
385384
self.tcx.hir().expect_item(local_def_id).kind
386385
{
386+
// skip items
387+
// mark dependent traits live
387388
intravisit::walk_generics(self, impl_ref.generics);
389+
// mark dependent parameters live
390+
intravisit::walk_path(self, impl_ref.of_trait.unwrap().path);
388391
}
389392
}
390393

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

402405
for impl_def in self.tcx.all_impls(trait_def_id) {
403406
if let Some(impl_def_id) = impl_def.as_local()
404407
&& let ItemKind::Impl(impl_ref) =
405408
self.tcx.hir().expect_item(impl_def_id).kind
406409
{
407-
self.check_def_id(impl_def);
410+
// mark self_ty live
411+
intravisit::walk_ty(self, impl_ref.self_ty);
408412
for impl_item in impl_ref.items {
409413
if Some(def_id) == impl_item.trait_item_def_id {
410414
self.check_def_id(impl_item.id.owner_id.to_def_id());

0 commit comments

Comments
 (0)