@@ -578,7 +578,7 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
578578 . resolve_ident_in_lexical_scope (
579579 self_ty,
580580 TypeNS ,
581- Finalize :: SimplePath ( ty. id , ty. span ) ,
581+ Some ( Finalize :: new ( ty. id , ty. span ) ) ,
582582 None ,
583583 )
584584 . map_or ( Res :: Err , |d| d. res ( ) ) ;
@@ -958,7 +958,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
958958 ident,
959959 ns,
960960 & self . parent_scope ,
961- Finalize :: No ,
961+ None ,
962962 & self . ribs [ ns] ,
963963 None ,
964964 )
@@ -968,7 +968,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
968968 & mut self ,
969969 ident : Ident ,
970970 ns : Namespace ,
971- finalize : Finalize ,
971+ finalize : Option < Finalize > ,
972972 unusable_binding : Option < & ' a NameBinding < ' a > > ,
973973 ) -> Option < LexicalScopeBinding < ' a > > {
974974 self . r . resolve_ident_in_lexical_scope (
@@ -985,7 +985,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
985985 & mut self ,
986986 path : & [ Segment ] ,
987987 opt_ns : Option < Namespace > , // `None` indicates a module path in import
988- finalize : Finalize ,
988+ finalize : Option < Finalize > ,
989989 ) -> PathResult < ' a > {
990990 self . r . resolve_path_with_ribs (
991991 path,
@@ -1299,11 +1299,8 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
12991299 partial_res : PartialRes ,
13001300 path : & [ Segment ] ,
13011301 source : PathSource < ' _ > ,
1302- finalize : Finalize ,
1302+ path_span : Span ,
13031303 ) {
1304- let Some ( path_span) = finalize. path_span ( ) else {
1305- return ;
1306- } ;
13071304 let proj_start = path. len ( ) - partial_res. unresolved_segments ( ) ;
13081305 for ( i, segment) in path. iter ( ) . enumerate ( ) {
13091306 if segment. has_lifetime_args {
@@ -1576,8 +1573,8 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
15761573 report_error ( self , ns) ;
15771574 }
15781575 Some ( LexicalScopeBinding :: Item ( binding) ) => {
1579- if let Some ( LexicalScopeBinding :: Res ( ..) ) = self
1580- . resolve_ident_in_lexical_scope ( ident, ns, Finalize :: No , Some ( binding) )
1576+ if let Some ( LexicalScopeBinding :: Res ( ..) ) =
1577+ self . resolve_ident_in_lexical_scope ( ident, ns, None , Some ( binding) )
15811578 {
15821579 report_error ( self , ns) ;
15831580 }
@@ -1979,7 +1976,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
19791976 None ,
19801977 & path,
19811978 PathSource :: Trait ( AliasPossibility :: No ) ,
1982- Finalize :: SimplePath ( trait_ref. ref_id , trait_ref. path . span ) ,
1979+ Finalize :: new ( trait_ref. ref_id , trait_ref. path . span ) ,
19831980 ) ;
19841981 if let Some ( def_id) = res. base_res ( ) . opt_def_id ( ) {
19851982 new_id = Some ( def_id) ;
@@ -2653,7 +2650,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
26532650 qself,
26542651 & Segment :: from_path ( path) ,
26552652 source,
2656- Finalize :: SimplePath ( id, path. span ) ,
2653+ Finalize :: new ( id, path. span ) ,
26572654 ) ;
26582655 }
26592656
@@ -2672,8 +2669,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
26722669 ) ;
26732670 let ns = source. namespace ( ) ;
26742671
2675- let ( id, path_span) =
2676- finalize. node_id_and_path_span ( ) . expect ( "unexpected speculative resolution" ) ;
2672+ let Finalize { node_id, path_span, .. } = finalize;
26772673 let report_errors = |this : & mut Self , res : Option < Res > | {
26782674 if this. should_report_errs ( ) {
26792675 let ( err, candidates) =
@@ -2787,7 +2783,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
27872783 if ns == ValueNS {
27882784 let item_name = path. last ( ) . unwrap ( ) . ident ;
27892785 let traits = self . traits_in_scope ( item_name, ns) ;
2790- self . r . trait_map . insert ( id , traits) ;
2786+ self . r . trait_map . insert ( node_id , traits) ;
27912787 }
27922788
27932789 if PrimTy :: from_name ( path[ 0 ] . ident . name ) . is_some ( ) {
@@ -2796,7 +2792,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
27962792 std_path. push ( Segment :: from_ident ( Ident :: with_dummy_span ( sym:: std) ) ) ;
27972793 std_path. extend ( path) ;
27982794 if let PathResult :: Module ( _) | PathResult :: NonModule ( _) =
2799- self . resolve_path ( & std_path, Some ( ns) , Finalize :: No )
2795+ self . resolve_path ( & std_path, Some ( ns) , None )
28002796 {
28012797 // Check if we wrote `str::from_utf8` instead of `std::str::from_utf8`
28022798 let item_span =
@@ -2823,8 +2819,8 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
28232819
28242820 if !matches ! ( source, PathSource :: TraitItem ( ..) ) {
28252821 // Avoid recording definition of `A::B` in `<T as A>::B::C`.
2826- self . r . record_partial_res ( id , partial_res) ;
2827- self . resolve_elided_lifetimes_in_path ( id , partial_res, path, source, finalize ) ;
2822+ self . r . record_partial_res ( node_id , partial_res) ;
2823+ self . resolve_elided_lifetimes_in_path ( node_id , partial_res, path, source, path_span ) ;
28282824 }
28292825
28302826 partial_res
@@ -2932,21 +2928,12 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
29322928 // the trait (the slice upto and including
29332929 // `qself.position`). And then we recursively resolve that,
29342930 // but with `qself` set to `None`.
2935- //
2936- // However, setting `qself` to none (but not changing the
2937- // span) loses the information about where this path
2938- // *actually* appears, so for the purposes of the crate
2939- // lint we pass along information that this is the trait
2940- // name from a fully qualified path, and this also
2941- // contains the full span (the `Finalize::QPathTrait`).
29422931 let ns = if qself. position + 1 == path. len ( ) { ns } else { TypeNS } ;
29432932 let partial_res = self . smart_resolve_path_fragment (
29442933 None ,
29452934 & path[ ..=qself. position ] ,
29462935 PathSource :: TraitItem ( ns) ,
2947- finalize. node_id_and_path_span ( ) . map_or ( Finalize :: No , |( qpath_id, path_span) | {
2948- Finalize :: QPathTrait { qpath_id, qpath_span : qself. path_span , path_span }
2949- } ) ,
2936+ Finalize :: with_root_span ( finalize. node_id , finalize. path_span , qself. path_span ) ,
29502937 ) ;
29512938
29522939 // The remaining segments (the `C` in our example) will
@@ -2958,7 +2945,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
29582945 ) ) ) ;
29592946 }
29602947
2961- let result = match self . resolve_path ( & path, Some ( ns) , finalize) {
2948+ let result = match self . resolve_path ( & path, Some ( ns) , Some ( finalize) ) {
29622949 PathResult :: NonModule ( path_res) => path_res,
29632950 PathResult :: Module ( ModuleOrUniformRoot :: Module ( module) ) if !module. is_normal ( ) => {
29642951 PartialRes :: new ( module. res ( ) . unwrap ( ) )
@@ -2996,10 +2983,9 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
29962983 && result. base_res ( ) != Res :: Err
29972984 && path[ 0 ] . ident . name != kw:: PathRoot
29982985 && path[ 0 ] . ident . name != kw:: DollarCrate
2999- && let Some ( ( id, path_span) ) = finalize. node_id_and_path_span ( )
30002986 {
30012987 let unqualified_result = {
3002- match self . resolve_path ( & [ * path. last ( ) . unwrap ( ) ] , Some ( ns) , Finalize :: No ) {
2988+ match self . resolve_path ( & [ * path. last ( ) . unwrap ( ) ] , Some ( ns) , None ) {
30032989 PathResult :: NonModule ( path_res) => path_res. base_res ( ) ,
30042990 PathResult :: Module ( ModuleOrUniformRoot :: Module ( module) ) => {
30052991 module. res ( ) . unwrap ( )
@@ -3009,7 +2995,12 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
30092995 } ;
30102996 if result. base_res ( ) == unqualified_result {
30112997 let lint = lint:: builtin:: UNUSED_QUALIFICATIONS ;
3012- self . r . lint_buffer . buffer_lint ( lint, id, path_span, "unnecessary qualification" )
2998+ self . r . lint_buffer . buffer_lint (
2999+ lint,
3000+ finalize. node_id ,
3001+ finalize. path_span ,
3002+ "unnecessary qualification" ,
3003+ )
30133004 }
30143005 }
30153006
0 commit comments