@@ -3,7 +3,7 @@ use std::sync::Arc;
3
3
use rustc_ast:: { self as ast, * } ;
4
4
use rustc_hir:: def:: { DefKind , PartialRes , PerNS , Res } ;
5
5
use rustc_hir:: def_id:: DefId ;
6
- use rustc_hir:: { self as hir, GenericArg } ;
6
+ use rustc_hir:: { self as hir, GenericArg , PathFlags } ;
7
7
use rustc_middle:: { span_bug, ty} ;
8
8
use rustc_session:: parse:: add_feature_diagnostics;
9
9
use rustc_span:: { BytePos , DUMMY_SP , DesugaringKind , Ident , Span , Symbol , sym} ;
@@ -135,6 +135,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
135
135
generic_args_mode,
136
136
itctx ( i) ,
137
137
bound_modifier_allowed_features. clone ( ) ,
138
+ PathFlags :: empty ( ) ,
138
139
)
139
140
} ,
140
141
) ) ,
@@ -160,16 +161,23 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
160
161
}
161
162
162
163
// 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 ( ) {
164
165
// If the base path is empty that means there exists a
165
166
// syntactical `Self`, e.g., `&i32` in `<&i32>::clone`.
166
- qself. expect ( "missing QSelf for <T>::..." )
167
+ ( qself. expect ( "missing QSelf for <T>::..." ) , PathFlags :: empty ( ) )
167
168
} else {
168
169
// Otherwise, the base path is an implicit `Self` type path,
169
170
// e.g., `Vec` in `Vec::new` or `<I as Iterator>::Item` in
170
171
// `<I as Iterator>::Item::default`.
171
172
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
+ )
173
181
} ;
174
182
175
183
// Anything after the base path are associated "extensions",
@@ -199,6 +207,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
199
207
generic_args_mode,
200
208
itctx ( i) ,
201
209
None ,
210
+ flags,
202
211
) ) ;
203
212
let qpath = hir:: QPath :: TypeRelative ( ty, hir_segment) ;
204
213
@@ -241,6 +250,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
241
250
GenericArgsMode :: Err ,
242
251
ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
243
252
None ,
253
+ PathFlags :: empty ( ) ,
244
254
)
245
255
} ) ) ,
246
256
span : self . lower_span ( p. span ) ,
@@ -258,6 +268,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
258
268
// This is passed down to the implicit associated type binding in
259
269
// parenthesized bounds.
260
270
bound_modifier_allowed_features : Option < Arc < [ Symbol ] > > ,
271
+ mut flags : PathFlags ,
261
272
) -> hir:: PathSegment < ' hir > {
262
273
debug ! ( "path_span: {:?}, lower_path_segment(segment: {:?})" , path_span, segment) ;
263
274
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> {
400
411
segment. ident, segment. id, hir_id,
401
412
) ;
402
413
414
+ flags. set ( PathFlags :: INFER_ARGS , infer_args) ;
415
+
403
416
hir:: PathSegment {
404
417
ident : self . lower_ident ( segment. ident ) ,
405
418
hir_id,
406
419
res : self . lower_res ( res) ,
407
- infer_args ,
420
+ flags ,
408
421
args : if generic_args. is_empty ( ) && generic_args. span . is_empty ( ) {
409
422
None
410
423
} else {
0 commit comments