Skip to content

Commit

Permalink
Limit from_anon_const to AnonConsts.
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Mar 23, 2020
1 parent 9bcd9fe commit 124ab20
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/librustc/ty/sty.rs
Expand Up @@ -2409,7 +2409,10 @@ impl<'tcx> Const<'tcx> {

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

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

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

Expand Down

0 comments on commit 124ab20

Please sign in to comment.