@@ -30,6 +30,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
30
30
let partial_res =
31
31
self . resolver . get_partial_res ( id) . unwrap_or_else ( || PartialRes :: new ( Res :: Err ) ) ;
32
32
33
+ let path_span_lo = p. span . shrink_to_lo ( ) ;
33
34
let proj_start = p. segments . len ( ) - partial_res. unresolved_segments ( ) ;
34
35
let path = self . arena . alloc ( hir:: Path {
35
36
res : self . lower_res ( partial_res. base_res ( ) ) ,
@@ -108,7 +109,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
108
109
)
109
110
} ,
110
111
) ) ,
111
- span : p. span ,
112
+ span : p. segments [ ..proj_start]
113
+ . last ( )
114
+ . map_or ( path_span_lo, |segment| path_span_lo. to ( segment. span ( ) ) ) ,
112
115
} ) ;
113
116
114
117
// Simple case, either no projections, or only fully-qualified.
@@ -127,7 +130,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
127
130
// e.g., `Vec` in `Vec::new` or `<I as Iterator>::Item` in
128
131
// `<I as Iterator>::Item::default`.
129
132
let new_id = self . next_id ( ) ;
130
- self . arena . alloc ( self . ty_path ( new_id, p . span , hir:: QPath :: Resolved ( qself, path) ) )
133
+ self . arena . alloc ( self . ty_path ( new_id, path . span , hir:: QPath :: Resolved ( qself, path) ) )
131
134
} ;
132
135
133
136
// Anything after the base path are associated "extensions",
@@ -141,7 +144,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
141
144
// 3. `<<std::vec::Vec<T>>::IntoIter>::Item`
142
145
// * final path is `<<<std::vec::Vec<T>>::IntoIter>::Item>::clone`
143
146
for ( i, segment) in p. segments . iter ( ) . enumerate ( ) . skip ( proj_start) {
144
- let segment = self . arena . alloc ( self . lower_path_segment (
147
+ let hir_segment = self . arena . alloc ( self . lower_path_segment (
145
148
p. span ,
146
149
segment,
147
150
param_mode,
@@ -150,7 +153,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
150
153
itctx. reborrow ( ) ,
151
154
None ,
152
155
) ) ;
153
- let qpath = hir:: QPath :: TypeRelative ( ty, segment ) ;
156
+ let qpath = hir:: QPath :: TypeRelative ( ty, hir_segment ) ;
154
157
155
158
// It's finished, return the extension of the right node type.
156
159
if i == p. segments . len ( ) - 1 {
@@ -159,7 +162,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
159
162
160
163
// Wrap the associated extension in another type node.
161
164
let new_id = self . next_id ( ) ;
162
- ty = self . arena . alloc ( self . ty_path ( new_id, p . span , qpath) ) ;
165
+ ty = self . arena . alloc ( self . ty_path ( new_id, path_span_lo . to ( segment . span ( ) ) , qpath) ) ;
163
166
}
164
167
165
168
// We should've returned in the for loop above.
0 commit comments