@@ -30,7 +30,7 @@ use rustc_span::hygiene::MacroKind;
30
30
use rustc_span:: source_map:: SourceMap ;
31
31
use rustc_span:: { BytePos , Ident , Span , Symbol , SyntaxContext , kw, sym} ;
32
32
use thin_vec:: { ThinVec , thin_vec} ;
33
- use tracing:: debug;
33
+ use tracing:: { debug, instrument } ;
34
34
35
35
use crate :: errors:: {
36
36
self , AddedMacroUse , ChangeImportBinding , ChangeImportBindingSuggestion , ConsiderAddingADerive ,
@@ -2237,12 +2237,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
2237
2237
/// Adds suggestions for a path that cannot be resolved.
2238
2238
pub ( crate ) fn make_path_suggestion (
2239
2239
& mut self ,
2240
- span : Span ,
2241
2240
mut path : Vec < Segment > ,
2242
2241
parent_scope : & ParentScope < ' ra > ,
2243
2242
) -> Option < ( Vec < Segment > , Option < String > ) > {
2244
- debug ! ( "make_path_suggestion: span={:?} path={:?}" , span, path) ;
2245
-
2246
2243
match ( path. get ( 0 ) , path. get ( 1 ) ) {
2247
2244
// `{{root}}::ident::...` on both editions.
2248
2245
// On 2015 `{{root}}` is usually added implicitly.
@@ -2271,6 +2268,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
2271
2268
/// LL | use foo::Bar;
2272
2269
/// | ^^^ did you mean `self::foo`?
2273
2270
/// ```
2271
+ #[ instrument( skip( self , parent_scope) ) ]
2274
2272
fn make_missing_self_suggestion (
2275
2273
& mut self ,
2276
2274
mut path : Vec < Segment > ,
@@ -2279,7 +2277,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
2279
2277
// Replace first ident with `self` and check if that is valid.
2280
2278
path[ 0 ] . ident . name = kw:: SelfLower ;
2281
2279
let result = self . maybe_resolve_path ( & path, None , parent_scope, None ) ;
2282
- debug ! ( "make_missing_self_suggestion: path={:?} result={:?}" , path , result) ;
2280
+ debug ! ( ? result) ;
2283
2281
if let PathResult :: Module ( ..) = result { Some ( ( path, None ) ) } else { None }
2284
2282
}
2285
2283
@@ -2290,6 +2288,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
2290
2288
/// LL | use foo::Bar;
2291
2289
/// | ^^^ did you mean `crate::foo`?
2292
2290
/// ```
2291
+ #[ instrument( skip( self , parent_scope) ) ]
2293
2292
fn make_missing_crate_suggestion (
2294
2293
& mut self ,
2295
2294
mut path : Vec < Segment > ,
@@ -2298,7 +2297,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
2298
2297
// Replace first ident with `crate` and check if that is valid.
2299
2298
path[ 0 ] . ident . name = kw:: Crate ;
2300
2299
let result = self . maybe_resolve_path ( & path, None , parent_scope, None ) ;
2301
- debug ! ( "make_missing_crate_suggestion: path={:?} result={:?}" , path , result) ;
2300
+ debug ! ( ? result) ;
2302
2301
if let PathResult :: Module ( ..) = result {
2303
2302
Some ( (
2304
2303
path,
@@ -2321,6 +2320,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
2321
2320
/// LL | use foo::Bar;
2322
2321
/// | ^^^ did you mean `super::foo`?
2323
2322
/// ```
2323
+ #[ instrument( skip( self , parent_scope) ) ]
2324
2324
fn make_missing_super_suggestion (
2325
2325
& mut self ,
2326
2326
mut path : Vec < Segment > ,
@@ -2329,7 +2329,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
2329
2329
// Replace first ident with `crate` and check if that is valid.
2330
2330
path[ 0 ] . ident . name = kw:: Super ;
2331
2331
let result = self . maybe_resolve_path ( & path, None , parent_scope, None ) ;
2332
- debug ! ( "make_missing_super_suggestion: path={:?} result={:?}" , path , result) ;
2332
+ debug ! ( ? result) ;
2333
2333
if let PathResult :: Module ( ..) = result { Some ( ( path, None ) ) } else { None }
2334
2334
}
2335
2335
@@ -2343,6 +2343,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
2343
2343
///
2344
2344
/// Used when importing a submodule of an external crate but missing that crate's
2345
2345
/// name as the first part of path.
2346
+ #[ instrument( skip( self , parent_scope) ) ]
2346
2347
fn make_external_crate_suggestion (
2347
2348
& mut self ,
2348
2349
mut path : Vec < Segment > ,
@@ -2363,10 +2364,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
2363
2364
// Replace first ident with a crate name and check if that is valid.
2364
2365
path[ 0 ] . ident . name = name;
2365
2366
let result = self . maybe_resolve_path ( & path, None , parent_scope, None ) ;
2366
- debug ! (
2367
- "make_external_crate_suggestion: name={:?} path={:?} result={:?}" ,
2368
- name, path, result
2369
- ) ;
2367
+ debug ! ( ?name, ?result) ;
2370
2368
if let PathResult :: Module ( ..) = result {
2371
2369
return Some ( ( path, None ) ) ;
2372
2370
}
@@ -2433,10 +2431,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
2433
2431
import. span ,
2434
2432
import. use_span ,
2435
2433
) ;
2436
- debug ! (
2437
- "check_for_module_export_macro: found_closing_brace={:?} binding_span={:?}" ,
2438
- found_closing_brace, binding_span
2439
- ) ;
2434
+ debug ! ( found_closing_brace, ?binding_span) ;
2440
2435
2441
2436
let mut removal_span = binding_span;
2442
2437
if found_closing_brace {
@@ -2450,11 +2445,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
2450
2445
if let Some ( previous_span) =
2451
2446
extend_span_to_previous_binding ( self . tcx . sess , binding_span)
2452
2447
{
2453
- debug ! ( "check_for_module_export_macro: previous_span={:?}" , previous_span) ;
2448
+ debug ! ( ? previous_span) ;
2454
2449
removal_span = removal_span. with_lo ( previous_span. lo ( ) ) ;
2455
2450
}
2456
2451
}
2457
- debug ! ( "check_for_module_export_macro: removal_span={:?}" , removal_span) ;
2452
+ debug ! ( ? removal_span) ;
2458
2453
2459
2454
// Remove the `removal_span`.
2460
2455
corrections. push ( ( removal_span, "" . to_string ( ) ) ) ;
@@ -2465,15 +2460,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
2465
2460
// ^^^^^^^^^
2466
2461
// or `use a::{b, c, d}};`
2467
2462
// ^^^^^^^^^^^
2468
- let ( has_nested, after_crate_name) = find_span_immediately_after_crate_name (
2469
- self . tcx . sess ,
2470
- module_name,
2471
- import. use_span ,
2472
- ) ;
2473
- debug ! (
2474
- "check_for_module_export_macro: has_nested={:?} after_crate_name={:?}" ,
2475
- has_nested, after_crate_name
2476
- ) ;
2463
+ let ( has_nested, after_crate_name) =
2464
+ find_span_immediately_after_crate_name ( self . tcx . sess , import. use_span ) ;
2465
+ debug ! ( has_nested, ?after_crate_name) ;
2477
2466
2478
2467
let source_map = self . tcx . sess . source_map ( ) ;
2479
2468
@@ -2677,15 +2666,7 @@ fn extend_span_to_previous_binding(sess: &Session, binding_span: Span) -> Option
2677
2666
/// use foo::{a, b::{c, d}};
2678
2667
/// // ^^^^^^^^^^^^^^^ -- true
2679
2668
/// ```
2680
- fn find_span_immediately_after_crate_name (
2681
- sess : & Session ,
2682
- module_name : Symbol ,
2683
- use_span : Span ,
2684
- ) -> ( bool , Span ) {
2685
- debug ! (
2686
- "find_span_immediately_after_crate_name: module_name={:?} use_span={:?}" ,
2687
- module_name, use_span
2688
- ) ;
2669
+ fn find_span_immediately_after_crate_name ( sess : & Session , use_span : Span ) -> ( bool , Span ) {
2689
2670
let source_map = sess. source_map ( ) ;
2690
2671
2691
2672
// Using `use issue_59764::foo::{baz, makro};` as an example throughout..
0 commit comments