File tree Expand file tree Collapse file tree 2 files changed +50
-18
lines changed Expand file tree Collapse file tree 2 files changed +50
-18
lines changed Original file line number Diff line number Diff line change @@ -377,26 +377,25 @@ impl<'a> TyLoweringContext<'a> {
377
377
// Count the number of `impl Trait` things that appear within our bounds.
378
378
// Since t hose have been emitted as implicit type args already.
379
379
counter. set ( idx + count_impl_traits ( type_ref) as u16 ) ;
380
- let (
381
- _parent_params,
382
- self_param,
383
- type_params,
384
- const_params,
385
- _impl_trait_params,
386
- lifetime_params,
387
- ) = self
380
+ let kind = self
388
381
. generics ( )
389
382
. expect ( "variable impl trait lowering must be in a generic def" )
390
- . provenance_split ( ) ;
391
- TyKind :: BoundVar ( BoundVar :: new (
392
- self . in_binders ,
393
- idx as usize
394
- + self_param as usize
395
- + type_params
396
- + const_params
397
- + lifetime_params,
398
- ) )
399
- . intern ( Interner )
383
+ . iter ( )
384
+ . enumerate ( )
385
+ . filter_map ( |( i, ( id, data) ) | match ( id, data) {
386
+ (
387
+ GenericParamId :: TypeParamId ( _) ,
388
+ GenericParamDataRef :: TypeParamData ( data) ,
389
+ ) if data. provenance == TypeParamProvenance :: ArgumentImplTrait => {
390
+ Some ( i)
391
+ }
392
+ _ => None ,
393
+ } )
394
+ . nth ( idx as usize )
395
+ . map_or ( TyKind :: Error , |id| {
396
+ TyKind :: BoundVar ( BoundVar { debruijn : self . in_binders , index : id } )
397
+ } ) ;
398
+ kind. intern ( Interner )
400
399
}
401
400
ImplTraitLoweringState :: Disallowed => {
402
401
// FIXME: report error
Original file line number Diff line number Diff line change @@ -2162,3 +2162,36 @@ fn main() {
2162
2162
"# ] ] ,
2163
2163
) ;
2164
2164
}
2165
+
2166
+ #[ test]
2167
+ fn issue_17711 ( ) {
2168
+ check_infer (
2169
+ r#"
2170
+ //- minicore: deref
2171
+ use core::ops::Deref;
2172
+
2173
+ struct Struct<'a, T>(&'a T);
2174
+
2175
+ trait Trait {}
2176
+
2177
+ impl<'a, T: Deref<Target = impl Trait>> Struct<'a, T> {
2178
+ fn foo(&self) -> &Self { self }
2179
+
2180
+ fn bar(&self) {
2181
+ let _ = self.foo();
2182
+ }
2183
+
2184
+ }
2185
+ "# ,
2186
+ expect ! [ [ r#"
2187
+ 137..141 'self': &'? Struct<'a, T>
2188
+ 152..160 '{ self }': &'? Struct<'a, T>
2189
+ 154..158 'self': &'? Struct<'a, T>
2190
+ 174..178 'self': &'? Struct<'a, T>
2191
+ 180..215 '{ ... }': ()
2192
+ 194..195 '_': &'? Struct<'?, T>
2193
+ 198..202 'self': &'? Struct<'a, T>
2194
+ 198..208 'self.foo()': &'? Struct<'?, T>
2195
+ "# ] ] ,
2196
+ ) ;
2197
+ }
You can’t perform that action at this time.
0 commit comments