@@ -29,7 +29,7 @@ use rustc::{bug, span_bug};
29
29
use syntax:: ast:: { self , Ident , Name , NodeId , CRATE_NODE_ID } ;
30
30
use syntax:: ext:: base:: Determinacy :: { self , Determined , Undetermined } ;
31
31
use syntax:: ext:: hygiene:: Mark ;
32
- use syntax:: symbol:: { kw , sym } ;
32
+ use syntax:: symbol:: kw ;
33
33
use syntax:: util:: lev_distance:: find_best_match_for_name;
34
34
use syntax:: { struct_span_err, unwrap_or} ;
35
35
use syntax_pos:: { MultiSpan , Span } ;
@@ -492,35 +492,26 @@ impl<'a> Resolver<'a> {
492
492
} )
493
493
}
494
494
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
-
506
495
// Define the name or return the existing binding if there is a collision.
507
496
pub fn try_define ( & mut self ,
508
497
module : Module < ' a > ,
509
498
ident : Ident ,
510
499
ns : Namespace ,
511
500
binding : & ' a NameBinding < ' a > )
512
501
-> 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) ;
514
505
self . set_binding_parent_module ( binding, module) ;
515
506
self . update_resolution ( module, ident, ns, |this, resolution| {
516
507
if let Some ( old_binding) = resolution. binding {
517
- if binding . res ( ) == Res :: Err {
508
+ if res == Res :: Err {
518
509
// Do not override real bindings with `Res::Err`s from error recovery.
519
510
return Ok ( ( ) ) ;
520
511
}
521
512
match ( old_binding. is_glob_import ( ) , binding. is_glob_import ( ) ) {
522
513
( true , true ) => {
523
- if binding . res ( ) != old_binding. res ( ) {
514
+ if res != old_binding. res ( ) {
524
515
resolution. binding = Some ( this. ambiguity ( AmbiguityKind :: GlobVsGlob ,
525
516
old_binding, binding) ) ;
526
517
} else if !old_binding. vis . is_at_least ( binding. vis , & * this) {
0 commit comments