Skip to content

Commit d727071

Browse files
committed
Auto merge of #63180 - varkor:trait-alias-impl-trait, r=Centril
Change opaque type syntax from `existential type` to type alias `impl Trait` This implements a new feature gate `type_alias_impl_trait` (this is slightly different from the originally proposed feature name, but matches what has been used in discussion since), deprecating the old `existential_types` feature. The syntax for opaque types has been changed. In addition, the "existential" terminology has been replaced with "opaque", as per previous discussion and the RFC. This makes partial progress towards implementing #63063. r? @Centril
2 parents d9bd4b2 + fbd7e0c commit d727071

File tree

202 files changed

+1050
-1033
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

202 files changed

+1050
-1033
lines changed

src/librustc/hir/check_attr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub(crate) enum Target {
2727
ForeignMod,
2828
GlobalAsm,
2929
Ty,
30-
Existential,
30+
OpaqueTy,
3131
Enum,
3232
Struct,
3333
Union,
@@ -51,7 +51,7 @@ impl Display for Target {
5151
Target::ForeignMod => "foreign module",
5252
Target::GlobalAsm => "global asm",
5353
Target::Ty => "type alias",
54-
Target::Existential => "existential type",
54+
Target::OpaqueTy => "opaque type",
5555
Target::Enum => "enum",
5656
Target::Struct => "struct",
5757
Target::Union => "union",
@@ -76,7 +76,7 @@ impl Target {
7676
hir::ItemKind::ForeignMod(..) => Target::ForeignMod,
7777
hir::ItemKind::GlobalAsm(..) => Target::GlobalAsm,
7878
hir::ItemKind::Ty(..) => Target::Ty,
79-
hir::ItemKind::Existential(..) => Target::Existential,
79+
hir::ItemKind::OpaqueTy(..) => Target::OpaqueTy,
8080
hir::ItemKind::Enum(..) => Target::Enum,
8181
hir::ItemKind::Struct(..) => Target::Struct,
8282
hir::ItemKind::Union(..) => Target::Union,

src/librustc/hir/def.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ pub enum DefKind {
5555
/// Refers to the variant itself, `DefKind::Ctor` refers to its constructor if it exists.
5656
Variant,
5757
Trait,
58-
/// `existential type Foo: Bar;`
59-
Existential,
58+
/// `type Foo = impl Bar;`
59+
OpaqueTy,
6060
/// `type Foo = Bar;`
6161
TyAlias,
6262
ForeignTy,
6363
TraitAlias,
6464
AssocTy,
65-
/// `existential type Foo: Bar;`
66-
AssocExistential,
65+
/// `type Foo = impl Bar;`
66+
AssocOpaqueTy,
6767
TyParam,
6868

6969
// Value namespace
@@ -96,11 +96,11 @@ impl DefKind {
9696
DefKind::Ctor(CtorOf::Struct, CtorKind::Const) => "unit struct",
9797
DefKind::Ctor(CtorOf::Struct, CtorKind::Fictive) =>
9898
bug!("impossible struct constructor"),
99-
DefKind::Existential => "existential type",
99+
DefKind::OpaqueTy => "opaque type",
100100
DefKind::TyAlias => "type alias",
101101
DefKind::TraitAlias => "trait alias",
102102
DefKind::AssocTy => "associated type",
103-
DefKind::AssocExistential => "associated existential type",
103+
DefKind::AssocOpaqueTy => "associated opaque type",
104104
DefKind::Union => "union",
105105
DefKind::Trait => "trait",
106106
DefKind::ForeignTy => "foreign type",
@@ -118,9 +118,9 @@ impl DefKind {
118118
match *self {
119119
DefKind::AssocTy
120120
| DefKind::AssocConst
121-
| DefKind::AssocExistential
121+
| DefKind::AssocOpaqueTy
122122
| DefKind::Enum
123-
| DefKind::Existential => "an",
123+
| DefKind::OpaqueTy => "an",
124124
DefKind::Macro(macro_kind) => macro_kind.article(),
125125
_ => "a",
126126
}

src/librustc/hir/intravisit.rs

+2-2
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::Existential(ExistTy {
508+
ItemKind::OpaqueTy(OpaqueTy {
509509
ref generics,
510510
ref bounds,
511511
..
@@ -930,7 +930,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
930930
visitor.visit_id(impl_item.hir_id);
931931
visitor.visit_ty(ty);
932932
}
933-
ImplItemKind::Existential(ref bounds) => {
933+
ImplItemKind::OpaqueTy(ref bounds) => {
934934
visitor.visit_id(impl_item.hir_id);
935935
walk_list!(visitor, visit_param_bound, bounds);
936936
}

0 commit comments

Comments
 (0)