@@ -28,7 +28,6 @@ use crate::ty::util::Discr;
28
28
pub use adt:: * ;
29
29
pub use assoc:: * ;
30
30
pub use generics:: * ;
31
- use hir:: OpaqueTyOrigin ;
32
31
use rustc_ast as ast;
33
32
use rustc_ast:: node_id:: NodeMap ;
34
33
use rustc_attr as attr;
@@ -1345,7 +1344,6 @@ impl<'tcx> OpaqueHiddenType<'tcx> {
1345
1344
tcx : TyCtxt < ' tcx > ,
1346
1345
// typeck errors have subpar spans for opaque types, so delay error reporting until borrowck.
1347
1346
ignore_errors : bool ,
1348
- origin : OpaqueTyOrigin ,
1349
1347
) -> Self {
1350
1348
let OpaqueTypeKey { def_id, substs } = opaque_type_key;
1351
1349
@@ -1361,30 +1359,7 @@ impl<'tcx> OpaqueHiddenType<'tcx> {
1361
1359
// This zip may have several times the same lifetime in `substs` paired with a different
1362
1360
// lifetime from `id_substs`. Simply `collect`ing the iterator is the correct behaviour:
1363
1361
// it will pick the last one, which is the one we introduced in the impl-trait desugaring.
1364
- let map = substs. iter ( ) . zip ( id_substs) ;
1365
-
1366
- let map: FxHashMap < GenericArg < ' tcx > , GenericArg < ' tcx > > = match origin {
1367
- // HACK: The HIR lowering for async fn does not generate
1368
- // any `+ Captures<'x>` bounds for the `impl Future<...>`, so all async fns with lifetimes
1369
- // would now fail to compile. We should probably just make hir lowering fill this in properly.
1370
- OpaqueTyOrigin :: AsyncFn ( _) => map. collect ( ) ,
1371
- OpaqueTyOrigin :: FnReturn ( _) | OpaqueTyOrigin :: TyAlias => {
1372
- // Opaque types may only use regions that are bound. So for
1373
- // ```rust
1374
- // type Foo<'a, 'b, 'c> = impl Trait<'a> + 'b;
1375
- // ```
1376
- // we may not use `'c` in the hidden type.
1377
- let variances = tcx. variances_of ( def_id) ;
1378
- debug ! ( ?variances) ;
1379
-
1380
- map. filter ( |( _, v) | {
1381
- let ty:: GenericArgKind :: Lifetime ( lt) = v. unpack ( ) else { return true } ;
1382
- let ty:: ReEarlyBound ( ebr) = lt. kind ( ) else { bug ! ( ) } ;
1383
- variances[ ebr. index as usize ] == ty:: Variance :: Invariant
1384
- } )
1385
- . collect ( )
1386
- }
1387
- } ;
1362
+ let map = substs. iter ( ) . zip ( id_substs) . collect ( ) ;
1388
1363
debug ! ( "map = {:#?}" , map) ;
1389
1364
1390
1365
// Convert the type from the function into a type valid outside
0 commit comments