@@ -19,9 +19,8 @@ use syntax::ext::base::{MacroKind, SyntaxExtension};
1919use syntax:: ext:: expand:: { AstFragment , Invocation , InvocationKind } ;
2020use syntax:: ext:: hygiene:: Mark ;
2121use syntax:: ext:: tt:: macro_rules;
22- use syntax:: feature_gate:: {
23- feature_err, is_builtin_attr_name, AttributeGate , GateIssue , Stability , BUILTIN_ATTRIBUTES ,
24- } ;
22+ use syntax:: feature_gate:: { feature_err, emit_feature_err, is_builtin_attr_name} ;
23+ use syntax:: feature_gate:: { AttributeGate , GateIssue , Stability , BUILTIN_ATTRIBUTES } ;
2524use syntax:: symbol:: { Symbol , kw, sym} ;
2625use syntax:: visit:: Visitor ;
2726use syntax:: util:: lev_distance:: find_best_match_for_name;
@@ -298,12 +297,25 @@ impl<'a> Resolver<'a> {
298297 let res = self . resolve_macro_to_res_inner ( path, kind, parent_scope, trace, force) ;
299298
300299 // Report errors and enforce feature gates for the resolved macro.
300+ let features = self . session . features_untracked ( ) ;
301301 if res != Err ( Determinacy :: Undetermined ) {
302302 // Do not report duplicated errors on every undetermined resolution.
303303 for segment in & path. segments {
304304 if let Some ( args) = & segment. args {
305305 self . session . span_err ( args. span ( ) , "generic arguments in macro path" ) ;
306306 }
307+ if kind == MacroKind :: Attr && !features. rustc_attrs &&
308+ segment. ident . as_str ( ) . starts_with ( "rustc" ) {
309+ let msg = "attributes starting with `rustc` are \
310+ reserved for use by the `rustc` compiler";
311+ emit_feature_err (
312+ & self . session . parse_sess ,
313+ sym:: rustc_attrs,
314+ segment. ident . span ,
315+ GateIssue :: Language ,
316+ msg,
317+ ) ;
318+ }
307319 }
308320 }
309321
@@ -320,7 +332,6 @@ impl<'a> Resolver<'a> {
320332 }
321333 Res :: NonMacroAttr ( attr_kind) => {
322334 if kind == MacroKind :: Attr {
323- let features = self . session . features_untracked ( ) ;
324335 if attr_kind == NonMacroAttrKind :: Custom {
325336 assert ! ( path. segments. len( ) == 1 ) ;
326337 if !features. custom_attribute {
0 commit comments