Skip to content

Commit

Permalink
Auto merge of #63180 - varkor:trait-alias-impl-trait, r=Centril
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Aug 3, 2019
2 parents d9bd4b2 + fbd7e0c commit d727071
Show file tree
Hide file tree
Showing 202 changed files with 1,050 additions and 1,033 deletions.
6 changes: 3 additions & 3 deletions src/librustc/hir/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub(crate) enum Target {
ForeignMod,
GlobalAsm,
Ty,
Existential,
OpaqueTy,
Enum,
Struct,
Union,
Expand All @@ -51,7 +51,7 @@ impl Display for Target {
Target::ForeignMod => "foreign module",
Target::GlobalAsm => "global asm",
Target::Ty => "type alias",
Target::Existential => "existential type",
Target::OpaqueTy => "opaque type",
Target::Enum => "enum",
Target::Struct => "struct",
Target::Union => "union",
Expand All @@ -76,7 +76,7 @@ impl Target {
hir::ItemKind::ForeignMod(..) => Target::ForeignMod,
hir::ItemKind::GlobalAsm(..) => Target::GlobalAsm,
hir::ItemKind::Ty(..) => Target::Ty,
hir::ItemKind::Existential(..) => Target::Existential,
hir::ItemKind::OpaqueTy(..) => Target::OpaqueTy,
hir::ItemKind::Enum(..) => Target::Enum,
hir::ItemKind::Struct(..) => Target::Struct,
hir::ItemKind::Union(..) => Target::Union,
Expand Down
16 changes: 8 additions & 8 deletions src/librustc/hir/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ pub enum DefKind {
/// Refers to the variant itself, `DefKind::Ctor` refers to its constructor if it exists.
Variant,
Trait,
/// `existential type Foo: Bar;`
Existential,
/// `type Foo = impl Bar;`
OpaqueTy,
/// `type Foo = Bar;`
TyAlias,
ForeignTy,
TraitAlias,
AssocTy,
/// `existential type Foo: Bar;`
AssocExistential,
/// `type Foo = impl Bar;`
AssocOpaqueTy,
TyParam,

// Value namespace
Expand Down Expand Up @@ -96,11 +96,11 @@ impl DefKind {
DefKind::Ctor(CtorOf::Struct, CtorKind::Const) => "unit struct",
DefKind::Ctor(CtorOf::Struct, CtorKind::Fictive) =>
bug!("impossible struct constructor"),
DefKind::Existential => "existential type",
DefKind::OpaqueTy => "opaque type",
DefKind::TyAlias => "type alias",
DefKind::TraitAlias => "trait alias",
DefKind::AssocTy => "associated type",
DefKind::AssocExistential => "associated existential type",
DefKind::AssocOpaqueTy => "associated opaque type",
DefKind::Union => "union",
DefKind::Trait => "trait",
DefKind::ForeignTy => "foreign type",
Expand All @@ -118,9 +118,9 @@ impl DefKind {
match *self {
DefKind::AssocTy
| DefKind::AssocConst
| DefKind::AssocExistential
| DefKind::AssocOpaqueTy
| DefKind::Enum
| DefKind::Existential => "an",
| DefKind::OpaqueTy => "an",
DefKind::Macro(macro_kind) => macro_kind.article(),
_ => "a",
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
visitor.visit_ty(ty);
visitor.visit_generics(generics)
}
ItemKind::Existential(ExistTy {
ItemKind::OpaqueTy(OpaqueTy {
ref generics,
ref bounds,
..
Expand Down Expand Up @@ -930,7 +930,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
visitor.visit_id(impl_item.hir_id);
visitor.visit_ty(ty);
}
ImplItemKind::Existential(ref bounds) => {
ImplItemKind::OpaqueTy(ref bounds) => {
visitor.visit_id(impl_item.hir_id);
walk_list!(visitor, visit_param_bound, bounds);
}
Expand Down

0 comments on commit d727071

Please sign in to comment.