@@ -158,6 +158,9 @@ pub struct Features {
158
158
pub visible_private_types : bool ,
159
159
pub allow_quote : bool ,
160
160
pub allow_asm : bool ,
161
+ pub allow_log_syntax : bool ,
162
+ pub allow_concat_idents : bool ,
163
+ pub allow_trace_macros : bool ,
161
164
pub old_orphan_check : bool ,
162
165
pub simd_ffi : bool ,
163
166
pub unmarked_api : bool ,
@@ -175,6 +178,9 @@ impl Features {
175
178
visible_private_types : false ,
176
179
allow_quote : false ,
177
180
allow_asm : false ,
181
+ allow_log_syntax : false ,
182
+ allow_concat_idents : false ,
183
+ allow_trace_macros : false ,
178
184
old_orphan_check : false ,
179
185
simd_ffi : false ,
180
186
unmarked_api : false ,
@@ -226,6 +232,15 @@ pub fn emit_feature_warn(diag: &SpanHandler, feature: &str, span: Span, explain:
226
232
pub const EXPLAIN_ASM : & ' static str =
227
233
"inline assembly is not stable enough for use and is subject to change" ;
228
234
235
+ pub const EXPLAIN_LOG_SYNTAX : & ' static str =
236
+ "`log_syntax!` is not stable enough for use and is subject to change" ;
237
+
238
+ pub const EXPLAIN_CONCAT_IDENTS : & ' static str =
239
+ "`concat_idents` is not stable enough for use and is subject to change" ;
240
+
241
+ pub const EXPLAIN_TRACE_MACROS : & ' static str =
242
+ "`trace_macros` is not stable enough for use and is subject to change" ;
243
+
229
244
struct MacroVisitor < ' a > {
230
245
context : & ' a Context < ' a >
231
246
}
@@ -235,23 +250,28 @@ impl<'a, 'v> Visitor<'v> for MacroVisitor<'a> {
235
250
let ast:: MacInvocTT ( ref path, _, _) = mac. node ;
236
251
let id = path. segments . last ( ) . unwrap ( ) . identifier ;
237
252
253
+ // Issue 22234: If you add a new case here, make sure to also
254
+ // add code to catch the macro during or after expansion.
255
+ //
256
+ // We still keep this MacroVisitor (rather than *solely*
257
+ // relying on catching cases during or after expansion) to
258
+ // catch uses of these macros within conditionally-compiled
259
+ // code, e.g. `#[cfg]`-guarded functions.
260
+
238
261
if id == token:: str_to_ident ( "asm" ) {
239
262
self . context . gate_feature ( "asm" , path. span , EXPLAIN_ASM ) ;
240
263
}
241
264
242
265
else if id == token:: str_to_ident ( "log_syntax" ) {
243
- self . context . gate_feature ( "log_syntax" , path. span , "`log_syntax!` is not \
244
- stable enough for use and is subject to change") ;
266
+ self . context . gate_feature ( "log_syntax" , path. span , EXPLAIN_LOG_SYNTAX ) ;
245
267
}
246
268
247
269
else if id == token:: str_to_ident ( "trace_macros" ) {
248
- self . context . gate_feature ( "trace_macros" , path. span , "`trace_macros` is not \
249
- stable enough for use and is subject to change") ;
270
+ self . context . gate_feature ( "trace_macros" , path. span , EXPLAIN_TRACE_MACROS ) ;
250
271
}
251
272
252
273
else if id == token:: str_to_ident ( "concat_idents" ) {
253
- self . context . gate_feature ( "concat_idents" , path. span , "`concat_idents` is not \
254
- stable enough for use and is subject to change") ;
274
+ self . context . gate_feature ( "concat_idents" , path. span , EXPLAIN_CONCAT_IDENTS ) ;
255
275
}
256
276
}
257
277
}
@@ -594,12 +614,18 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::C
594
614
595
615
check ( & mut cx, krate) ;
596
616
617
+ // FIXME (pnkfelix): Before adding the 99th entry below, change it
618
+ // to a single-pass (instead of N calls to `.has_feature`).
619
+
597
620
Features {
598
621
unboxed_closures : cx. has_feature ( "unboxed_closures" ) ,
599
622
rustc_diagnostic_macros : cx. has_feature ( "rustc_diagnostic_macros" ) ,
600
623
visible_private_types : cx. has_feature ( "visible_private_types" ) ,
601
624
allow_quote : cx. has_feature ( "quote" ) ,
602
625
allow_asm : cx. has_feature ( "asm" ) ,
626
+ allow_log_syntax : cx. has_feature ( "log_syntax" ) ,
627
+ allow_concat_idents : cx. has_feature ( "concat_idents" ) ,
628
+ allow_trace_macros : cx. has_feature ( "trace_macros" ) ,
603
629
old_orphan_check : cx. has_feature ( "old_orphan_check" ) ,
604
630
simd_ffi : cx. has_feature ( "simd_ffi" ) ,
605
631
unmarked_api : cx. has_feature ( "unmarked_api" ) ,
0 commit comments