@@ -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;
@@ -1316,7 +1315,6 @@ impl<'tcx> OpaqueHiddenType<'tcx> {
1316
1315
tcx : TyCtxt < ' tcx > ,
1317
1316
// typeck errors have subpar spans for opaque types, so delay error reporting until borrowck.
1318
1317
ignore_errors : bool ,
1319
- origin : OpaqueTyOrigin ,
1320
1318
) -> Self {
1321
1319
let OpaqueTypeKey { def_id, substs } = opaque_type_key;
1322
1320
@@ -1332,30 +1330,7 @@ impl<'tcx> OpaqueHiddenType<'tcx> {
1332
1330
// This zip may have several times the same lifetime in `substs` paired with a different
1333
1331
// lifetime from `id_substs`. Simply `collect`ing the iterator is the correct behaviour:
1334
1332
// it will pick the last one, which is the one we introduced in the impl-trait desugaring.
1335
- let map = substs. iter ( ) . zip ( id_substs) ;
1336
-
1337
- let map: FxHashMap < GenericArg < ' tcx > , GenericArg < ' tcx > > = match origin {
1338
- // HACK: The HIR lowering for async fn does not generate
1339
- // any `+ Captures<'x>` bounds for the `impl Future<...>`, so all async fns with lifetimes
1340
- // would now fail to compile. We should probably just make hir lowering fill this in properly.
1341
- OpaqueTyOrigin :: AsyncFn ( _) => map. collect ( ) ,
1342
- OpaqueTyOrigin :: FnReturn ( _) | OpaqueTyOrigin :: TyAlias => {
1343
- // Opaque types may only use regions that are bound. So for
1344
- // ```rust
1345
- // type Foo<'a, 'b, 'c> = impl Trait<'a> + 'b;
1346
- // ```
1347
- // we may not use `'c` in the hidden type.
1348
- let variances = tcx. variances_of ( def_id) ;
1349
- debug ! ( ?variances) ;
1350
-
1351
- map. filter ( |( _, v) | {
1352
- let ty:: GenericArgKind :: Lifetime ( lt) = v. unpack ( ) else { return true } ;
1353
- let ty:: ReEarlyBound ( ebr) = lt. kind ( ) else { bug ! ( ) } ;
1354
- variances[ ebr. index as usize ] == ty:: Variance :: Invariant
1355
- } )
1356
- . collect ( )
1357
- }
1358
- } ;
1333
+ let map = substs. iter ( ) . zip ( id_substs) . collect ( ) ;
1359
1334
debug ! ( "map = {:#?}" , map) ;
1360
1335
1361
1336
// Convert the type from the function into a type valid outside
0 commit comments