about summary refs log tree commit diff
path: root/src/librustc_mir
diff options
context:
space:
mode:
authorBastian Kauschke <bastian_kauschke@hotmail.de>2020-07-08 10:35:58 +0200
committerBastian Kauschke <bastian_kauschke@hotmail.de>2020-07-15 12:58:33 +0200
commita7fe4df04a095bad08a4158ce0cabed632a16828 (patch)
tree36258fdc7bc764967b0c7e31471b0e4a9f1cf565 /src/librustc_mir
parentae80d7e012e6b0efcacc7b648690a9257445afd7 (diff)
downloadrust-a7fe4df04a095bad08a4158ce0cabed632a16828.tar.gz
rust-a7fe4df04a095bad08a4158ce0cabed632a16828.zip
update promoted_mir
Diffstat (limited to 'src/librustc_mir')
-rw-r--r--src/librustc_mir/const_eval/eval_queries.rs2
-rw-r--r--src/librustc_mir/interpret/eval_context.rs6
-rw-r--r--src/librustc_mir/transform/mod.rs12
3 files changed, 6 insertions, 14 deletions
diff --git a/src/librustc_mir/const_eval/eval_queries.rs b/src/librustc_mir/const_eval/eval_queries.rs
index 38894398343..cec7f1bcb9d 100644
--- a/src/librustc_mir/const_eval/eval_queries.rs
+++ b/src/librustc_mir/const_eval/eval_queries.rs
@@ -360,7 +360,7 @@ pub fn const_eval_raw_provider<'tcx>(
                     // deny-by-default lint
                     _ => {
                         if let Some(p) = cid.promoted {
-                            let span = tcx.promoted_mir_of_const_arg(def)[p].span;
+                            let span = tcx.promoted_mir_of_opt_const_arg(def.to_global())[p].span;
                             if let err_inval!(ReferencedConstant) = err.error {
                                 err.report_as_error(
                                     tcx.at(span),
diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs
index 9cbc6d4dcea..c59b7c98e98 100644
--- a/src/librustc_mir/interpret/eval_context.rs
+++ b/src/librustc_mir/interpret/eval_context.rs
@@ -406,11 +406,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
         }
         trace!("load mir(instance={:?}, promoted={:?})", instance, promoted);
         if let Some(promoted) = promoted {
-            return if let Some(def) = def.as_local() {
-                Ok(&self.tcx.promoted_mir_of_const_arg(def)[promoted])
-            } else {
-                Ok(&self.tcx.promoted_mir(def.did)[promoted])
-            };
+            return Ok(&self.tcx.promoted_mir_of_opt_const_arg(def)[promoted]);
         }
         match instance {
             ty::InstanceDef::Item(def) => {
diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs
index fdcf36a3162..f2d6efae019 100644
--- a/src/librustc_mir/transform/mod.rs
+++ b/src/librustc_mir/transform/mod.rs
@@ -62,12 +62,8 @@ pub(crate) fn provide(providers: &mut Providers) {
         promoted_mir: |tcx, def_id| {
             promoted_mir(tcx, ty::WithOptParam::dummy(def_id.expect_local()))
         },
-        promoted_mir_of_const_arg: |tcx, def| {
-            if def.param_did.is_none() {
-                tcx.promoted_mir(def.did.to_def_id())
-            } else {
-                promoted_mir(tcx, def)
-            }
+        promoted_mir_of_const_arg: |tcx, (did, param_did)| {
+            promoted_mir(tcx, ty::WithOptParam { did, param_did: Some(param_did) })
         },
         ..*providers
     };
@@ -525,8 +521,8 @@ fn promoted_mir<'tcx>(
     def: ty::WithOptParam<LocalDefId>,
 ) -> &'tcx IndexVec<Promoted, Body<'tcx>> {
     if def.param_did.is_none() {
-        if let param_did @ Some(_) = tcx.opt_const_param_of(def.did) {
-            return tcx.promoted_mir_of_const_arg(ty::WithOptParam { param_did, ..def });
+        if let Some(param_did) = tcx.opt_const_param_of(def.did) {
+            return tcx.promoted_mir_of_const_arg((def.did, param_did));
         }
     }