Skip to content

Commit b4fe555

Browse files
committed
Replace exist_ty and ExistTy with opaque_ty and OpaqueTy
1 parent 2777386 commit b4fe555

File tree

11 files changed

+79
-79
lines changed

11 files changed

+79
-79
lines changed

Diff for: src/librustc/hir/intravisit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
505505
visitor.visit_ty(ty);
506506
visitor.visit_generics(generics)
507507
}
508-
ItemKind::OpaqueTy(ExistTy {
508+
ItemKind::OpaqueTy(OpaqueTy {
509509
ref generics,
510510
ref bounds,
511511
..

Diff for: src/librustc/hir/lowering.rs

+53-53
Original file line numberDiff line numberDiff line change
@@ -1721,38 +1721,38 @@ impl<'a> LoweringContext<'a> {
17211721
&mut self,
17221722
span: Span,
17231723
fn_def_id: Option<DefId>,
1724-
exist_ty_node_id: NodeId,
1724+
opaque_ty_node_id: NodeId,
17251725
lower_bounds: impl FnOnce(&mut LoweringContext<'_>) -> hir::GenericBounds,
17261726
) -> hir::TyKind {
17271727
// Make sure we know that some funky desugaring has been going on here.
17281728
// This is a first: there is code in other places like for loop
17291729
// desugaring that explicitly states that we don't want to track that.
17301730
// Not tracking it makes lints in rustc and clippy very fragile, as
17311731
// frequently opened issues show.
1732-
let exist_ty_span = self.mark_span_with_reason(
1732+
let opaque_ty_span = self.mark_span_with_reason(
17331733
DesugaringKind::OpaqueTy,
17341734
span,
17351735
None,
17361736
);
17371737

1738-
let exist_ty_def_index = self
1738+
let opaque_ty_def_index = self
17391739
.resolver
17401740
.definitions()
1741-
.opt_def_index(exist_ty_node_id)
1741+
.opt_def_index(opaque_ty_node_id)
17421742
.unwrap();
17431743

1744-
self.allocate_hir_id_counter(exist_ty_node_id);
1744+
self.allocate_hir_id_counter(opaque_ty_node_id);
17451745

1746-
let hir_bounds = self.with_hir_id_owner(exist_ty_node_id, lower_bounds);
1746+
let hir_bounds = self.with_hir_id_owner(opaque_ty_node_id, lower_bounds);
17471747

17481748
let (lifetimes, lifetime_defs) = self.lifetimes_from_impl_trait_bounds(
1749-
exist_ty_node_id,
1750-
exist_ty_def_index,
1749+
opaque_ty_node_id,
1750+
opaque_ty_def_index,
17511751
&hir_bounds,
17521752
);
17531753

1754-
self.with_hir_id_owner(exist_ty_node_id, |lctx| {
1755-
let exist_ty_item = hir::ExistTy {
1754+
self.with_hir_id_owner(opaque_ty_node_id, |lctx| {
1755+
let opaque_ty_item = hir::OpaqueTy {
17561756
generics: hir::Generics {
17571757
params: lifetime_defs,
17581758
where_clause: hir::WhereClause {
@@ -1766,51 +1766,51 @@ impl<'a> LoweringContext<'a> {
17661766
origin: hir::OpaqueTyOrigin::ReturnImplTrait,
17671767
};
17681768

1769-
trace!("exist ty from impl trait def-index: {:#?}", exist_ty_def_index);
1770-
let exist_ty_id = lctx.generate_opaque_type(
1771-
exist_ty_node_id,
1772-
exist_ty_item,
1769+
trace!("exist ty from impl trait def-index: {:#?}", opaque_ty_def_index);
1770+
let opaque_ty_id = lctx.generate_opaque_type(
1771+
opaque_ty_node_id,
1772+
opaque_ty_item,
17731773
span,
1774-
exist_ty_span,
1774+
opaque_ty_span,
17751775
);
17761776

17771777
// `impl Trait` now just becomes `Foo<'a, 'b, ..>`.
1778-
hir::TyKind::Def(hir::ItemId { id: exist_ty_id }, lifetimes)
1778+
hir::TyKind::Def(hir::ItemId { id: opaque_ty_id }, lifetimes)
17791779
})
17801780
}
17811781

17821782
/// Registers a new opaque type with the proper `NodeId`s and
17831783
/// returns the lowered node-ID for the opaque type.
17841784
fn generate_opaque_type(
17851785
&mut self,
1786-
exist_ty_node_id: NodeId,
1787-
exist_ty_item: hir::ExistTy,
1786+
opaque_ty_node_id: NodeId,
1787+
opaque_ty_item: hir::OpaqueTy,
17881788
span: Span,
1789-
exist_ty_span: Span,
1789+
opaque_ty_span: Span,
17901790
) -> hir::HirId {
1791-
let exist_ty_item_kind = hir::ItemKind::OpaqueTy(exist_ty_item);
1792-
let exist_ty_id = self.lower_node_id(exist_ty_node_id);
1791+
let opaque_ty_item_kind = hir::ItemKind::OpaqueTy(opaque_ty_item);
1792+
let opaque_ty_id = self.lower_node_id(opaque_ty_node_id);
17931793
// Generate an `type Foo = impl Trait;` declaration.
1794-
trace!("registering opaque type with id {:#?}", exist_ty_id);
1795-
let exist_ty_item = hir::Item {
1796-
hir_id: exist_ty_id,
1794+
trace!("registering opaque type with id {:#?}", opaque_ty_id);
1795+
let opaque_ty_item = hir::Item {
1796+
hir_id: opaque_ty_id,
17971797
ident: Ident::invalid(),
17981798
attrs: Default::default(),
1799-
node: exist_ty_item_kind,
1799+
node: opaque_ty_item_kind,
18001800
vis: respan(span.shrink_to_lo(), hir::VisibilityKind::Inherited),
1801-
span: exist_ty_span,
1801+
span: opaque_ty_span,
18021802
};
18031803

18041804
// Insert the item into the global item list. This usually happens
18051805
// automatically for all AST items. But this opaque type item
18061806
// does not actually exist in the AST.
1807-
self.insert_item(exist_ty_item);
1808-
exist_ty_id
1807+
self.insert_item(opaque_ty_item);
1808+
opaque_ty_id
18091809
}
18101810

18111811
fn lifetimes_from_impl_trait_bounds(
18121812
&mut self,
1813-
exist_ty_id: NodeId,
1813+
opaque_ty_id: NodeId,
18141814
parent_index: DefIndex,
18151815
bounds: &hir::GenericBounds,
18161816
) -> (HirVec<hir::GenericArg>, HirVec<hir::GenericParam>) {
@@ -1820,7 +1820,7 @@ impl<'a> LoweringContext<'a> {
18201820
struct ImplTraitLifetimeCollector<'r, 'a> {
18211821
context: &'r mut LoweringContext<'a>,
18221822
parent: DefIndex,
1823-
exist_ty_id: NodeId,
1823+
opaque_ty_id: NodeId,
18241824
collect_elided_lifetimes: bool,
18251825
currently_bound_lifetimes: Vec<hir::LifetimeName>,
18261826
already_defined_lifetimes: FxHashSet<hir::LifetimeName>,
@@ -1916,7 +1916,7 @@ impl<'a> LoweringContext<'a> {
19161916

19171917
let def_node_id = self.context.sess.next_node_id();
19181918
let hir_id =
1919-
self.context.lower_node_id_with_owner(def_node_id, self.exist_ty_id);
1919+
self.context.lower_node_id_with_owner(def_node_id, self.opaque_ty_id);
19201920
self.context.resolver.definitions().create_def_with_parent(
19211921
self.parent,
19221922
def_node_id,
@@ -1952,7 +1952,7 @@ impl<'a> LoweringContext<'a> {
19521952
let mut lifetime_collector = ImplTraitLifetimeCollector {
19531953
context: self,
19541954
parent: parent_index,
1955-
exist_ty_id,
1955+
opaque_ty_id,
19561956
collect_elided_lifetimes: true,
19571957
currently_bound_lifetimes: Vec::new(),
19581958
already_defined_lifetimes: FxHashSet::default(),
@@ -2582,40 +2582,40 @@ impl<'a> LoweringContext<'a> {
25822582
})
25832583
}
25842584

2585-
// Transforms `-> T` for `async fn` into `-> ExistTy { .. }`
2586-
// combined with the following definition of `ExistTy`:
2585+
// Transforms `-> T` for `async fn` into `-> OpaqueTy { .. }`
2586+
// combined with the following definition of `OpaqueTy`:
25872587
//
2588-
// type ExistTy<generics_from_parent_fn> = impl Future<Output = T>;
2588+
// type OpaqueTy<generics_from_parent_fn> = impl Future<Output = T>;
25892589
//
25902590
// `inputs`: lowered types of arguments to the function (used to collect lifetimes)
25912591
// `output`: unlowered output type (`T` in `-> T`)
25922592
// `fn_def_id`: `DefId` of the parent function (used to create child impl trait definition)
2593-
// `exist_ty_node_id`: `NodeId` of the opaque `impl Trait` type that should be created
2593+
// `opaque_ty_node_id`: `NodeId` of the opaque `impl Trait` type that should be created
25942594
// `elided_lt_replacement`: replacement for elided lifetimes in the return type
25952595
fn lower_async_fn_ret_ty(
25962596
&mut self,
25972597
output: &FunctionRetTy,
25982598
fn_def_id: DefId,
2599-
exist_ty_node_id: NodeId,
2599+
opaque_ty_node_id: NodeId,
26002600
elided_lt_replacement: LtReplacement,
26012601
) -> hir::FunctionRetTy {
26022602
let span = output.span();
26032603

2604-
let exist_ty_span = self.mark_span_with_reason(
2604+
let opaque_ty_span = self.mark_span_with_reason(
26052605
DesugaringKind::Async,
26062606
span,
26072607
None,
26082608
);
26092609

2610-
let exist_ty_def_index = self
2610+
let opaque_ty_def_index = self
26112611
.resolver
26122612
.definitions()
2613-
.opt_def_index(exist_ty_node_id)
2613+
.opt_def_index(opaque_ty_node_id)
26142614
.unwrap();
26152615

2616-
self.allocate_hir_id_counter(exist_ty_node_id);
2616+
self.allocate_hir_id_counter(opaque_ty_node_id);
26172617

2618-
let (exist_ty_id, lifetime_params) = self.with_hir_id_owner(exist_ty_node_id, |this| {
2618+
let (opaque_ty_id, lifetime_params) = self.with_hir_id_owner(opaque_ty_node_id, |this| {
26192619
let future_bound = this.with_anonymous_lifetime_mode(
26202620
AnonymousLifetimeMode::Replace(elided_lt_replacement),
26212621
|this| this.lower_async_fn_output_type_to_future_bound(
@@ -2642,11 +2642,11 @@ impl<'a> LoweringContext<'a> {
26422642
lifetime_params
26432643
.iter().cloned()
26442644
.map(|(span, hir_name)| {
2645-
this.lifetime_to_generic_param(span, hir_name, exist_ty_def_index)
2645+
this.lifetime_to_generic_param(span, hir_name, opaque_ty_def_index)
26462646
})
26472647
.collect();
26482648

2649-
let exist_ty_item = hir::ExistTy {
2649+
let opaque_ty_item = hir::OpaqueTy {
26502650
generics: hir::Generics {
26512651
params: generic_params,
26522652
where_clause: hir::WhereClause {
@@ -2660,15 +2660,15 @@ impl<'a> LoweringContext<'a> {
26602660
origin: hir::OpaqueTyOrigin::AsyncFn,
26612661
};
26622662

2663-
trace!("exist ty from async fn def index: {:#?}", exist_ty_def_index);
2664-
let exist_ty_id = this.generate_opaque_type(
2665-
exist_ty_node_id,
2666-
exist_ty_item,
2663+
trace!("exist ty from async fn def index: {:#?}", opaque_ty_def_index);
2664+
let opaque_ty_id = this.generate_opaque_type(
2665+
opaque_ty_node_id,
2666+
opaque_ty_item,
26672667
span,
2668-
exist_ty_span,
2668+
opaque_ty_span,
26692669
);
26702670

2671-
(exist_ty_id, lifetime_params)
2671+
(opaque_ty_id, lifetime_params)
26722672
});
26732673

26742674
let generic_args =
@@ -2683,10 +2683,10 @@ impl<'a> LoweringContext<'a> {
26832683
})
26842684
.collect();
26852685

2686-
let exist_ty_ref = hir::TyKind::Def(hir::ItemId { id: exist_ty_id }, generic_args);
2686+
let opaque_ty_ref = hir::TyKind::Def(hir::ItemId { id: opaque_ty_id }, generic_args);
26872687

26882688
hir::FunctionRetTy::Return(P(hir::Ty {
2689-
node: exist_ty_ref,
2689+
node: opaque_ty_ref,
26902690
span,
26912691
hir_id: self.next_id(),
26922692
}))
@@ -3445,7 +3445,7 @@ impl<'a> LoweringContext<'a> {
34453445
self.lower_generics(generics, ImplTraitContext::disallowed()),
34463446
),
34473447
ItemKind::OpaqueTy(ref b, ref generics) => hir::ItemKind::OpaqueTy(
3448-
hir::ExistTy {
3448+
hir::OpaqueTy {
34493449
generics: self.lower_generics(generics,
34503450
ImplTraitContext::OpaqueTy(None)),
34513451
bounds: self.lower_param_bounds(b,

Diff for: src/librustc/hir/map/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ impl<'hir> Map<'hir> {
827827
match self.get(scope) {
828828
Node::Item(i) => {
829829
match i.node {
830-
ItemKind::OpaqueTy(ExistTy { impl_trait_fn: None, .. }) => {}
830+
ItemKind::OpaqueTy(OpaqueTy { impl_trait_fn: None, .. }) => {}
831831
_ => break,
832832
}
833833
}

Diff for: src/librustc/hir/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1922,7 +1922,7 @@ pub struct BareFnTy {
19221922
}
19231923

19241924
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
1925-
pub struct ExistTy {
1925+
pub struct OpaqueTy {
19261926
pub generics: Generics,
19271927
pub bounds: GenericBounds,
19281928
pub impl_trait_fn: Option<DefId>,
@@ -2422,7 +2422,7 @@ pub enum ItemKind {
24222422
/// A type alias, e.g., `type Foo = Bar<u8>`
24232423
Ty(P<Ty>, Generics),
24242424
/// An opaque `impl Trait` type alias, e.g., `type Foo = impl Bar;`
2425-
OpaqueTy(ExistTy),
2425+
OpaqueTy(OpaqueTy),
24262426
/// An enum definition, e.g., `enum Foo<A, B> {C<A>, D<B>}`
24272427
Enum(EnumDef, Generics),
24282428
/// A struct definition, e.g., `struct Foo<A> {x: A}`
@@ -2479,7 +2479,7 @@ impl ItemKind {
24792479
Some(match *self {
24802480
ItemKind::Fn(_, _, ref generics, _) |
24812481
ItemKind::Ty(_, ref generics) |
2482-
ItemKind::OpaqueTy(ExistTy { ref generics, impl_trait_fn: None, .. }) |
2482+
ItemKind::OpaqueTy(OpaqueTy { ref generics, impl_trait_fn: None, .. }) |
24832483
ItemKind::Enum(_, ref generics) |
24842484
ItemKind::Struct(_, ref generics) |
24852485
ItemKind::Union(_, ref generics) |

Diff for: src/librustc/infer/opaque_types/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1033,13 +1033,13 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
10331033
let (in_definition_scope, origin) = match tcx.hir().find(opaque_hir_id) {
10341034
Some(Node::Item(item)) => match item.node {
10351035
// Anonymous `impl Trait`
1036-
hir::ItemKind::OpaqueTy(hir::ExistTy {
1036+
hir::ItemKind::OpaqueTy(hir::OpaqueTy {
10371037
impl_trait_fn: Some(parent),
10381038
origin,
10391039
..
10401040
}) => (parent == self.parent_def_id, origin),
10411041
// Named `type Foo = impl Bar;`
1042-
hir::ItemKind::OpaqueTy(hir::ExistTy {
1042+
hir::ItemKind::OpaqueTy(hir::OpaqueTy {
10431043
impl_trait_fn: None,
10441044
origin,
10451045
..

Diff for: src/librustc/middle/resolve_lifetime.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
480480
};
481481
self.with(scope, |_, this| intravisit::walk_item(this, item));
482482
}
483-
hir::ItemKind::OpaqueTy(hir::ExistTy {
483+
hir::ItemKind::OpaqueTy(hir::OpaqueTy {
484484
impl_trait_fn: Some(_),
485485
..
486486
}) => {
@@ -489,7 +489,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
489489
// it.
490490
}
491491
hir::ItemKind::Ty(_, ref generics)
492-
| hir::ItemKind::OpaqueTy(hir::ExistTy {
492+
| hir::ItemKind::OpaqueTy(hir::OpaqueTy {
493493
impl_trait_fn: None,
494494
ref generics,
495495
..
@@ -629,15 +629,15 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
629629
{
630630
// Named opaque `impl Trait` types are reached via `TyKind::Path`.
631631
// This arm is for `impl Trait` in the types of statics, constants and locals.
632-
hir::ItemKind::OpaqueTy(hir::ExistTy {
632+
hir::ItemKind::OpaqueTy(hir::OpaqueTy {
633633
impl_trait_fn: None,
634634
..
635635
}) => {
636636
intravisit::walk_ty(self, ty);
637637
return;
638638
}
639639
// RPIT (return position impl trait)
640-
hir::ItemKind::OpaqueTy(hir::ExistTy {
640+
hir::ItemKind::OpaqueTy(hir::OpaqueTy {
641641
ref generics,
642642
ref bounds,
643643
..
@@ -1254,7 +1254,7 @@ fn compute_object_lifetime_defaults(tcx: TyCtxt<'_>) -> HirIdMap<Vec<ObjectLifet
12541254
hir::ItemKind::Struct(_, ref generics)
12551255
| hir::ItemKind::Union(_, ref generics)
12561256
| hir::ItemKind::Enum(_, ref generics)
1257-
| hir::ItemKind::OpaqueTy(hir::ExistTy {
1257+
| hir::ItemKind::OpaqueTy(hir::OpaqueTy {
12581258
ref generics,
12591259
impl_trait_fn: None,
12601260
..

Diff for: src/librustc/ty/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3214,8 +3214,8 @@ fn trait_of_item(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> {
32143214
pub fn is_impl_trait_defn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> {
32153215
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
32163216
if let Node::Item(item) = tcx.hir().get(hir_id) {
3217-
if let hir::ItemKind::OpaqueTy(ref exist_ty) = item.node {
3218-
return exist_ty.impl_trait_fn;
3217+
if let hir::ItemKind::OpaqueTy(ref opaque_ty) = item.node {
3218+
return opaque_ty.impl_trait_fn;
32193219
}
32203220
}
32213221
}

Diff for: src/librustc_typeck/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item) {
14031403
hir::ItemKind::Union(..) => {
14041404
check_union(tcx, it.hir_id, it.span);
14051405
}
1406-
hir::ItemKind::OpaqueTy(hir::ExistTy{origin, ..}) => {
1406+
hir::ItemKind::OpaqueTy(hir::OpaqueTy{origin, ..}) => {
14071407
let def_id = tcx.hir().local_def_id(it.hir_id);
14081408

14091409
let substs = InternalSubsts::identity_for_item(tcx, def_id);

0 commit comments

Comments
 (0)