diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2022-11-14 21:24:18 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-11-14 21:24:18 +0000 |
| commit | b37feca804ece8eed650465faab65f5c53494b33 (patch) | |
| tree | 3759189c818d72e70425b003c6bd05f2aeda2428 /compiler/rustc_middle/src | |
| parent | b552965a93b28a6f184c75fe4e6fcc5129dc1d1a (diff) | |
Give precendence to regions from member constaints when inferring concrete types.
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/ty/mod.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index ce1b1d6973e..31bdb049e76 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -1257,7 +1257,7 @@ impl<'tcx> InstantiatedPredicates<'tcx> { } } -#[derive(Copy, Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable, Lift)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable, TyEncodable, TyDecodable, Lift)] #[derive(TypeFoldable, TypeVisitable)] pub struct OpaqueTypeKey<'tcx> { pub def_id: LocalDefId, @@ -1333,17 +1333,16 @@ 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`. In that case, we actually want to pick the last one, as it - // is the one we introduced in the impl-trait desugaring to be meaningful. The other ones - // are redundant. + // 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::FnReturn(_) | OpaqueTyOrigin::AsyncFn(_) => map.collect(), - OpaqueTyOrigin::TyAlias => { + 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; |
