about summary refs log tree commit diff
path: root/compiler/rustc_passes/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-05-16 17:52:52 +0000
committerbors <bors@rust-lang.org>2021-05-16 17:52:52 +0000
commit7dc9ff5c629753b6930ecfe9a0446538b8e25fb7 (patch)
tree497b34e49454d1f24eb481c8b546061d6a47d747 /compiler/rustc_passes/src
parentf8e1e9238077a829ce1ac0cc1f2c7e0eaa4e679d (diff)
parent1605e0ec4e21d563703f4504740fa90b16089c20 (diff)
downloadrust-7dc9ff5c629753b6930ecfe9a0446538b8e25fb7.tar.gz
rust-7dc9ff5c629753b6930ecfe9a0446538b8e25fb7.zip
Auto merge of #85290 - Amanieu:asm_const_int, r=nagisa
Remove support for floating-point constants in asm!

Floating-point constants aren't very useful anyways and this simplifies
the code since the type check can now be done in typeck.

cc `@rust-lang/wg-inline-asm`

r? `@nagisa`
Diffstat (limited to 'compiler/rustc_passes/src')
-rw-r--r--compiler/rustc_passes/src/intrinsicck.rs43
1 files changed, 2 insertions, 41 deletions
diff --git a/compiler/rustc_passes/src/intrinsicck.rs b/compiler/rustc_passes/src/intrinsicck.rs
index 4532a0a350c..012d97ef106 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, _)) 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,19 +372,7 @@ impl ExprVisitor<'tcx> {
                         );
                     }
                 }
-                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(*op_sp, msg);
-                        }
-                    }
-                }
-                hir::InlineAsmOperand::Sym { .. } => {}
+                hir::InlineAsmOperand::Const { .. } | hir::InlineAsmOperand::Sym { .. } => {}
             }
         }
     }
@@ -405,33 +393,6 @@ impl Visitor<'tcx> for ItemVisitor<'tcx> {
         ExprVisitor { tcx: self.tcx, param_env, typeck_results }.visit_body(body);
         self.visit_body(body);
     }
-
-    fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
-        if let hir::ItemKind::GlobalAsm(asm) = item.kind {
-            for (op, op_sp) in asm.operands {
-                match *op {
-                    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(*op_sp, msg);
-                            }
-                        }
-                    }
-                    hir::InlineAsmOperand::In { .. }
-                    | hir::InlineAsmOperand::Out { .. }
-                    | hir::InlineAsmOperand::InOut { .. }
-                    | hir::InlineAsmOperand::SplitInOut { .. }
-                    | hir::InlineAsmOperand::Sym { .. } => unreachable!(),
-                }
-            }
-        }
-
-        intravisit::walk_item(self, item);
-    }
 }
 
 impl Visitor<'tcx> for ExprVisitor<'tcx> {