File tree 3 files changed +36
-12
lines changed
rustc_trait_selection/src/traits
3 files changed +36
-12
lines changed Original file line number Diff line number Diff line change @@ -2282,19 +2282,18 @@ impl<'tcx> Ty<'tcx> {
2282
2282
ty:: Str | ty:: Slice ( _) => ( tcx. types . usize , false ) ,
2283
2283
ty:: Dynamic ( ..) => {
2284
2284
let dyn_metadata = tcx. lang_items ( ) . dyn_metadata ( ) . unwrap ( ) ;
2285
- ( tcx. type_of ( dyn_metadata) . subst ( tcx, & [ self . into ( ) ] ) , false )
2285
+ ( tcx. type_of ( dyn_metadata) . subst ( tcx, & [ tail . into ( ) ] ) , false )
2286
2286
} ,
2287
2287
2288
2288
// type parameters only have unit metadata if they're sized, so return true
2289
2289
// to make sure we double check this during confirmation
2290
- ty:: Param ( _) | ty:: Projection ( _) => ( tcx. types . unit , true ) ,
2290
+ ty:: Param ( _) | ty:: Projection ( _) | ty :: Opaque ( .. ) => ( tcx. types . unit , true ) ,
2291
2291
2292
- ty:: Opaque ( ..)
2293
- | ty:: Infer ( ty:: TyVar ( _) )
2292
+ ty:: Infer ( ty:: TyVar ( _) )
2294
2293
| ty:: Bound ( ..)
2295
2294
| ty:: Placeholder ( ..)
2296
2295
| ty:: Infer ( ty:: FreshTy ( _) | ty:: FreshIntTy ( _) | ty:: FreshFloatTy ( _) ) => {
2297
- bug ! ( "`ptr_metadata_ty` applied to unexpected type: {:?}" , self )
2296
+ bug ! ( "`ptr_metadata_ty` applied to unexpected type: {:?} (tail = {:?}) " , self , tail )
2298
2297
}
2299
2298
}
2300
2299
}
Original file line number Diff line number Diff line change @@ -1439,10 +1439,18 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
1439
1439
// Integers and floats are always Sized, and so have unit type metadata.
1440
1440
| ty:: Infer ( ty:: InferTy :: IntVar ( _) | ty:: InferTy :: FloatVar ( ..) ) => true ,
1441
1441
1442
- // type parameters and unnormalized projections have pointer metadata if they're still known to be sized
1443
- ty:: Param ( _) | ty:: Projection ( ..) => tail. is_sized ( selcx. tcx ( ) . at ( obligation. cause . span ) , obligation. param_env ) ,
1442
+ // type parameters, opaques, and unnormalized projections have pointer
1443
+ // metadata if they're known (e.g. by the param_env) to be sized
1444
+ ty:: Param ( _) | ty:: Projection ( ..) | ty:: Opaque ( ..)
1445
+ if tail. is_sized ( selcx. tcx ( ) . at ( obligation. cause . span ) , obligation. param_env ) =>
1446
+ {
1447
+ true
1448
+ }
1444
1449
1445
- ty:: Opaque ( ..)
1450
+ // FIXME(compiler-errors): are Bound and Placeholder types ever known sized?
1451
+ ty:: Param ( _)
1452
+ | ty:: Projection ( ..)
1453
+ | ty:: Opaque ( ..)
1446
1454
| ty:: Bound ( ..)
1447
1455
| ty:: Placeholder ( ..)
1448
1456
| ty:: Infer ( ..)
@@ -1451,7 +1459,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
1451
1459
candidate_set. mark_ambiguous ( ) ;
1452
1460
}
1453
1461
false
1454
- } ,
1462
+ }
1455
1463
}
1456
1464
}
1457
1465
super :: ImplSource :: Param ( ..) => {
Original file line number Diff line number Diff line change 1
1
// check-pass
2
+ // edition:2018
2
3
3
4
#![ feature( ptr_metadata) ]
5
+ #![ feature( type_alias_impl_trait) ]
6
+
7
+ type Opaque = impl std:: future:: Future ;
8
+
9
+ fn opaque ( ) -> Opaque {
10
+ async { }
11
+ }
4
12
5
13
fn a < T > ( ) {
6
- b :: < T > ( ) ;
7
- b :: < std:: cell:: Cell < T > > ( ) ;
14
+ // type parameter T is known to be sized
15
+ is_thin :: < T > ( ) ;
16
+ // tail of ADT (which is a type param) is known to be sized
17
+ is_thin :: < std:: cell:: Cell < T > > ( ) ;
18
+ // opaque type is known to be sized
19
+ is_thin :: < Opaque > ( ) ;
20
+ }
21
+
22
+ fn a2 < T : Iterator > ( ) {
23
+ // associated type is known to be sized
24
+ is_thin :: < T :: Item > ( ) ;
8
25
}
9
26
10
- fn b < T : std:: ptr:: Pointee < Metadata = ( ) > > ( ) { }
27
+ fn is_thin < T : std:: ptr:: Pointee < Metadata = ( ) > > ( ) { }
11
28
12
29
fn main ( ) { }
You can’t perform that action at this time.
0 commit comments