Skip to content

Commit 124ab20

Browse files
committed
Limit from_anon_const to AnonConsts.
1 parent 9bcd9fe commit 124ab20

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/librustc/ty/sty.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2409,7 +2409,10 @@ impl<'tcx> Const<'tcx> {
24092409

24102410
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
24112411

2412-
let body_id = tcx.hir().body_owned_by(hir_id);
2412+
let body_id = match tcx.hir().get(hir_id) {
2413+
hir::Node::AnonConst(ac) => ac.body,
2414+
_ => span_bug!(tcx.def_span(def_id.to_def_id()), "from_anon_const can only process anonymous constants"),
2415+
};
24132416

24142417
let expr = &tcx.hir().body(body_id).value;
24152418

0 commit comments

Comments
 (0)