about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2020-03-23 19:35:19 +0100
committerOliver Scherer <github35764891676564198441@oli-obk.de>2020-03-23 19:35:19 +0100
commit124ab20d4bbbe28d50b641836e3a87f1d796767d (patch)
treeebf79a8e35f265a95ea0c73c8444902a53b473c9
parent9bcd9fe6743aabcf6d96b3fafcd86d1e36114eed (diff)
downloadrust-124ab20d4bbbe28d50b641836e3a87f1d796767d.tar.gz
rust-124ab20d4bbbe28d50b641836e3a87f1d796767d.zip
Limit `from_anon_const` to `AnonConst`s.
-rw-r--r--src/librustc/ty/sty.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs
index ed441797874..e49a29f687c 100644
--- a/src/librustc/ty/sty.rs
+++ b/src/librustc/ty/sty.rs
@@ -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;