]> git.lizzy.rs Git - rust.git/commitdiff
`<&'tcx ty::Const as Deref>::deref`
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Thu, 13 Dec 2018 10:11:12 +0000 (11:11 +0100)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Tue, 1 Jan 2019 19:05:02 +0000 (20:05 +0100)
20 files changed:
src/librustc/mir/interpret/error.rs
src/librustc/mir/mod.rs
src/librustc/ty/codec.rs
src/librustc/ty/context.rs
src/librustc/ty/query/keys.rs
src/librustc/ty/structural_impls.rs
src/librustc/ty/sty.rs
src/librustc_codegen_ssa/mir/constant.rs
src/librustc_codegen_ssa/mir/operand.rs
src/librustc_mir/build/matches/mod.rs
src/librustc_mir/build/matches/test.rs
src/librustc_mir/build/misc.rs
src/librustc_mir/const_eval.rs
src/librustc_mir/hair/constant.rs
src/librustc_mir/hair/cx/expr.rs
src/librustc_mir/hair/cx/mod.rs
src/librustc_mir/hair/pattern/_match.rs
src/librustc_mir/hair/pattern/mod.rs
src/librustc_mir/monomorphize/collector.rs
src/librustc_mir/shim.rs

index 19be0c08ef13bad5917967fdaacdd7de5d212e4c..c3fe5d773ab16e4c4d55d44e5b69b827da3d53f0 100644 (file)
@@ -37,7 +37,7 @@ pub fn assert_reported(self) {
 }
 
 pub type ConstEvalRawResult<'tcx> = Result<RawConst<'tcx>, ErrorHandled>;
-pub type ConstEvalResult<'tcx> = Result<&'tcx ty::Const<'tcx>, ErrorHandled>;
+pub type ConstEvalResult<'tcx> = Result<ty::Const<'tcx>, ErrorHandled>;
 
 #[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
 pub struct ConstEvalErr<'tcx> {
index eafae6d9c9e8de10accf61bd2c1f7b60f9c2c2d2..a1a6e890b1292de4691455187d3226128c357283 100644 (file)
@@ -1666,7 +1666,7 @@ pub fn fmt_successor_labels(&self) -> Vec<Cow<'static, str>> {
                             ),
                             ty: switch_ty,
                         };
-                        fmt_const_val(&mut s, &c).unwrap();
+                        fmt_const_val(&mut s, c).unwrap();
                         s.into()
                     }).chain(iter::once("otherwise".into()))
                     .collect()
@@ -2155,7 +2155,7 @@ pub fn function_handle<'a>(
             ty,
             user_ty: None,
             literal: tcx.intern_lazy_const(
-                ty::LazyConst::Evaluated(ty::Const::zero_sized(tcx, ty)),
+                ty::LazyConst::Evaluated(ty::Const::zero_sized(ty)),
             ),
         })
     }
@@ -2663,14 +2663,14 @@ fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
 
 /// Write a `ConstValue` in a way closer to the original source code than the `Debug` output.
 pub fn fmt_lazy_const_val(f: &mut impl Write, const_val: &ty::LazyConst<'_>) -> fmt::Result {
-    match const_val {
+    match *const_val {
         ty::LazyConst::Unevaluated(..) => write!(f, "{:?}", const_val),
         ty::LazyConst::Evaluated(c) => fmt_const_val(f, c),
     }
 }
 
 /// Write a `ConstValue` in a way closer to the original source code than the `Debug` output.
-pub fn fmt_const_val(f: &mut impl Write, const_val: &ty::Const<'_>) -> fmt::Result {
+pub fn fmt_const_val(f: &mut impl Write, const_val: ty::Const<'_>) -> fmt::Result {
     use ty::TyKind::*;
     let value = const_val.val;
     let ty = const_val.ty;
index 57b99db0c7d54afc418b13e590d4d7d04d882c75..e0e4d9c362a6ca0c1cc3690b357bad71851572ce 100644 (file)
@@ -246,15 +246,6 @@ pub fn decode_canonical_var_infos<'a, 'tcx, D>(decoder: &mut D)
               .intern_canonical_var_infos(interned?.as_slice()))
 }
 
-#[inline]
-pub fn decode_const<'a, 'tcx, D>(decoder: &mut D)
-                                 -> Result<&'tcx ty::Const<'tcx>, D::Error>
-    where D: TyDecoder<'a, 'tcx>,
-          'tcx: 'a,
-{
-    Ok(decoder.tcx().mk_const(Decodable::decode(decoder)?))
-}
-
 #[inline]
 pub fn decode_lazy_const<'a, 'tcx, D>(decoder: &mut D)
                                  -> Result<&'tcx ty::LazyConst<'tcx>, D::Error>
@@ -398,13 +389,6 @@ fn specialized_decode(&mut self)
                 }
             }
 
