]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #106503 - cjgillot:remap-nofilter, r=oli-obk
authorbors <bors@rust-lang.org>
Wed, 18 Jan 2023 16:37:33 +0000 (16:37 +0000)
committerbors <bors@rust-lang.org>
Wed, 18 Jan 2023 16:37:33 +0000 (16:37 +0000)
Do not filter substs in `remap_generic_params_to_declaration_params`.

The relevant filtering should have been performed by borrowck.

Fixes https://github.com/rust-lang/rust/issues/105826

r? types

1  2 
compiler/rustc_borrowck/src/region_infer/opaque_types.rs
compiler/rustc_middle/src/ty/mod.rs

index e68f27cc0fd5d7cb7bb4a3831f7e9d09dbff82a3,d5f2fe3ac3792c1a4304c7fa125155cf2128f26c..ccac6e8f77a6557d00136dfd6eb8970d6a5e7e32
@@@ -1359,32 -1328,9 +1357,9 @@@ impl<'tcx> OpaqueHiddenType<'tcx> 
          debug!(?id_substs);
  
          // This zip may have several times the same lifetime in `substs` paired with a different
 -        // lifetime from `id_substs`.  Simply `collect`ing the iterator is the correct behaviour:
 +        // lifetime from `id_substs`. Simply `collect`ing the iterator is the correct behaviour:
          // it will pick the last one, which is the one we introduced in the impl-trait desugaring.
-         let map = substs.iter().zip(id_substs);
-         let map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>> = match origin {
-             // HACK: The HIR lowering for async fn does not generate
-             // any `+ Captures<'x>` bounds for the `impl Future<...>`, so all async fns with lifetimes
-             // would now fail to compile. We should probably just make hir lowering fill this in properly.
-             OpaqueTyOrigin::AsyncFn(_) => map.collect(),
-             OpaqueTyOrigin::FnReturn(_) | OpaqueTyOrigin::TyAlias => {
-                 // Opaque types may only use regions that are bound. So for
-                 // ```rust
-                 // type Foo<'a, 'b, 'c> = impl Trait<'a> + 'b;
-                 // ```
-                 // we may not use `'c` in the hidden type.
-                 let variances = tcx.variances_of(def_id);
-                 debug!(?variances);
-                 map.filter(|(_, v)| {
-                     let ty::GenericArgKind::Lifetime(lt) = v.unpack() else { return true };
-                     let ty::ReEarlyBound(ebr) = lt.kind() else { bug!() };
-                     variances[ebr.index as usize] == ty::Variance::Invariant
-                 })
-                 .collect()
-             }
-         };
+         let map = substs.iter().zip(id_substs).collect();
          debug!("map = {:#?}", map);
  
          // Convert the type from the function into a type valid outside