@@ -4,7 +4,8 @@ use rustc_ast::*;
44use rustc_data_structures:: fx:: FxHashMap ;
55use rustc_errors:: struct_span_err;
66use rustc_hir as hir;
7- use rustc_span:: { Span , Symbol } ;
7+ use rustc_session:: parse:: feature_err;
8+ use rustc_span:: { sym, Span , Symbol } ;
89use rustc_target:: asm;
910use std:: collections:: hash_map:: Entry ;
1011use std:: fmt:: Write ;
@@ -18,6 +19,27 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1819 struct_span_err ! ( self . sess, sp, E0472 , "inline assembly is unsupported on this target" )
1920 . emit ( ) ;
2021 }
22+ if let Some ( asm_arch) = asm_arch {
23+ // Inline assembly is currently only stable for these architectures.
24+ let is_stable = matches ! (
25+ asm_arch,
26+ asm:: InlineAsmArch :: X86
27+ | asm:: InlineAsmArch :: X86_64
28+ | asm:: InlineAsmArch :: Arm
29+ | asm:: InlineAsmArch :: AArch64
30+ | asm:: InlineAsmArch :: RiscV32
31+ | asm:: InlineAsmArch :: RiscV64
32+ ) ;
33+ if !is_stable && !self . sess . features_untracked ( ) . asm_experimental_arch {
34+ feature_err (
35+ & self . sess . parse_sess ,
36+ sym:: asm_experimental_arch,
37+ sp,
38+ "inline assembly is not stable yet on this architecture" ,
39+ )
40+ . emit ( ) ;
41+ }
42+ }
2143 if asm. options . contains ( InlineAsmOptions :: ATT_SYNTAX )
2244 && !matches ! ( asm_arch, Some ( asm:: InlineAsmArch :: X86 | asm:: InlineAsmArch :: X86_64 ) )
2345 && !self . sess . opts . actually_rustdoc
@@ -121,10 +143,30 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
121143 out_expr : out_expr. as_ref ( ) . map ( |expr| self . lower_expr_mut ( expr) ) ,
122144 }
123145 }
124- InlineAsmOperand :: Const { ref anon_const } => hir:: InlineAsmOperand :: Const {
125- anon_const : self . lower_anon_const ( anon_const) ,
126- } ,
146+ InlineAsmOperand :: Const { ref anon_const } => {
147+ if !self . sess . features_untracked ( ) . asm_const {
148+ feature_err (
149+ & self . sess . parse_sess ,
150+ sym:: asm_const,
151+ * op_sp,
152+ "const operands for inline assembly are unstable" ,
153+ )
154+ . emit ( ) ;
155+ }
156+ hir:: InlineAsmOperand :: Const {
157+ anon_const : self . lower_anon_const ( anon_const) ,
158+ }
159+ }
127160 InlineAsmOperand :: Sym { ref expr } => {
161+ if !self . sess . features_untracked ( ) . asm_sym {
162+ feature_err (
163+ & self . sess . parse_sess ,
164+ sym:: asm_sym,
165+ * op_sp,
166+ "sym operands for inline assembly are unstable" ,
167+ )
168+ . emit ( ) ;
169+ }
128170 hir:: InlineAsmOperand :: Sym { expr : self . lower_expr_mut ( expr) }
129171 }
130172 } ;
0 commit comments