@@ -214,17 +214,29 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
214214 let item_span = path. last ( ) . unwrap ( ) . ident . span ;
215215 let sp = item_span. peel_ctxt ( ) ;
216216 let ctxt_kind = sp. ctxt ( ) . outer_expn_data ( ) . kind ;
217- let ( mod_prefix, mod_str, suggestion) =
217+ let ( mod_prefix, mod_str, name , mod_label , suggestion) =
218218 if let ExpnKind :: Macro ( MacroKind :: Attr | MacroKind :: Bang , name) = ctxt_kind
219219 && sp. parent_callsite ( ) . map ( |p| ( p. lo ( ) , p. hi ( ) ) ) == Some ( ( sp. lo ( ) , sp. hi ( ) ) )
220220 {
221221 // This span comes from a proc macro and it doesn't point at user code.
222- ( String :: new ( ) , format ! ( "the expanded code of procedural macro `{name}`" ) , None )
222+ (
223+ String :: new ( ) ,
224+ format ! ( "the expanded code of procedural macro `{name}`" ) ,
225+ format ! ( "`{path_str}` " ) ,
226+ format ! ( "expanded code of this procedural macro" ) ,
227+ None ,
228+ )
223229 } else if let ExpnKind :: Macro ( MacroKind :: Derive , name) = ctxt_kind
224230 && sp. parent_callsite ( ) . map ( |p| ( p. lo ( ) , p. hi ( ) ) ) == Some ( ( sp. lo ( ) , sp. hi ( ) ) )
225231 {
226232 // This span comes from a `derive` macro and it doesn't point at user code.
227- ( String :: new ( ) , format ! ( "the expanded code of `derive` macro `{name}`" ) , None )
233+ (
234+ String :: new ( ) ,
235+ format ! ( "the expanded code of `derive` macro `{name}`" ) ,
236+ format ! ( "`{path_str}` " ) ,
237+ format ! ( "expanded code of this `derive` macro" ) ,
238+ None ,
239+ )
228240 } else if path. len ( ) == 1 {
229241 debug ! ( ?self . diagnostic_metadata. current_impl_items) ;
230242 debug ! ( ?self . diagnostic_metadata. current_function) ;
@@ -259,26 +271,31 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
259271 } else {
260272 None
261273 } ;
262- ( String :: new ( ) , "this scope" . to_string ( ) , suggestion)
274+ let s = "this scope" . to_string ( ) ;
275+ ( String :: new ( ) , s. clone ( ) , String :: new ( ) , s, suggestion)
263276 } else if path. len ( ) == 2 && path[ 0 ] . ident . name == kw:: PathRoot {
264277 if self . r . tcx . sess . edition ( ) > Edition :: Edition2015 {
265278 // In edition 2018 onwards, the `::foo` syntax may only pull from the extern prelude
266279 // which overrides all other expectations of item type
267280 expected = "crate" ;
268- ( String :: new ( ) , "the list of imported crates" . to_string ( ) , None )
281+ let s = "the list of imported crates" . to_string ( ) ;
282+ ( String :: new ( ) , s. clone ( ) , String :: new ( ) , s, None )
269283 } else {
270- ( String :: new ( ) , "the crate root" . to_string ( ) , None )
284+ let s = "the crate root" . to_string ( ) ;
285+ ( String :: new ( ) , s. clone ( ) , String :: new ( ) , s, None )
271286 }
272287 } else if path. len ( ) == 2 && path[ 0 ] . ident . name == kw:: Crate {
273- ( String :: new ( ) , "the crate root" . to_string ( ) , None )
288+ let s = "the crate root" . to_string ( ) ;
289+ ( String :: new ( ) , s. clone ( ) , String :: new ( ) , s, None )
274290 } else {
275291 let mod_path = & path[ ..path. len ( ) - 1 ] ;
276292 let mod_prefix = match self . resolve_path ( mod_path, Some ( TypeNS ) , None ) {
277293 PathResult :: Module ( ModuleOrUniformRoot :: Module ( module) ) => module. res ( ) ,
278294 _ => None ,
279295 }
280296 . map_or_else ( String :: new, |res| format ! ( "{} " , res. descr( ) ) ) ;
281- ( mod_prefix, format ! ( "`{}`" , Segment :: names_to_string( mod_path) ) , None )
297+ let s = format ! ( "`{}`" , Segment :: names_to_string( mod_path) ) ;
298+ ( mod_prefix, s. clone ( ) , String :: new ( ) , s, None )
282299 } ;
283300
284301 let ( fallback_label, suggestion) = if path_str == "async"
@@ -302,7 +319,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
302319 } else {
303320 suggestion
304321 } ;
305- ( format ! ( "not found in {mod_str }" ) , override_suggestion)
322+ ( format ! ( "{name} not found in {mod_label }" ) , override_suggestion)
306323 } ;
307324
308325 BaseError {
0 commit comments