about summary refs log tree commit diff
path: root/src/librustc_mir
diff options
context:
space:
mode:
authorRakshith Ravi <rakshith.ravi@gmx.com>2020-05-24 19:38:54 +0530
committerRakshith Ravi <rakshith.ravi@gmx.com>2020-05-24 19:38:54 +0530
commit245ebc7210f99528d65e4b46f012dbde2a2f299f (patch)
treed255edcf561048cbaed17e28bf9d9a97d61f608c /src/librustc_mir
parent52b605c8cb2f730e607de0777a694cd1b9bb3e15 (diff)
downloadrust-245ebc7210f99528d65e4b46f012dbde2a2f299f.tar.gz
rust-245ebc7210f99528d65e4b46f012dbde2a2f299f.zip
Removed all instances of const_field.
Diffstat (limited to 'src/librustc_mir')
-rw-r--r--src/librustc_mir/const_eval/eval_queries.rs2
-rw-r--r--src/librustc_mir/const_eval/mod.rs27
-rw-r--r--src/librustc_mir/lib.rs4
3 files changed, 1 insertions, 32 deletions
diff --git a/src/librustc_mir/const_eval/eval_queries.rs b/src/librustc_mir/const_eval/eval_queries.rs
index fd5e0632a2c..695e0741e35 100644
--- a/src/librustc_mir/const_eval/eval_queries.rs
+++ b/src/librustc_mir/const_eval/eval_queries.rs
@@ -122,7 +122,7 @@ pub(super) fn op_to_const<'tcx>(
     } else {
         // It is guaranteed that any non-slice scalar pair is actually ByRef here.
         // When we come back from raw const eval, we are always by-ref. The only way our op here is
-        // by-val is if we are in const_field, i.e., if this is (a field of) something that we
+        // by-val is if we are in destructure_const, i.e., if this is (a field of) something that we
         // "tried to make immediate" before. We wouldn't do that for non-slice scalar pairs or
         // structs containing such.
         op.try_as_mplace(ecx)
diff --git a/src/librustc_mir/const_eval/mod.rs b/src/librustc_mir/const_eval/mod.rs
index 7f557e340bb..3539ccf5de0 100644
--- a/src/librustc_mir/const_eval/mod.rs
+++ b/src/librustc_mir/const_eval/mod.rs
@@ -5,7 +5,6 @@ use std::convert::TryFrom;
 use rustc_middle::mir;
 use rustc_middle::ty::{self, TyCtxt};
 use rustc_span::{source_map::DUMMY_SP, symbol::Symbol};
-use rustc_target::abi::VariantIdx;
 
 use crate::interpret::{intern_const_alloc_recursive, ConstValue, InternKind, InterpCx};
 
@@ -19,32 +18,6 @@ pub use eval_queries::*;
 pub use fn_queries::*;
 pub use machine::*;
 
-/// Extracts a field of a (variant of a) const.
-// this function uses `unwrap` copiously, because an already validated constant must have valid
-// fields and can thus never fail outside of compiler bugs
-pub(crate) fn const_field<'tcx>(
-    tcx: TyCtxt<'tcx>,
-    param_env: ty::ParamEnv<'tcx>,
-    variant: Option<VariantIdx>,
-    field: mir::Field,
-    value: &'tcx ty::Const<'tcx>,
-) -> ConstValue<'tcx> {
-    trace!("const_field: {:?}, {:?}", field, value);
-    let ecx = mk_eval_cx(tcx, DUMMY_SP, param_env, false);
-    // get the operand again
-    let op = ecx.eval_const_to_op(value, None).unwrap();
-    // downcast
-    let down = match variant {
-        None => op,
-        Some(variant) => ecx.operand_downcast(op, variant).unwrap(),
-    };
-    // then project
-    let field = ecx.operand_field(down, field.index()).unwrap();
-    // and finally move back to the const world, always normalizing because
-    // this is not called for statics.
-    op_to_const(&ecx, field)
-}
-
 pub(crate) fn const_caller_location(
     tcx: TyCtxt<'tcx>,
     (file, line, col): (Symbol, u32, u32),
diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs
index 785c6c21d74..928d5bf88f2 100644
--- a/src/librustc_mir/lib.rs
+++ b/src/librustc_mir/lib.rs
@@ -56,10 +56,6 @@ pub fn provide(providers: &mut Providers<'_>) {
     providers.const_eval_validated = const_eval::const_eval_validated_provider;
     providers.const_eval_raw = const_eval::const_eval_raw_provider;
     providers.const_caller_location = const_eval::const_caller_location;
-    providers.const_field = |tcx, param_env_and_value| {
-        let (param_env, (value, field)) = param_env_and_value.into_parts();
-        const_eval::const_field(tcx, param_env, None, field, value)
-    };
     providers.destructure_const = |tcx, param_env_and_value| {
         let (param_env, value) = param_env_and_value.into_parts();
         const_eval::destructure_const(tcx, param_env, value)