@@ -30,7 +30,7 @@ use rustc_span::hygiene::MacroKind;
3030use rustc_span:: source_map:: SourceMap ;
3131use rustc_span:: { BytePos , Ident , Span , Symbol , SyntaxContext , kw, sym} ;
3232use thin_vec:: { ThinVec , thin_vec} ;
33- use tracing:: debug;
33+ use tracing:: { debug, instrument } ;
3434
3535use crate :: errors:: {
3636 self , AddedMacroUse , ChangeImportBinding , ChangeImportBindingSuggestion , ConsiderAddingADerive ,
@@ -2237,12 +2237,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
22372237 /// Adds suggestions for a path that cannot be resolved.
22382238 pub ( crate ) fn make_path_suggestion (
22392239 & mut self ,
2240- span : Span ,
22412240 mut path : Vec < Segment > ,
22422241 parent_scope : & ParentScope < ' ra > ,
22432242 ) -> Option < ( Vec < Segment > , Option < String > ) > {
2244- debug ! ( "make_path_suggestion: span={:?} path={:?}" , span, path) ;
2245-
22462243 match ( path. get ( 0 ) , path. get ( 1 ) ) {
22472244 // `{{root}}::ident::...` on both editions.
22482245 // On 2015 `{{root}}` is usually added implicitly.
@@ -2271,6 +2268,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
22712268 /// LL | use foo::Bar;
22722269 /// | ^^^ did you mean `self::foo`?
22732270 /// ```
2271+ #[ instrument( skip( self , parent_scope) ) ]
22742272 fn make_missing_self_suggestion (
22752273 & mut self ,
22762274 mut path : Vec < Segment > ,
@@ -2279,7 +2277,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
22792277 // Replace first ident with `self` and check if that is valid.
22802278 path[ 0 ] . ident . name = kw:: SelfLower ;
22812279 let result = self . maybe_resolve_path ( & path, None , parent_scope, None ) ;
2282- debug ! ( "make_missing_self_suggestion: path={:?} result={:?}" , path , result) ;
2280+ debug ! ( ? result) ;
22832281 if let PathResult :: Module ( ..) = result { Some ( ( path, None ) ) } else { None }
22842282 }
22852283
@@ -2290,6 +2288,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
22902288 /// LL | use foo::Bar;
22912289 /// | ^^^ did you mean `crate::foo`?
22922290 /// ```
2291+ #[ instrument( skip( self , parent_scope) ) ]
22932292 fn make_missing_crate_suggestion (
22942293 & mut self ,
22952294 mut path : Vec < Segment > ,
@@ -2298,7 +2297,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
22982297 // Replace first ident with `crate` and check if that is valid.
22992298 path[ 0 ] . ident . name = kw:: Crate ;
23002299 let result = self . maybe_resolve_path ( & path, None , parent_scope, None ) ;
2301- debug ! ( "make_missing_crate_suggestion: path={:?} result={:?}" , path , result) ;
2300+ debug ! ( ? result) ;
23022301 if let PathResult :: Module ( ..) = result {
23032302 Some ( (
23042303 path,
@@ -2321,6 +2320,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
23212320 /// LL | use foo::Bar;
23222321 /// | ^^^ did you mean `super::foo`?
23232322 /// ```
2323+ #[ instrument( skip( self , parent_scope) ) ]
23242324 fn make_missing_super_suggestion (
23252325 & mut self ,
23262326 mut path : Vec < Segment > ,
@@ -2329,7 +2329,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
23292329 // Replace first ident with `crate` and check if that is valid.
23302330 path[ 0 ] . ident . name = kw:: Super ;
23312331 let result = self . maybe_resolve_path ( & path, None , parent_scope, None ) ;
2332- debug ! ( "make_missing_super_suggestion: path={:?} result={:?}" , path , result) ;
2332+ debug ! ( ? result) ;
23332333 if let PathResult :: Module ( ..) = result { Some ( ( path, None ) ) } else { None }
23342334 }
23352335
@@ -2343,6 +2343,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
23432343 ///
23442344 /// Used when importing a submodule of an external crate but missing that crate's
23452345 /// name as the first part of path.
2346+ #[ instrument( skip( self , parent_scope) ) ]
23462347 fn make_external_crate_suggestion (
23472348 & mut self ,
23482349 mut path : Vec < Segment > ,
@@ -2363,10 +2364,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
23632364 // Replace first ident with a crate name and check if that is valid.
23642365 path[ 0 ] . ident . name = name;
23652366 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) ;
23702368 if let PathResult :: Module ( ..) = result {
23712369 return Some ( ( path, None ) ) ;
23722370 }
@@ -2433,10 +2431,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
24332431 import. span ,
24342432 import. use_span ,
24352433 ) ;
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) ;
24402435
24412436 let mut removal_span = binding_span;
24422437 if found_closing_brace {
@@ -2450,11 +2445,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
24502445 if let Some ( previous_span) =
24512446 extend_span_to_previous_binding ( self . tcx . sess , binding_span)
24522447 {
2453- debug ! ( "check_for_module_export_macro: previous_span={:?}" , previous_span) ;
2448+ debug ! ( ? previous_span) ;
24542449 removal_span = removal_span. with_lo ( previous_span. lo ( ) ) ;
24552450 }
24562451 }
2457- debug ! ( "check_for_module_export_macro: removal_span={:?}" , removal_span) ;
2452+ debug ! ( ? removal_span) ;
24582453
24592454 // Remove the `removal_span`.
24602455 corrections. push ( ( removal_span, "" . to_string ( ) ) ) ;
@@ -2465,15 +2460,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
24652460 // ^^^^^^^^^
24662461 // or `use a::{b, c, d}};`
24672462 // ^^^^^^^^^^^
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) ;
24772466
24782467 let source_map = self . tcx . sess . source_map ( ) ;
24792468
@@ -2677,15 +2666,7 @@ fn extend_span_to_previous_binding(sess: &Session, binding_span: Span) -> Option
26772666/// use foo::{a, b::{c, d}};
26782667/// // ^^^^^^^^^^^^^^^ -- true
26792668/// ```
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 ) {
26892670 let source_map = sess. source_map ( ) ;
26902671
26912672 // Using `use issue_59764::foo::{baz, makro};` as an example throughout..
0 commit comments