@@ -3664,9 +3664,7 @@ impl<'a> Resolver<'a> {
36643664 crate_lint : CrateLint ,
36653665 ) -> Option < PartialRes > {
36663666 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 ( ) {
36703668 if i == 0 || ns != primary_ns {
36713669 match self . resolve_qpath ( id, qself, path, ns, span, global_by_default, crate_lint) {
36723670 // If defer_to_typeck, then resolution > no resolution,
@@ -3675,21 +3673,25 @@ impl<'a> Resolver<'a> {
36753673 defer_to_typeck =>
36763674 return Some ( partial_res) ,
36773675 partial_res => if fin_res. is_none ( ) { fin_res = partial_res } ,
3678- } ;
3676+ }
36793677 }
36803678 }
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+ }
36923693 }
3694+
36933695 fin_res
36943696 }
36953697
0 commit comments