-            impl<$($typaram),*> SpecializedDecoder<&'tcx $crate::ty::Const<'tcx>>
-            for $DecoderName<$($typaram),*> {
-                fn specialized_decode(&mut self) -> Result<&'tcx ty::Const<'tcx>, Self::Error> {
-                    decode_const(self)
-                }
-            }
-
             impl<$($typaram),*> SpecializedDecoder<&'tcx $crate::ty::LazyConst<'tcx>>
             for $DecoderName<$($typaram),*> {
                 fn specialized_decode(&mut self) -> Result<&'tcx ty::LazyConst<'tcx>, Self::Error> {
index 715e7367fada7c03ffd4a3df77422cdded1ce6ef..108fcc1bd3f21023aff4e79c6bb118b174432c38 100644 (file)
@@ -122,7 +122,6 @@ pub struct CtxtInterners<'tcx> {
     region: InternedSet<'tcx, RegionKind>,
     existential_predicates: InternedSet<'tcx, List<ExistentialPredicate<'tcx>>>,
     predicates: InternedSet<'tcx, List<Predicate<'tcx>>>,
-    const_: InternedSet<'tcx, Const<'tcx>>,
     clauses: InternedSet<'tcx, List<Clause<'tcx>>>,
     goal: InternedSet<'tcx, GoalKind<'tcx>>,
     goal_list: InternedSet<'tcx, List<Goal<'tcx>>>,
@@ -140,7 +139,6 @@ fn new(arena: &'tcx SyncDroplessArena) -> CtxtInterners<'tcx> {
             existential_predicates: Default::default(),
             canonical_var_infos: Default::default(),
             predicates: Default::default(),
-            const_: Default::default(),
             clauses: Default::default(),
             goal: Default::default(),
             goal_list: Default::default(),
@@ -1071,24 +1069,6 @@ pub fn alloc_byte_array(self, bytes: &[u8]) -> &'gcx [u8] {
         }
     }
 
-    pub fn alloc_const_slice(self, values: &[&'tcx ty::Const<'tcx>])
-                             -> &'tcx [&'tcx ty::Const<'tcx>] {
-        if values.is_empty() {
-            &[]
-        } else {
-            self.interners.arena.alloc_slice(values)
-        }
-    }
-
-    pub fn alloc_name_const_slice(self, values: &[(ast::Name, &'tcx ty::Const<'tcx>)])
-                                  -> &'tcx [(ast::Name, &'tcx ty::Const<'tcx>)] {
-        if values.is_empty() {
-            &[]
-        } else {
-            self.interners.arena.alloc_slice(values)
-        }
-    }
-
     pub fn intern_const_alloc(
         self,
         alloc: Allocation,
@@ -1833,9 +1813,9 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<&'tcx Laz
     }
 }
 
