Skip to content

Commit 30ddd00

Browse files
committed
Simplify logic for determining anonymous constant parent in generic contexts
1 parent ecb2838 commit 30ddd00

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

  • compiler/rustc_hir_analysis/src/hir_ty_lowering

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -511,15 +511,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
511511
let anon_const_def_id = match tcx.def_kind(parent_def_id) {
512512
DefKind::AnonConst => parent_def_id,
513513
DefKind::InlineConst | DefKind::Closure => {
514-
let mut current = tcx.local_parent(parent_def_id);
515-
loop {
516-
match tcx.def_kind(current) {
517-
DefKind::AnonConst => break current,
518-
DefKind::InlineConst | DefKind::Closure => {
519-
current = tcx.local_parent(current);
520-
}
521-
_ => return None,
522-
}
514+
let root = tcx.typeck_root_def_id(parent_def_id.into());
515+
match tcx.def_kind(root) {
516+
DefKind::AnonConst => root.expect_local(),
517+
_ => return None,
523518
}
524519
}
525520
_ => return None,

0 commit comments

Comments
 (0)