1
Fork 0

Rename OtherOpaqueTy to TypeAliasesOpaqueTy

This commit is contained in:
Santiago Pastorino 2021-07-14 15:06:02 -03:00
parent 66c9cd9e66
commit 13287d8dd2
No known key found for this signature in database
GPG key ID: 8131A24E0C79EFAF
2 changed files with 16 additions and 12 deletions

View file

@ -343,7 +343,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// opaque type Foo1: Trait // opaque type Foo1: Trait
let ty = self.lower_ty( let ty = self.lower_ty(
ty, ty,
ImplTraitContext::OtherOpaqueTy { ImplTraitContext::TypeAliasesOpaqueTy {
capturable_lifetimes: &mut FxHashSet::default(), capturable_lifetimes: &mut FxHashSet::default(),
origin: hir::OpaqueTyOrigin::TyAlias, origin: hir::OpaqueTyOrigin::TyAlias,
}, },
@ -487,7 +487,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let mut capturable_lifetimes; let mut capturable_lifetimes;
let itctx = if self.sess.features_untracked().impl_trait_in_bindings { let itctx = if self.sess.features_untracked().impl_trait_in_bindings {
capturable_lifetimes = FxHashSet::default(); capturable_lifetimes = FxHashSet::default();
ImplTraitContext::OtherOpaqueTy { ImplTraitContext::TypeAliasesOpaqueTy {
capturable_lifetimes: &mut capturable_lifetimes, capturable_lifetimes: &mut capturable_lifetimes,
origin: hir::OpaqueTyOrigin::Misc, origin: hir::OpaqueTyOrigin::Misc,
} }
@ -926,7 +926,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
Some(ty) => { Some(ty) => {
let ty = self.lower_ty( let ty = self.lower_ty(
ty, ty,
ImplTraitContext::OtherOpaqueTy { ImplTraitContext::TypeAliasesOpaqueTy {
capturable_lifetimes: &mut FxHashSet::default(), capturable_lifetimes: &mut FxHashSet::default(),
origin: hir::OpaqueTyOrigin::TyAlias, origin: hir::OpaqueTyOrigin::TyAlias,
}, },

View file

@ -265,7 +265,7 @@ enum ImplTraitContext<'b, 'a> {
origin: hir::OpaqueTyOrigin, origin: hir::OpaqueTyOrigin,
}, },
/// Impl trait in type aliases. /// Impl trait in type aliases.
OtherOpaqueTy { TypeAliasesOpaqueTy {
/// Set of lifetimes that this opaque type can capture, if it uses /// Set of lifetimes that this opaque type can capture, if it uses
/// them. This includes lifetimes bound since we entered this context. /// them. This includes lifetimes bound since we entered this context.
/// For example: /// For example:
@ -310,8 +310,8 @@ impl<'a> ImplTraitContext<'_, 'a> {
ReturnPositionOpaqueTy { fn_def_id, origin } => { ReturnPositionOpaqueTy { fn_def_id, origin } => {
ReturnPositionOpaqueTy { fn_def_id: *fn_def_id, origin: *origin } ReturnPositionOpaqueTy { fn_def_id: *fn_def_id, origin: *origin }
} }
OtherOpaqueTy { capturable_lifetimes, origin } => { TypeAliasesOpaqueTy { capturable_lifetimes, origin } => {
OtherOpaqueTy { capturable_lifetimes, origin: *origin } TypeAliasesOpaqueTy { capturable_lifetimes, origin: *origin }
} }
Disallowed(pos) => Disallowed(*pos), Disallowed(pos) => Disallowed(*pos),
} }
@ -1126,7 +1126,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
// //
// fn foo() -> impl Iterator<Item = impl Debug> // fn foo() -> impl Iterator<Item = impl Debug>
ImplTraitContext::ReturnPositionOpaqueTy { .. } ImplTraitContext::ReturnPositionOpaqueTy { .. }
| ImplTraitContext::OtherOpaqueTy { .. } => (true, itctx), | ImplTraitContext::TypeAliasesOpaqueTy { .. } => (true, itctx),
// We are in the argument position, but within a dyn type: // We are in the argument position, but within a dyn type:
// //
@ -1150,7 +1150,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
capturable_lifetimes = FxHashSet::default(); capturable_lifetimes = FxHashSet::default();
( (
true, true,
ImplTraitContext::OtherOpaqueTy { ImplTraitContext::TypeAliasesOpaqueTy {
capturable_lifetimes: &mut capturable_lifetimes, capturable_lifetimes: &mut capturable_lifetimes,
origin: hir::OpaqueTyOrigin::Misc, origin: hir::OpaqueTyOrigin::Misc,
}, },
@ -1416,11 +1416,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
None, None,
|this| this.lower_param_bounds(bounds, itctx), |this| this.lower_param_bounds(bounds, itctx),
), ),
ImplTraitContext::OtherOpaqueTy { ref capturable_lifetimes, origin } => { ImplTraitContext::TypeAliasesOpaqueTy { ref capturable_lifetimes, origin } => {
// Reset capturable lifetimes, any nested impl trait // Reset capturable lifetimes, any nested impl trait
// types will inherit lifetimes from this opaque type, // types will inherit lifetimes from this opaque type,
// so don't need to capture them again. // so don't need to capture them again.
let nested_itctx = ImplTraitContext::OtherOpaqueTy { let nested_itctx = ImplTraitContext::TypeAliasesOpaqueTy {
capturable_lifetimes: &mut FxHashSet::default(), capturable_lifetimes: &mut FxHashSet::default(),
origin, origin,
}; };
@ -2321,13 +2321,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
)), )),
_ => None, _ => None,
}); });
if let ImplTraitContext::OtherOpaqueTy { ref mut capturable_lifetimes, .. } = itctx { if let ImplTraitContext::TypeAliasesOpaqueTy { ref mut capturable_lifetimes, .. } =
itctx
{
capturable_lifetimes.extend(lt_def_names.clone()); capturable_lifetimes.extend(lt_def_names.clone());
} }
let res = this.lower_trait_ref(&p.trait_ref, itctx.reborrow()); let res = this.lower_trait_ref(&p.trait_ref, itctx.reborrow());
if let ImplTraitContext::OtherOpaqueTy { ref mut capturable_lifetimes, .. } = itctx { if let ImplTraitContext::TypeAliasesOpaqueTy { ref mut capturable_lifetimes, .. } =
itctx
{
for param in lt_def_names { for param in lt_def_names {
capturable_lifetimes.remove(&param); capturable_lifetimes.remove(&param);
} }