-impl<'a, 'tcx> Lift<'tcx> for &'a Const<'a> {
-    type Lifted = &'tcx Const<'tcx>;
-    fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<&'tcx Const<'tcx>> {
+impl<'a, 'tcx> Lift<'tcx> for &'a mir::interpret::Allocation {
+    type Lifted = &'tcx mir::interpret::Allocation;
+    fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
         if tcx.interners.arena.in_arena(*self as *const _) {
             return Some(unsafe { mem::transmute(*self) });
         }
@@ -2516,7 +2496,6 @@ pub fn keep_local<'tcx, T: ty::TypeFoldable<'tcx>>(x: &T) -> bool {
 
 direct_interners!('tcx,
     region: mk_region(|r: &RegionKind| r.keep_in_local_tcx()) -> RegionKind,
-    const_: mk_const(|c: &Const<'_>| keep_local(&c.ty) || keep_local(&c.val)) -> Const<'tcx>,
     goal: mk_goal(|c: &GoalKind<'_>| keep_local(c)) -> GoalKind<'tcx>
 );
 
index 959a5ff5767a36119ac1faee800a8952a3cfb83d..af6f5a00dee5c914d3a269001525db7a2cc0302e 100644 (file)
@@ -136,7 +136,7 @@ fn default_span(&self, tcx: TyCtxt<'_, '_, '_>) -> Span {
     }
 }
 
-impl<'tcx> Key for &'tcx ty::Const<'tcx> {
+impl<'tcx> Key for ty::Const<'tcx> {
     fn query_crate(&self) -> CrateNum {
         LOCAL_CRATE
     }
index 28184725b1c81bdf333953a239936fd53b8742d0..6e599531f25ee77f30341816e61d2ce3044f48a1 100644 (file)
@@ -53,7 +53,6 @@
     ::ty::UniverseIndex,
     ::ty::Variance,
     ::syntax_pos::Span,
-    ConstValue<'tcx>,
 }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -492,6 +491,26 @@ impl<'a, 'tcx> Lift<'tcx> for interpret::GlobalId<'a> {
     }
 }
 
+BraceStructLiftImpl! {
+    impl<'a, 'tcx> Lift<'tcx> for ty::Const<'a> {
+        type Lifted = ty::Const<'tcx>;
+        val, ty
+    }
+}
+
+impl<'a, 'tcx> Lift<'tcx> for ConstValue<'a> {
+    type Lifted = ConstValue<'tcx>;
+    fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
+        match *self {
+            ConstValue::Scalar(x) => Some(ConstValue::Scalar(x)),
+            ConstValue::ScalarPair(x, y) => Some(ConstValue::ScalarPair(x, y)),
+            ConstValue::ByRef(x, alloc, z) => Some(ConstValue::ByRef(
+                x, alloc.lift_to_tcx(tcx)?, z,
+            )),
+        }
+    }
+}
+
 ///////////////////////////////////////////////////////////////////////////
 // TypeFoldable implementations.
 //
@@ -1048,17 +1067,27 @@ fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
     }
 }
 
-impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Const<'tcx> {
+impl<'tcx> TypeFoldable<'tcx> for ty::Const<'tcx> {
     fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
         let ty = self.ty.fold_with(folder);
         let val = self.val.fold_with(folder);
-        folder.tcx().mk_const(ty::Const {
+        ty::Const {
             ty,
             val
-        })
+        }
     }
 
     fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
         self.ty.visit_with(visitor) || self.val.visit_with(visitor)
     }
 }
