Skip to content

Commit

Permalink
Rename OtherOpaqueTy to TypeAliasesOpaqueTy
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Jul 18, 2021
1 parent 66c9cd9 commit 13287d8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
6 changes: 3 additions & 3 deletions compiler/rustc_ast_lowering/src/item.rs
Expand Up @@ -343,7 +343,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// opaque type Foo1: Trait
let ty = self.lower_ty(
ty,
ImplTraitContext::OtherOpaqueTy {
ImplTraitContext::TypeAliasesOpaqueTy {
capturable_lifetimes: &mut FxHashSet::default(),
origin: hir::OpaqueTyOrigin::TyAlias,
},
Expand Down Expand Up @@ -487,7 +487,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let mut capturable_lifetimes;
let itctx = if self.sess.features_untracked().impl_trait_in_bindings {
capturable_lifetimes = FxHashSet::default();
ImplTraitContext::OtherOpaqueTy {
ImplTraitContext::TypeAliasesOpaqueTy {
capturable_lifetimes: &mut capturable_lifetimes,
origin: hir::OpaqueTyOrigin::Misc,
}
Expand Down Expand Up @@ -926,7 +926,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
Some(ty) => {
let ty = self.lower_ty(
ty,
ImplTraitContext::OtherOpaqueTy {
ImplTraitContext::TypeAliasesOpaqueTy {
capturable_lifetimes: &mut FxHashSet::default(),
origin: hir::OpaqueTyOrigin::TyAlias,
},
Expand Down
22 changes: 13 additions & 9 deletions compiler/rustc_ast_lowering/src/lib.rs
Expand Up @@ -265,7 +265,7 @@ enum ImplTraitContext<'b, 'a> {
origin: hir::OpaqueTyOrigin,
},
/// Impl trait in type aliases.
OtherOpaqueTy {
TypeAliasesOpaqueTy {
/// Set of lifetimes that this opaque type can capture, if it uses
/// them. This includes lifetimes bound since we entered this context.
/// For example:
Expand Down Expand Up @@ -310,8 +310,8 @@ impl<'a> ImplTraitContext<'_, 'a> {
ReturnPositionOpaqueTy { fn_def_id, origin } => {
ReturnPositionOpaqueTy { fn_def_id: *fn_def_id, origin: *origin }
}
OtherOpaqueTy { capturable_lifetimes, origin } => {
OtherOpaqueTy { capturable_lifetimes, origin: *origin }
TypeAliasesOpaqueTy { capturable_lifetimes, origin } => {
TypeAliasesOpaqueTy { capturable_lifetimes, origin: *origin }
}
Disallowed(pos) => Disallowed(*pos),
}
Expand Down Expand Up @@ -1126,7 +1126,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
//
// fn foo() -> impl Iterator<Item = impl Debug>
ImplTraitContext::ReturnPositionOpaqueTy { .. }
| ImplTraitContext::OtherOpaqueTy { .. } => (true, itctx),
| ImplTraitContext::TypeAliasesOpaqueTy { .. } => (true, itctx),

// We are in the argument position, but within a dyn type:
//
Expand All @@ -1150,7 +1150,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
capturable_lifetimes = FxHashSet::default();
(
true,
ImplTraitContext::OtherOpaqueTy {
ImplTraitContext::TypeAliasesOpaqueTy {
capturable_lifetimes: &mut capturable_lifetimes,
origin: hir::OpaqueTyOrigin::Misc,
},
Expand Down Expand Up @@ -1416,11 +1416,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
None,
|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
// types will inherit lifetimes from this opaque type,
// so don't need to capture them again.
let nested_itctx = ImplTraitContext::OtherOpaqueTy {
let nested_itctx = ImplTraitContext::TypeAliasesOpaqueTy {
capturable_lifetimes: &mut FxHashSet::default(),
origin,
};
Expand Down Expand Up @@ -2321,13 +2321,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
)),
_ => 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());
}

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 {
capturable_lifetimes.remove(&param);
}
Expand Down

0 comments on commit 13287d8

Please sign in to comment.