@@ -29,7 +29,7 @@ use rustc::{bug, span_bug};
2929use syntax:: ast:: { self , Ident , Name , NodeId , CRATE_NODE_ID } ;
3030use syntax:: ext:: base:: Determinacy :: { self , Determined , Undetermined } ;
3131use syntax:: ext:: hygiene:: Mark ;
32- use syntax:: symbol:: { kw , sym } ;
32+ use syntax:: symbol:: kw ;
3333use syntax:: util:: lev_distance:: find_best_match_for_name;
3434use syntax:: { struct_span_err, unwrap_or} ;
3535use syntax_pos:: { MultiSpan , Span } ;
@@ -492,35 +492,26 @@ impl<'a> Resolver<'a> {
492492 } )
493493 }
494494
495- crate fn check_reserved_macro_name ( & self , ident : Ident , ns : Namespace ) {
496- // Reserve some names that are not quite covered by the general check
497- // performed on `Resolver::builtin_attrs`.
498- if ns == MacroNS &&
499- ( ident. name == sym:: cfg || ident. name == sym:: cfg_attr ||
500- ident. name == sym:: derive) {
501- self . session . span_err ( ident. span ,
502- & format ! ( "name `{}` is reserved in macro namespace" , ident) ) ;
503- }
504- }
505-
506495 // Define the name or return the existing binding if there is a collision.
507496 pub fn try_define ( & mut self ,
508497 module : Module < ' a > ,
509498 ident : Ident ,
510499 ns : Namespace ,
511500 binding : & ' a NameBinding < ' a > )
512501 -> Result < ( ) , & ' a NameBinding < ' a > > {
513- self . check_reserved_macro_name ( ident, ns) ;
502+ let res = binding. res ( ) ;
503+ let macro_kind = self . opt_get_macro ( res) . map ( |ext| ext. macro_kind ( ) ) ;
504+ self . check_reserved_macro_name ( ident, macro_kind) ;
514505 self . set_binding_parent_module ( binding, module) ;
515506 self . update_resolution ( module, ident, ns, |this, resolution| {
516507 if let Some ( old_binding) = resolution. binding {
517- if binding . res ( ) == Res :: Err {
508+ if res == Res :: Err {
518509 // Do not override real bindings with `Res::Err`s from error recovery.
519510 return Ok ( ( ) ) ;
520511 }
521512 match ( old_binding. is_glob_import ( ) , binding. is_glob_import ( ) ) {
522513 ( true , true ) => {
523- if binding . res ( ) != old_binding. res ( ) {
514+ if res != old_binding. res ( ) {
524515 resolution. binding = Some ( this. ambiguity ( AmbiguityKind :: GlobVsGlob ,
525516 old_binding, binding) ) ;
526517 } else if !old_binding. vis . is_at_least ( binding. vis , & * this) {
0 commit comments