@@ -3664,9 +3664,7 @@ impl<'a> Resolver<'a> {
3664
3664
crate_lint : CrateLint ,
3665
3665
) -> Option < PartialRes > {
3666
3666
let mut fin_res = None ;
3667
- // FIXME: can't resolve paths in macro namespace yet, macros are
3668
- // processed by the little special hack below.
3669
- for ( i, ns) in [ primary_ns, TypeNS , ValueNS , /*MacroNS*/ ] . iter ( ) . cloned ( ) . enumerate ( ) {
3667
+ for ( i, ns) in [ primary_ns, TypeNS , ValueNS ] . iter ( ) . cloned ( ) . enumerate ( ) {
3670
3668
if i == 0 || ns != primary_ns {
3671
3669
match self . resolve_qpath ( id, qself, path, ns, span, global_by_default, crate_lint) {
3672
3670
// If defer_to_typeck, then resolution > no resolution,
@@ -3675,21 +3673,25 @@ impl<'a> Resolver<'a> {
3675
3673
defer_to_typeck =>
3676
3674
return Some ( partial_res) ,
3677
3675
partial_res => if fin_res. is_none ( ) { fin_res = partial_res } ,
3678
- } ;
3676
+ }
3679
3677
}
3680
3678
}
3681
- if primary_ns != MacroNS &&
3682
- ( self . macro_names . contains ( & path[ 0 ] . ident . modern ( ) ) ||
3683
- self . builtin_macros . get ( & path[ 0 ] . ident . name ) . cloned ( )
3684
- . and_then ( NameBinding :: macro_kind) == Some ( MacroKind :: Bang ) ||
3685
- self . macro_use_prelude . get ( & path[ 0 ] . ident . name ) . cloned ( )
3686
- . and_then ( NameBinding :: macro_kind) == Some ( MacroKind :: Bang ) ) {
3687
- // Return some dummy definition, it's enough for error reporting.
3688
- return Some ( PartialRes :: new ( Res :: Def (
3689
- DefKind :: Macro ( MacroKind :: Bang ) ,
3690
- DefId :: local ( CRATE_DEF_INDEX ) ,
3691
- ) ) ) ;
3679
+
3680
+ // `MacroNS`
3681
+ assert ! ( primary_ns != MacroNS ) ;
3682
+ if qself. is_none ( ) {
3683
+ let path_seg = |seg : & Segment | ast:: PathSegment :: from_ident ( seg. ident ) ;
3684
+ let path = Path { segments : path. iter ( ) . map ( path_seg) . collect ( ) , span } ;
3685
+ let parent_scope =
3686
+ ParentScope { module : self . current_module , ..self . dummy_parent_scope ( ) } ;
3687
+ for macro_kind in & [ MacroKind :: Bang , MacroKind :: Attr , MacroKind :: Derive ] {
3688
+ if let Ok ( ( _, res) ) = self . resolve_macro_path ( & path, * macro_kind,
3689
+ & parent_scope, false , false ) {
3690
+ return Some ( PartialRes :: new ( res) ) ;
3691
+ }
3692
+ }
3692
3693
}
3694
+
3693
3695
fin_res
3694
3696
}
3695
3697
0 commit comments