@@ -578,7 +578,7 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
578
578
. resolve_ident_in_lexical_scope (
579
579
self_ty,
580
580
TypeNS ,
581
- Finalize :: SimplePath ( ty. id , ty. span ) ,
581
+ Some ( Finalize :: new ( ty. id , ty. span ) ) ,
582
582
None ,
583
583
)
584
584
. map_or ( Res :: Err , |d| d. res ( ) ) ;
@@ -958,7 +958,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
958
958
ident,
959
959
ns,
960
960
& self . parent_scope ,
961
- Finalize :: No ,
961
+ None ,
962
962
& self . ribs [ ns] ,
963
963
None ,
964
964
)
@@ -968,7 +968,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
968
968
& mut self ,
969
969
ident : Ident ,
970
970
ns : Namespace ,
971
- finalize : Finalize ,
971
+ finalize : Option < Finalize > ,
972
972
unusable_binding : Option < & ' a NameBinding < ' a > > ,
973
973
) -> Option < LexicalScopeBinding < ' a > > {
974
974
self . r . resolve_ident_in_lexical_scope (
@@ -985,7 +985,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
985
985
& mut self ,
986
986
path : & [ Segment ] ,
987
987
opt_ns : Option < Namespace > , // `None` indicates a module path in import
988
- finalize : Finalize ,
988
+ finalize : Option < Finalize > ,
989
989
) -> PathResult < ' a > {
990
990
self . r . resolve_path_with_ribs (
991
991
path,
@@ -1299,11 +1299,8 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1299
1299
partial_res : PartialRes ,
1300
1300
path : & [ Segment ] ,
1301
1301
source : PathSource < ' _ > ,
1302
- finalize : Finalize ,
1302
+ path_span : Span ,
1303
1303
) {
1304
- let Some ( path_span) = finalize. path_span ( ) else {
1305
- return ;
1306
- } ;
1307
1304
let proj_start = path. len ( ) - partial_res. unresolved_segments ( ) ;
1308
1305
for ( i, segment) in path. iter ( ) . enumerate ( ) {
1309
1306
if segment. has_lifetime_args {
@@ -1576,8 +1573,8 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1576
1573
report_error ( self , ns) ;
1577
1574
}
1578
1575
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) )
1581
1578
{
1582
1579
report_error ( self , ns) ;
1583
1580
}
@@ -1979,7 +1976,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1979
1976
None ,
1980
1977
& path,
1981
1978
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 ) ,
1983
1980
) ;
1984
1981
if let Some ( def_id) = res. base_res ( ) . opt_def_id ( ) {
1985
1982
new_id = Some ( def_id) ;
@@ -2653,7 +2650,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
2653
2650
qself,
2654
2651
& Segment :: from_path ( path) ,
2655
2652
source,
2656
- Finalize :: SimplePath ( id, path. span ) ,
2653
+ Finalize :: new ( id, path. span ) ,
2657
2654
) ;
2658
2655
}
2659
2656
@@ -2672,8 +2669,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
2672
2669
) ;
2673
2670
let ns = source. namespace ( ) ;
2674
2671
2675
- let ( id, path_span) =
2676
- finalize. node_id_and_path_span ( ) . expect ( "unexpected speculative resolution" ) ;
2672
+ let Finalize { node_id, path_span, .. } = finalize;
2677
2673
let report_errors = |this : & mut Self , res : Option < Res > | {
2678
2674
if this. should_report_errs ( ) {
2679
2675
let ( err, candidates) =
@@ -2787,7 +2783,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
2787
2783
if ns == ValueNS {
2788
2784
let item_name = path. last ( ) . unwrap ( ) . ident ;
2789
2785
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) ;
2791
2787
}
2792
2788
2793
2789
if PrimTy :: from_name ( path[ 0 ] . ident . name ) . is_some ( ) {
@@ -2796,7 +2792,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
2796
2792
std_path. push ( Segment :: from_ident ( Ident :: with_dummy_span ( sym:: std) ) ) ;
2797
2793
std_path. extend ( path) ;
2798
2794
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 )
2800
2796
{
2801
2797
// Check if we wrote `str::from_utf8` instead of `std::str::from_utf8`
2802
2798
let item_span =
@@ -2823,8 +2819,8 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
2823
2819
2824
2820
if !matches ! ( source, PathSource :: TraitItem ( ..) ) {
2825
2821
// 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 ) ;
2828
2824
}
2829
2825
2830
2826
partial_res
@@ -2932,21 +2928,12 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
2932
2928
// the trait (the slice upto and including
2933
2929
// `qself.position`). And then we recursively resolve that,
2934
2930
// 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`).
2942
2931
let ns = if qself. position + 1 == path. len ( ) { ns } else { TypeNS } ;
2943
2932
let partial_res = self . smart_resolve_path_fragment (
2944
2933
None ,
2945
2934
& path[ ..=qself. position ] ,
2946
2935
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 ) ,
2950
2937
) ;
2951
2938
2952
2939
// The remaining segments (the `C` in our example) will
@@ -2958,7 +2945,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
2958
2945
) ) ) ;
2959
2946
}
2960
2947
2961
- let result = match self . resolve_path ( & path, Some ( ns) , finalize) {
2948
+ let result = match self . resolve_path ( & path, Some ( ns) , Some ( finalize) ) {
2962
2949
PathResult :: NonModule ( path_res) => path_res,
2963
2950
PathResult :: Module ( ModuleOrUniformRoot :: Module ( module) ) if !module. is_normal ( ) => {
2964
2951
PartialRes :: new ( module. res ( ) . unwrap ( ) )
@@ -2996,10 +2983,9 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
2996
2983
&& result. base_res ( ) != Res :: Err
2997
2984
&& path[ 0 ] . ident . name != kw:: PathRoot
2998
2985
&& path[ 0 ] . ident . name != kw:: DollarCrate
2999
- && let Some ( ( id, path_span) ) = finalize. node_id_and_path_span ( )
3000
2986
{
3001
2987
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 ) {
3003
2989
PathResult :: NonModule ( path_res) => path_res. base_res ( ) ,
3004
2990
PathResult :: Module ( ModuleOrUniformRoot :: Module ( module) ) => {
3005
2991
module. res ( ) . unwrap ( )
@@ -3009,7 +2995,12 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
3009
2995
} ;
3010
2996
if result. base_res ( ) == unqualified_result {
3011
2997
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
+ )
3013
3004
}
3014
3005
}
3015
3006
0 commit comments