about summary refs log tree commit diff
path: root/compiler/rustc_passes/src
diff options
context:
space:
mode:
authorAmanieu d'Antras <amanieu@gmail.com>2021-04-06 05:50:55 +0100
committerAmanieu d'Antras <amanieu@gmail.com>2021-04-06 12:35:41 +0100
commit32be124e306e537590cedcb56e6c16db7f9d8ce7 (patch)
treef1556b2b11d22a126ad37867267ff2afe6bb9f33 /compiler/rustc_passes/src
parentcbd6ec760453b333e86aac106f47fe9132498924 (diff)
downloadrust-32be124e306e537590cedcb56e6c16db7f9d8ce7.tar.gz
rust-32be124e306e537590cedcb56e6c16db7f9d8ce7.zip
Use AnonConst for asm! constants
Diffstat (limited to 'compiler/rustc_passes/src')
-rw-r--r--compiler/rustc_passes/src/intrinsicck.rs11
-rw-r--r--compiler/rustc_passes/src/liveness.rs2
2 files changed, 7 insertions, 6 deletions
diff --git a/compiler/rustc_passes/src/intrinsicck.rs b/compiler/rustc_passes/src/intrinsicck.rs
index 0f4bb635eee..3f095d0e824 100644
--- a/compiler/rustc_passes/src/intrinsicck.rs
+++ b/compiler/rustc_passes/src/intrinsicck.rs
@@ -347,7 +347,7 @@ impl ExprVisitor<'tcx> {
     }
 
     fn check_asm(&self, asm: &hir::InlineAsm<'tcx>) {
-        for (idx, (op, _op_sp)) in asm.operands.iter().enumerate() {
+        for (idx, (op, op_sp)) in asm.operands.iter().enumerate() {
             match *op {
                 hir::InlineAsmOperand::In { reg, ref expr } => {
                     self.check_asm_operand_type(idx, reg, expr, asm.template, None);
@@ -372,14 +372,15 @@ impl ExprVisitor<'tcx> {
                         );
                     }
                 }
-                hir::InlineAsmOperand::Const { ref expr } => {
-                    let ty = self.typeck_results.expr_ty_adjusted(expr);
-                    match ty.kind() {
+                hir::InlineAsmOperand::Const { ref anon_const } => {
+                    let anon_const_def_id = self.tcx.hir().local_def_id(anon_const.hir_id);
+                    let value = ty::Const::from_anon_const(self.tcx, anon_const_def_id);
+                    match value.ty.kind() {
                         ty::Int(_) | ty::Uint(_) | ty::Float(_) => {}
                         _ => {
                             let msg =
                                 "asm `const` arguments must be integer or floating-point values";
-                            self.tcx.sess.span_err(expr.span, msg);
+                            self.tcx.sess.span_err(*op_sp, msg);
                         }
                     }
                 }
diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs
index f24309fa950..e22a108aaf0 100644
--- a/compiler/rustc_passes/src/liveness.rs
+++ b/compiler/rustc_passes/src/liveness.rs
@@ -1067,7 +1067,6 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
                 for (op, _op_sp) in asm.operands.iter().rev() {
                     match op {
                         hir::InlineAsmOperand::In { expr, .. }
-                        | hir::InlineAsmOperand::Const { expr, .. }
                         | hir::InlineAsmOperand::Sym { expr, .. } => {
                             succ = self.propagate_through_expr(expr, succ)
                         }
@@ -1085,6 +1084,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
                             }
                             succ = self.propagate_through_expr(in_expr, succ);
                         }
+                        hir::InlineAsmOperand::Const { .. } => {}
                     }
                 }
                 succ