about summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros/src
diff options
context:
space:
mode:
authorAmanieu d'Antras <amanieu@gmail.com>2022-03-01 00:50:56 +0000
committerAmanieu d'Antras <amanieu@gmail.com>2022-04-14 15:32:03 +0100
commitdc345d8bffdd95c65ba537c32a6900b8c19c049d (patch)
tree78f026fb2d4b9d98045e7b4a05c4135ebe6c52b4 /compiler/rustc_builtin_macros/src
parentf9d4d12b6ab97fae8b9a6f607473fe149f38f6bd (diff)
downloadrust-dc345d8bffdd95c65ba537c32a6900b8c19c049d.tar.gz
rust-dc345d8bffdd95c65ba537c32a6900b8c19c049d.zip
Reimplement lowering of sym operands for asm! so that it also works with global_asm!
Diffstat (limited to 'compiler/rustc_builtin_macros/src')
-rw-r--r--compiler/rustc_builtin_macros/src/asm.rs22
1 files changed, 12 insertions, 10 deletions
diff --git a/compiler/rustc_builtin_macros/src/asm.rs b/compiler/rustc_builtin_macros/src/asm.rs
index 57ef46475dd..030295d3d8d 100644
--- a/compiler/rustc_builtin_macros/src/asm.rs
+++ b/compiler/rustc_builtin_macros/src/asm.rs
@@ -154,17 +154,19 @@ pub fn parse_asm_args<'a>(
         } else if p.eat_keyword(kw::Const) {
             let anon_const = p.parse_anon_const_expr()?;
             ast::InlineAsmOperand::Const { anon_const }
-        } else if !is_global_asm && p.eat_keyword(sym::sym) {
+        } else if p.eat_keyword(sym::sym) {
             let expr = p.parse_expr()?;
-            match expr.kind {
-                ast::ExprKind::Path(..) => {}
-                _ => {
-                    let err = diag
-                        .struct_span_err(expr.span, "argument to `sym` must be a path expression");
-                    return Err(err);
-                }
-            }
-            ast::InlineAsmOperand::Sym { expr }
+            let ast::ExprKind::Path(qself, path) = &expr.kind else {
+                let err = diag
+                    .struct_span_err(expr.span, "expected a path for argument to `sym`");
+                return Err(err);
+            };
+            let sym = ast::InlineAsmSym {
+                id: ast::DUMMY_NODE_ID,
+                qself: qself.clone(),
+                path: path.clone(),
+            };
+            ast::InlineAsmOperand::Sym { sym }
         } else if allow_templates {
             let template = p.parse_expr()?;
             // If it can't possibly expand to a string, provide diagnostics here to include other