@@ -214,17 +214,29 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
214
214
let item_span = path. last ( ) . unwrap ( ) . ident . span ;
215
215
let sp = item_span. peel_ctxt ( ) ;
216
216
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) =
218
218
if let ExpnKind :: Macro ( MacroKind :: Attr | MacroKind :: Bang , name) = ctxt_kind
219
219
&& sp. parent_callsite ( ) . map ( |p| ( p. lo ( ) , p. hi ( ) ) ) == Some ( ( sp. lo ( ) , sp. hi ( ) ) )
220
220
{
221
221
// 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
+ )
223
229
} else if let ExpnKind :: Macro ( MacroKind :: Derive , name) = ctxt_kind
224
230
&& sp. parent_callsite ( ) . map ( |p| ( p. lo ( ) , p. hi ( ) ) ) == Some ( ( sp. lo ( ) , sp. hi ( ) ) )
225
231
{
226
232
// 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
+ )
228
240
} else if path. len ( ) == 1 {
229
241
debug ! ( ?self . diagnostic_metadata. current_impl_items) ;
230
242
debug ! ( ?self . diagnostic_metadata. current_function) ;
@@ -259,26 +271,31 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
259
271
} else {
260
272
None
261
273
} ;
262
- ( String :: new ( ) , "this scope" . to_string ( ) , suggestion)
274
+ let s = "this scope" . to_string ( ) ;
275
+ ( String :: new ( ) , s. clone ( ) , String :: new ( ) , s, suggestion)
263
276
} else if path. len ( ) == 2 && path[ 0 ] . ident . name == kw:: PathRoot {
264
277
if self . r . tcx . sess . edition ( ) > Edition :: Edition2015 {
265
278
// In edition 2018 onwards, the `::foo` syntax may only pull from the extern prelude
266
279
// which overrides all other expectations of item type
267
280
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 )
269
283
} 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 )
271
286
}
272
287
} 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 )
274
290
} else {
275
291
let mod_path = & path[ ..path. len ( ) - 1 ] ;
276
292
let mod_prefix = match self . resolve_path ( mod_path, Some ( TypeNS ) , None ) {
277
293
PathResult :: Module ( ModuleOrUniformRoot :: Module ( module) ) => module. res ( ) ,
278
294
_ => None ,
279
295
}
280
296
. 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 )
282
299
} ;
283
300
284
301
let ( fallback_label, suggestion) = if path_str == "async"
@@ -302,7 +319,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
302
319
} else {
303
320
suggestion
304
321
} ;
305
- ( format ! ( "not found in {mod_str }" ) , override_suggestion)
322
+ ( format ! ( "{name} not found in {mod_label }" ) , override_suggestion)
306
323
} ;
307
324
308
325
BaseError {
0 commit comments