@@ -114,17 +114,21 @@ fn sub_namespace_match(candidate: Option<MacroKind>, requirement: Option<MacroKi
114114// We don't want to format a path using pretty-printing,
115115// `format!("{}", path)`, because that tries to insert
116116// line-breaks and is slow.
117- fn fast_print_path ( path : & ast:: Path ) -> String {
118- let mut path_str = String :: with_capacity ( 64 ) ;
119- for ( i, segment) in path. segments . iter ( ) . enumerate ( ) {
120- if i != 0 {
121- path_str. push_str ( "::" ) ;
122- }
123- if segment. ident . name != kw:: PathRoot {
124- path_str. push_str ( & segment. ident . as_str ( ) )
117+ fn fast_print_path ( path : & ast:: Path ) -> Symbol {
118+ if path. segments . len ( ) == 1 {
119+ return path. segments [ 0 ] . ident . name
120+ } else {
121+ let mut path_str = String :: with_capacity ( 64 ) ;
122+ for ( i, segment) in path. segments . iter ( ) . enumerate ( ) {
123+ if i != 0 {
124+ path_str. push_str ( "::" ) ;
125+ }
126+ if segment. ident . name != kw:: PathRoot {
127+ path_str. push_str ( & segment. ident . as_str ( ) )
128+ }
125129 }
130+ Symbol :: intern ( & path_str)
126131 }
127- path_str
128132}
129133
130134impl < ' a > base:: Resolver for Resolver < ' a > {
@@ -219,14 +223,10 @@ impl<'a> base::Resolver for Resolver<'a> {
219223 } ;
220224
221225 let span = invoc. span ( ) ;
222- let path = fast_print_path ( path) ;
223- let format = match kind {
224- MacroKind :: Derive => format ! ( "derive({})" , path) ,
225- _ => path. clone ( ) ,
226- } ;
227- invoc. expansion_data . mark . set_expn_info ( ext. expn_info ( span, & format) ) ;
226+ let descr = fast_print_path ( path) ;
227+ invoc. expansion_data . mark . set_expn_info ( ext. expn_info ( span, descr) ) ;
228228
229- self . check_stability_and_deprecation ( & ext, & path , span) ;
229+ self . check_stability_and_deprecation ( & ext, descr , span) ;
230230
231231 if let Res :: Def ( _, def_id) = res {
232232 if after_derive {
@@ -991,7 +991,7 @@ impl<'a> Resolver<'a> {
991991 }
992992 }
993993
994- fn check_stability_and_deprecation ( & self , ext : & SyntaxExtension , path : & str , span : Span ) {
994+ fn check_stability_and_deprecation ( & self , ext : & SyntaxExtension , descr : Symbol , span : Span ) {
995995 if let Some ( stability) = & ext. stability {
996996 if let StabilityLevel :: Unstable { reason, issue } = stability. level {
997997 let feature = stability. feature ;
@@ -1000,14 +1000,14 @@ impl<'a> Resolver<'a> {
10001000 }
10011001 }
10021002 if let Some ( depr) = & stability. rustc_depr {
1003- let ( message, lint) = stability:: rustc_deprecation_message ( depr, path ) ;
1003+ let ( message, lint) = stability:: rustc_deprecation_message ( depr, & descr . as_str ( ) ) ;
10041004 stability:: early_report_deprecation (
10051005 self . session , & message, depr. suggestion , lint, span
10061006 ) ;
10071007 }
10081008 }
10091009 if let Some ( depr) = & ext. deprecation {
1010- let ( message, lint) = stability:: deprecation_message ( depr, path ) ;
1010+ let ( message, lint) = stability:: deprecation_message ( depr, & descr . as_str ( ) ) ;
10111011 stability:: early_report_deprecation ( self . session , & message, None , lint, span) ;
10121012 }
10131013 }
0 commit comments