@@ -3,7 +3,7 @@ use std::sync::Arc;
33use rustc_ast:: { self as ast, * } ;
44use rustc_hir:: def:: { DefKind , PartialRes , PerNS , Res } ;
55use rustc_hir:: def_id:: DefId ;
6- use rustc_hir:: { self as hir, GenericArg } ;
6+ use rustc_hir:: { self as hir, GenericArg , PathFlags } ;
77use rustc_middle:: { span_bug, ty} ;
88use rustc_session:: parse:: add_feature_diagnostics;
99use rustc_span:: { BytePos , DUMMY_SP , DesugaringKind , Ident , Span , Symbol , sym} ;
@@ -135,6 +135,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
135135 generic_args_mode,
136136 itctx ( i) ,
137137 bound_modifier_allowed_features. clone ( ) ,
138+ PathFlags :: empty ( ) ,
138139 )
139140 } ,
140141 ) ) ,
@@ -160,16 +161,23 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
160161 }
161162
162163 // Create the innermost type that we're projecting from.
163- let mut ty = if path. segments . is_empty ( ) {
164+ let ( mut ty, flags ) = if path. segments . is_empty ( ) {
164165 // If the base path is empty that means there exists a
165166 // syntactical `Self`, e.g., `&i32` in `<&i32>::clone`.
166- qself. expect ( "missing QSelf for <T>::..." )
167+ ( qself. expect ( "missing QSelf for <T>::..." ) , PathFlags :: empty ( ) )
167168 } else {
168169 // Otherwise, the base path is an implicit `Self` type path,
169170 // e.g., `Vec` in `Vec::new` or `<I as Iterator>::Item` in
170171 // `<I as Iterator>::Item::default`.
171172 let new_id = self . next_id ( ) ;
172- self . arena . alloc ( self . ty_path ( new_id, path. span , hir:: QPath :: Resolved ( qself, path) ) )
173+ (
174+ & * self . arena . alloc ( self . ty_path (
175+ new_id,
176+ path. span ,
177+ hir:: QPath :: Resolved ( qself, path) ,
178+ ) ) ,
179+ PathFlags :: IMPLICIT_SELF ,
180+ )
173181 } ;
174182
175183 // Anything after the base path are associated "extensions",
@@ -199,6 +207,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
199207 generic_args_mode,
200208 itctx ( i) ,
201209 None ,
210+ flags,
202211 ) ) ;
203212 let qpath = hir:: QPath :: TypeRelative ( ty, hir_segment) ;
204213
@@ -241,6 +250,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
241250 GenericArgsMode :: Err ,
242251 ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
243252 None ,
253+ PathFlags :: empty ( ) ,
244254 )
245255 } ) ) ,
246256 span : self . lower_span ( p. span ) ,
@@ -258,6 +268,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
258268 // This is passed down to the implicit associated type binding in
259269 // parenthesized bounds.
260270 bound_modifier_allowed_features : Option < Arc < [ Symbol ] > > ,
271+ mut flags : PathFlags ,
261272 ) -> hir:: PathSegment < ' hir > {
262273 debug ! ( "path_span: {:?}, lower_path_segment(segment: {:?})" , path_span, segment) ;
263274 let ( mut generic_args, infer_args) = if let Some ( generic_args) = segment. args . as_deref ( ) {
@@ -400,11 +411,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
400411 segment. ident, segment. id, hir_id,
401412 ) ;
402413
414+ flags. set ( PathFlags :: INFER_ARGS , infer_args) ;
415+
403416 hir:: PathSegment {
404417 ident : self . lower_ident ( segment. ident ) ,
405418 hir_id,
406419 res : self . lower_res ( res) ,
407- infer_args ,
420+ flags ,
408421 args : if generic_args. is_empty ( ) && generic_args. span . is_empty ( ) {
409422 None
410423 } else {
0 commit comments