]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_mir_build/src/build/misc.rs
do use ty::Const in patterns and abstract consts
[rust.git] / compiler / rustc_mir_build / src / build / misc.rs
index fd5914460140a84044acf8c62b889c51d56a0f07..84762d602f8db5030f46e9c4046ed9f3000bf833 100644 (file)
@@ -3,6 +3,7 @@
 
 use crate::build::Builder;
 
+use rustc_middle::mir;
 use rustc_middle::mir::*;
 use rustc_middle::ty::{self, Ty};
 use rustc_span::{Span, DUMMY_SP};
@@ -25,8 +26,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
 
     /// Convenience function for creating a literal operand, one
     /// without any user type annotation.
-    crate fn literal_operand(&mut self, span: Span, literal: ty::Const<'tcx>) -> Operand<'tcx> {
-        let literal = literal.into();
+    crate fn literal_operand(
+        &mut self,
+        span: Span,
+        literal: mir::ConstantKind<'tcx>,
+    ) -> Operand<'tcx> {
         let constant = Box::new(Constant { span, user_ty: None, literal });
         Operand::Constant(constant)
     }
@@ -34,7 +38,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
     // Returns a zero literal operand for the appropriate type, works for
     // bool, char and integers.
     crate fn zero_literal(&mut self, span: Span, ty: Ty<'tcx>) -> Operand<'tcx> {
-        let literal = ty::Const::from_bits(self.tcx, 0, ty::ParamEnv::empty().and(ty));
+        let literal = ConstantKind::from_bits(self.tcx, 0, ty::ParamEnv::empty().and(ty));
 
         self.literal_operand(span, literal)
     }
@@ -54,7 +58,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
             Constant {
                 span: source_info.span,
                 user_ty: None,
-                literal: ty::Const::from_usize(self.tcx, value).into(),
+                literal: ConstantKind::from_usize(self.tcx, value),
             },
         );
         temp