@@ -30,6 +30,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
3030        let  partial_res =
3131            self . resolver . get_partial_res ( id) . unwrap_or_else ( || PartialRes :: new ( Res :: Err ) ) ; 
3232
33+         let  path_span_lo = p. span . shrink_to_lo ( ) ; 
3334        let  proj_start = p. segments . len ( )  - partial_res. unresolved_segments ( ) ; 
3435        let  path = self . arena . alloc ( hir:: Path  { 
3536            res :  self . lower_res ( partial_res. base_res ( ) ) , 
@@ -108,7 +109,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
108109                    ) 
109110                } , 
110111            ) ) , 
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 ( ) ) ) , 
112115        } ) ; 
113116
114117        // Simple case, either no projections, or only fully-qualified. 
@@ -127,7 +130,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
127130            // e.g., `Vec` in `Vec::new` or `<I as Iterator>::Item` in 
128131            // `<I as Iterator>::Item::default`. 
129132            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) ) ) 
131134        } ; 
132135
133136        // Anything after the base path are associated "extensions", 
@@ -141,7 +144,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
141144        //   3. `<<std::vec::Vec<T>>::IntoIter>::Item` 
142145        // * final path is `<<<std::vec::Vec<T>>::IntoIter>::Item>::clone` 
143146        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 ( 
145148                p. span , 
146149                segment, 
147150                param_mode, 
@@ -150,7 +153,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
150153                itctx. reborrow ( ) , 
151154                None , 
152155            ) ) ; 
153-             let  qpath = hir:: QPath :: TypeRelative ( ty,  segment ) ; 
156+             let  qpath = hir:: QPath :: TypeRelative ( ty,  hir_segment ) ; 
154157
155158            // It's finished, return the extension of the right node type. 
156159            if  i == p. segments . len ( )  - 1  { 
@@ -159,7 +162,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
159162
160163            // Wrap the associated extension in another type node. 
161164            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) ) ; 
163166        } 
164167
165168        // We should've returned in the for loop above. 
0 commit comments