@@ -4,7 +4,8 @@ use rustc_ast::*;
4
4
use rustc_data_structures:: fx:: FxHashMap ;
5
5
use rustc_errors:: struct_span_err;
6
6
use rustc_hir as hir;
7
- use rustc_span:: { Span , Symbol } ;
7
+ use rustc_session:: parse:: feature_err;
8
+ use rustc_span:: { sym, Span , Symbol } ;
8
9
use rustc_target:: asm;
9
10
use std:: collections:: hash_map:: Entry ;
10
11
use std:: fmt:: Write ;
@@ -18,6 +19,27 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
18
19
struct_span_err ! ( self . sess, sp, E0472 , "inline assembly is unsupported on this target" )
19
20
. emit ( ) ;
20
21
}
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
+ }
21
43
if asm. options . contains ( InlineAsmOptions :: ATT_SYNTAX )
22
44
&& !matches ! ( asm_arch, Some ( asm:: InlineAsmArch :: X86 | asm:: InlineAsmArch :: X86_64 ) )
23
45
&& !self . sess . opts . actually_rustdoc
@@ -121,10 +143,30 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
121
143
out_expr : out_expr. as_ref ( ) . map ( |expr| self . lower_expr_mut ( expr) ) ,
122
144
}
123
145
}
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
+ }
127
160
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
+ }
128
170
hir:: InlineAsmOperand :: Sym { expr : self . lower_expr_mut ( expr) }
129
171
}
130
172
} ;
0 commit comments