+
+impl<'tcx> TypeFoldable<'tcx> for ConstValue<'tcx> {
+    fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, _folder: &mut F) -> Self {
+        *self
+    }
+
+    fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> bool {
+        false
+    }
+}
index 6fd3fbd7376f2ea94c615be89f1ec956f690f1c4..be33911d4849ce9f7054329a4679ed4057eb6418 100644 (file)
@@ -2018,13 +2018,11 @@ pub fn is_trivially_sized(&self, tcx: TyCtxt<'_, '_, 'tcx>) -> bool {
 /// code is monomorphic enough for that.
 pub enum LazyConst<'tcx> {
     Unevaluated(DefId, &'tcx Substs<'tcx>),
-    Evaluated(&'tcx Const<'tcx>),
+    Evaluated(Const<'tcx>),
 }
 
-static_assert!(MEM_SIZE_OF_LAZY_CONST: ::std::mem::size_of::<LazyConst<'_>>() <= 24);
-
 impl<'tcx> LazyConst<'tcx> {
-    pub fn map_evaluated<R>(self, f: impl FnOnce(&'tcx Const<'tcx>) -> Option<R>) -> Option<R> {
+    pub fn map_evaluated<R>(self, f: impl FnOnce(Const<'tcx>) -> Option<R>) -> Option<R> {
         match self {
             LazyConst::Evaluated(c) => f(c),
             LazyConst::Unevaluated(..) => None,
@@ -2050,25 +2048,15 @@ pub struct Const<'tcx> {
 }
 
 impl<'tcx> Const<'tcx> {
-    #[inline]
-    pub fn from_const_value(
-        tcx: TyCtxt<'_, '_, 'tcx>,
-        val: ConstValue<'tcx>,
-        ty: Ty<'tcx>,
-    ) -> &'tcx Self {
-        tcx.mk_const(Const {
-            val,
-            ty,
-        })
-    }
-
     #[inline]
     pub fn from_scalar(
-        tcx: TyCtxt<'_, '_, 'tcx>,
         val: Scalar,
         ty: Ty<'tcx>,
-    ) -> &'tcx Self {
-        Self::from_const_value(tcx, ConstValue::Scalar(val), ty)
+    ) -> Self {
+        Self {
+            val: ConstValue::Scalar(val),
+            ty,
+        }
     }
 
     #[inline]
@@ -2076,7 +2064,7 @@ pub fn from_bits(
         tcx: TyCtxt<'_, '_, 'tcx>,
         bits: u128,
         ty: ParamEnvAnd<'tcx, Ty<'tcx>>,
-    ) -> &'tcx Self {
+    ) -> Self {
         let ty = tcx.lift_to_global(&ty).unwrap();
         let size = tcx.layout_of(ty).unwrap_or_else(|e| {
             panic!("could not compute layout for {:?}: {:?}", ty, e)
@@ -2084,21 +2072,21 @@ pub fn from_bits(
         let shift = 128 - size.bits();
         let truncated = (bits << shift) >> shift;
         assert_eq!(truncated, bits, "from_bits called with untruncated value");
-        Self::from_scalar(tcx, Scalar::Bits { bits, size: size.bytes() as u8 }, ty.value)
+        Self::from_scalar(Scalar::Bits { bits, size: size.bytes() as u8 }, ty.value)
     }
 
     #[inline]
-    pub fn zero_sized(tcx: TyCtxt<'_, '_, 'tcx>, ty: Ty<'tcx>) -> &'tcx Self {
-        Self::from_scalar(tcx, Scalar::Bits { bits: 0, size: 0 }, ty)
+    pub fn zero_sized(ty: Ty<'tcx>) -> Self {
+        Self::from_scalar(Scalar::Bits { bits: 0, size: 0 }, ty)
     }
 
     #[inline]
-    pub fn from_bool(tcx: TyCtxt<'_, '_, 'tcx>, v: bool) -> &'tcx Self {
+    pub fn from_bool(tcx: TyCtxt<'_, '_, 'tcx>, v: bool) -> Self {
         Self::from_bits(tcx, v as u128, ParamEnv::empty().and(tcx.types.bool))
     }
 
     #[inline]
-    pub fn from_usize(tcx: TyCtxt<'_, '_, 'tcx>, n: u64) -> &'tcx Self {
+    pub fn from_usize(tcx: TyCtxt<'_, '_, 'tcx>, n: u64) -> Self {
         Self::from_bits(tcx, n as u128, ParamEnv::empty().and(tcx.types.usize))
     }
 
@@ -2164,5 +2152,4 @@ pub fn unwrap_usize(&self, tcx: TyCtxt<'_, '_, '_>) -> u64 {
     }
 }
 
-impl<'tcx> serialize::UseSpecializedDecodable for &'tcx Const<'tcx> {}
 impl<'tcx> serialize::UseSpecializedDecodable for &'tcx LazyConst<'tcx> {}
index 35bd3a32e81828e2563d643cf33601ca4b381c87..e6d6ef1d7a38b35aebb87984e7b6410381eefe14 100644 (file)
@@ -15,7 +15,7 @@ fn fully_evaluate(
         &mut self,
         bx: &Bx,
         constant: &'tcx ty::LazyConst<'tcx>,
-    ) -> Result<&'tcx ty::Const<'tcx>, ErrorHandled> {
+    ) -> Result<ty::Const<'tcx>, ErrorHandled> {
         match *constant {
             ty::LazyConst::Unevaluated(def_id, ref substs) => {
                 let tcx = bx.tcx();
@@ -35,7 +35,7 @@ pub fn eval_mir_constant(
         &mut self,
         bx: &Bx,
         constant: &mir::Constant<'tcx>,
-    ) -> Result<&'tcx ty::Const<'tcx>, ErrorHandled> {
+    ) -> Result<ty::Const<'tcx>, ErrorHandled> {
         let c = self.monomorphize(&constant.literal);
         self.fully_evaluate(bx, c)
     }
@@ -46,7 +46,7 @@ pub fn simd_shuffle_indices(
         bx: &Bx,
         span: Span,
         ty: Ty<'tcx>,
-        constant: Result<&'tcx ty::Const<'tcx>, ErrorHandled>,
+        constant: Result<ty::Const<'tcx>, ErrorHandled>,
     ) -> (Bx::Value, Ty<'tcx>) {
         constant
             .and_then(|c| {
index bb55bf3b46cd4caa41e302c949ce3c23a26e734d..2026e042ef0eb652b8a9992848e2a021822fb538 100644 (file)
@@ -67,7 +67,7 @@ pub fn new_zst<Cx: CodegenMethods<'tcx, Value = V>>(
 
     pub fn from_const<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
         bx: &mut Bx,
-        val: &'tcx ty::Const<'tcx>
+        val: ty::Const<'tcx>
     ) -> Result<Self, ErrorHandled> {
         let layout = bx.cx().layout_of(val.ty);
 
index fe5bc6e19db659bb4af1308d74ca7199298a7bc5..409b6c038ab69200e57853778e68a0e22df08835 100644 (file)
@@ -658,12 +658,12 @@ enum TestKind<'tcx> {
     SwitchInt {
         switch_ty: Ty<'tcx>,
         options: Vec<u128>,
-        indices: FxHashMap<&'tcx ty::Const<'tcx>, usize>,
+        indices: FxHashMap<ty::Const<'tcx>, usize>,
     },
 
     // test for equality
     Eq {
-        value: &'tcx ty::Const<'tcx>,
+        value: ty::Const<'tcx>,
         ty: Ty<'tcx>,
     },
 
index f601e38717f2d035d249cf931cb5ca29806f87ae..3d960a2dd288abbc4bc1d72d961d4be2f90438b8 100644 (file)
@@ -101,7 +101,7 @@ pub fn add_cases_to_switch<'pat>(&mut self,
                                      candidate: &Candidate<'pat, 'tcx>,
                                      switch_ty: Ty<'tcx>,
                                      options: &mut Vec<u128>,
-                                     indices: &mut FxHashMap<&'tcx ty::Const<'tcx>, usize>)
+                                     indices: &mut FxHashMap<ty::Const<'tcx>, usize>)
                                      -> bool
     {
         let match_pair = match candidate.match_pairs.iter().find(|mp| mp.place == *test_place) {
index 0689dcfceea250d3bf844340963d5d75e81e648b..b4887dada7aeb4d7deff9513925c2d599ba7414a 100644 (file)
@@ -27,7 +27,7 @@ pub fn temp(&mut self, ty: Ty<'tcx>, span: Span) -> Place<'tcx> {
     pub fn literal_operand(&mut self,
                            span: Span,
                            ty: Ty<'tcx>,
-                           literal: &'tcx ty::Const<'tcx>)
+                           literal: ty::Const<'tcx>)
                            -> Operand<'tcx> {
         let constant = box Constant {
             span,
index 2722355b050f9aa3e96ef54e17bb2629fe894e02..01177e5e49a0ef1042e70f421ee6f1e4471b2c57 100644 (file)
@@ -95,7 +95,7 @@ pub fn op_to_const<'tcx>(
     ecx: &CompileTimeEvalContext<'_, '_, 'tcx>,
     op: OpTy<'tcx>,
     may_normalize: bool,
-) -> EvalResult<'tcx, &'tcx ty::Const<'tcx>> {
+) -> EvalResult<'tcx, ty::Const<'tcx>> {
     // We do not normalize just any data.  Only scalar layout and fat pointers.
     let normalize = may_normalize
         && match op.layout.abi {
@@ -134,7 +134,7 @@ pub fn op_to_const<'tcx>(
         Ok(Immediate::ScalarPair(a, b)) =>
             ConstValue::ScalarPair(a.not_undef()?, b.not_undef()?),
     };
-    Ok(ty::Const::from_const_value(ecx.tcx.tcx, val, op.layout.ty))
+    Ok(ty::Const { val, ty: op.layout.ty })
 }
 
 pub fn lazy_const_to_op<'tcx>(
@@ -510,7 +510,7 @@ pub fn const_field<'a, 'tcx>(
     instance: ty::Instance<'tcx>,
     variant: Option<VariantIdx>,
     field: mir::Field,
-    value: &'tcx ty::Const<'tcx>,
+    value: ty::Const<'tcx>,
 ) -> ::rustc::mir::interpret::ConstEvalResult<'tcx> {
     trace!("const_field: {:?}, {:?}, {:?}", instance, field, value);
     let ecx = mk_eval_cx(tcx, instance, param_env).unwrap();
@@ -539,7 +539,7 @@ pub fn const_variant_index<'a, 'tcx>(
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
     param_env: ty::ParamEnv<'tcx>,
     instance: ty::Instance<'tcx>,
-    val: &'tcx ty::Const<'tcx>,
+    val: ty::Const<'tcx>,
 ) -> EvalResult<'tcx, VariantIdx> {
     trace!("const_variant_index: {:?}, {:?}", instance, val);
     let ecx = mk_eval_cx(tcx, instance, param_env).unwrap();
index c98ef31c2bae22b958f357b969e54be0948ce89c..37d741d2606d52630542cbd26703df1240634eb2 100644 (file)
@@ -14,7 +14,7 @@
     tcx: TyCtxt<'a, 'gcx, 'tcx>,
     ty: Ty<'tcx>,
     neg: bool,
-) -> Result<&'tcx ty::Const<'tcx>, LitToConstError> {
+) -> Result<ty::Const<'tcx>, LitToConstError> {
     use syntax::ast::*;
 
     let trunc = |n| {
@@ -64,7 +64,7 @@
         LitKind::Bool(b) => ConstValue::Scalar(Scalar::from_bool(b)),
         LitKind::Char(c) => ConstValue::Scalar(Scalar::from_char(c)),
     };
-    Ok(ty::Const::from_const_value(tcx, lit, ty))
+    Ok(ty::Const { val: lit, ty })
 }
 
 fn parse_float<'tcx>(
index e2d0f6b0ae6255486891ba01a9bd8d8b263c7cc2..532e6783f2f2bc38dd49aa1f5b7b202732ee9994 100644 (file)
@@ -871,7 +871,7 @@ fn method_callee<'a, 'gcx, 'tcx>(
         span,
         kind: ExprKind::Literal {
             literal: cx.tcx().intern_lazy_const(ty::LazyConst::Evaluated(
-                ty::Const::zero_sized(cx.tcx(), ty)
+                ty::Const::zero_sized(ty)
             )),
             user_ty,
         },
@@ -933,7 +933,6 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
             debug!("convert_path_expr: user_ty={:?}", user_ty);
             ExprKind::Literal {
                 literal: cx.tcx.intern_lazy_const(ty::LazyConst::Evaluated(ty::Const::zero_sized(
-                    cx.tcx,
                     cx.tables().node_id_to_type(expr.hir_id),
                 ))),
                 user_ty,
index 5681237c14b3e05e1e5b15c4a7c1c7ff5ffe401c..25c5498b5f1e43573d2602a72787a8a2adc51b35 100644 (file)
@@ -134,7 +134,7 @@ pub fn const_eval_literal(
         ty: Ty<'tcx>,
         sp: Span,
         neg: bool,
-    ) -> &'tcx ty::Const<'tcx> {
+    ) -> ty::Const<'tcx> {
         trace!("const_eval_literal: {:#?}, {:?}, {:?}, {:?}", lit, ty, sp, neg);
 
         match lit_to_const(lit, self.tcx, ty, neg) {
@@ -169,14 +169,14 @@ pub fn trait_method(&mut self,
                         method_name: &str,
                         self_ty: Ty<'tcx>,
                         params: &[Kind<'tcx>])
-                        -> (Ty<'tcx>, &'tcx ty::Const<'tcx>) {
+                        -> (Ty<'tcx>, ty::Const<'tcx>) {
         let method_name = Symbol::intern(method_name);
         let substs = self.tcx.mk_substs_trait(self_ty, params);
         for item in self.tcx.associated_items(trait_def_id) {
             if item.kind == ty::AssociatedKind::Method && item.ident.name == method_name {
                 let method_ty = self.tcx.type_of(item.def_id);
                 let method_ty = method_ty.subst(self.tcx, substs);
-                return (method_ty, ty::Const::zero_sized(self.tcx, method_ty));
+                return (method_ty, ty::Const::zero_sized(method_ty));
             }
         }
 
index 0f5510a2921d7d84228faa1261fa0b6ab1bcf7ef..57b0fb1d8be1e0bcd0ee08ed591e7b611193ea00 100644 (file)
@@ -420,7 +420,7 @@ pub enum Constructor<'tcx> {
     /// Enum variants.
     Variant(DefId),
     /// Literal values.
-    ConstantValue(&'tcx ty::Const<'tcx>),
+    ConstantValue(ty::Const<'tcx>),
     /// Ranges of literal values (`2...5` and `2..5`).
     ConstantRange(u128, u128, Ty<'tcx>, RangeEnd),
     /// Array patterns of length n.
@@ -1787,7 +1787,7 @@ fn specialize<'p, 'a: 'p, 'tcx: 'a>(
                                         &cx.tcx, ptr, layout.size,
                                     ).ok()?;
                                     let scalar = scalar.not_undef().ok()?;
-                                    let value = ty::Const::from_scalar(cx.tcx, scalar, ty);
+                                    let value = ty::Const::from_scalar(scalar, ty);
                                     let pattern = Pattern {
                                         ty,
                                         span: pat.span,
index 10d2d7bc1b18b7cb63bc724e5447c51d76a937b5..f52aeded19ae797bb6117786b2167543b846b8ef 100644 (file)
@@ -123,7 +123,7 @@ pub enum PatternKind<'tcx> {
     },
 
     Constant {
-        value: &'tcx ty::Const<'tcx>,
+        value: ty::Const<'tcx>,
     },
 
     Range(PatternRange<'tcx>),
@@ -147,8 +147,8 @@ pub enum PatternKind<'tcx> {
 
 #[derive(Clone, Copy, Debug, PartialEq)]
 pub struct PatternRange<'tcx> {
-    pub lo: &'tcx ty::Const<'tcx>,
-    pub hi: &'tcx ty::Const<'tcx>,
+    pub lo: ty::Const<'tcx>,
+    pub hi: ty::Const<'tcx>,
     pub ty: Ty<'tcx>,
     pub end: RangeEnd,
 }
@@ -857,7 +857,7 @@ fn lower_lit(&mut self, expr: &'tcx hir::Expr) -> PatternKind<'tcx> {
     fn const_to_pat(
         &self,
         instance: ty::Instance<'tcx>,
-        cv: &'tcx ty::Const<'tcx>,
+        cv: ty::Const<'tcx>,
         id: hir::HirId,
         span: Span,
     ) -> Pattern<'tcx> {
@@ -1018,7 +1018,7 @@ fn super_fold_with<F: PatternFolder<$lt_tcx>>(&self, _: &mut F) -> Self {
 }
 
 CloneImpls!{ <'tcx>
-    Span, Field, Mutability, ast::Name, ast::NodeId, usize, &'tcx ty::Const<'tcx>,
+    Span, Field, Mutability, ast::Name, ast::NodeId, usize, ty::Const<'tcx>,
     Region<'tcx>, Ty<'tcx>, BindingMode<'tcx>, &'tcx AdtDef,
     &'tcx Substs<'tcx>, &'tcx Kind<'tcx>, UserTypeAnnotation<'tcx>,
     UserTypeProjection<'tcx>, PatternTypeProjection<'tcx>
@@ -1140,8 +1140,8 @@ fn super_fold_with<F: PatternFolder<'tcx>>(&self, folder: &mut F) -> Self {
 
 pub fn compare_const_vals<'a, 'gcx, 'tcx>(
     tcx: TyCtxt<'a, 'gcx, 'tcx>,
-    a: &'tcx ty::Const<'tcx>,
-    b: &'tcx ty::Const<'tcx>,
+    a: ty::Const<'tcx>,
+    b: ty::Const<'tcx>,
     ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
 ) -> Option<Ordering> {
     trace!("compare_const_vals: {:?}, {:?}", a, b);
index 757f94f2076acd3117cc16e4b976c72dc7be962a..eabfd47c9fb9033016e7ad70a19dc2c5189450d9 100644 (file)
@@ -1252,10 +1252,10 @@ fn collect_lazy_const<'a, 'tcx>(
 
 fn collect_const<'a, 'tcx>(
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
-    constant: &ty::Const<'tcx>,
+    constant: ty::Const<'tcx>,
     output: &mut Vec<MonoItem<'tcx>>,
 ) {
-    debug!("visiting const {:?}", *constant);
+    debug!("visiting const {:?}", constant);
 
     match constant.val {
         ConstValue::ScalarPair(Scalar::Ptr(a), Scalar::Ptr(b)) => {
index 73e26d6349340706445e557afbde5834d71d2d90..8710a09c209cfc701e8f899d9a844e9e14626576 100644 (file)
@@ -460,7 +460,7 @@ fn make_clone_call(
             ty: func_ty,
             user_ty: None,
             literal: tcx.intern_lazy_const(ty::LazyConst::Evaluated(
-                ty::Const::zero_sized(self.tcx, func_ty),
+                ty::Const::zero_sized(func_ty),
             )),
         });
 
@@ -760,7 +760,7 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                 ty,
                 user_ty: None,
                 literal: tcx.intern_lazy_const(ty::LazyConst::Evaluated(
-                    ty::Const::zero_sized(tcx, ty)
+                    ty::Const::zero_sized(ty)
                 )),
              }),
              vec![rcvr])