diff options
| author | varkor <github@varkor.com> | 2019-08-01 00:41:54 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2019-08-02 02:44:36 +0100 |
| commit | c28ce3e4ca021aea5ca25227c0e46d9b47095db6 (patch) | |
| tree | baae77321295ecfd9077bc52342ea5ba78cc9eec /src/libsyntax | |
| parent | fc48541ab19cdd68a2b0228004e64d3cbb7a1ecb (diff) | |
| download | rust-c28ce3e4ca021aea5ca25227c0e46d9b47095db6.tar.gz rust-c28ce3e4ca021aea5ca25227c0e46d9b47095db6.zip | |
Replace "existential" by "opaque"
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 14 | ||||
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/mut_visit.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 18 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 14 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 4 |
6 files changed, 31 insertions, 31 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index b633705a65f..38454d7c3b7 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1485,6 +1485,7 @@ pub enum TraitItemKind { Macro(Mac), } +/// Represents anything within an `impl` block. #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct ImplItem { pub id: NodeId, @@ -1499,12 +1500,13 @@ pub struct ImplItem { pub tokens: Option<TokenStream>, } +/// Represents various kinds of content within an `impl`. #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub enum ImplItemKind { Const(P<Ty>, P<Expr>), Method(MethodSig, P<Block>), Type(P<Ty>), - Existential(GenericBounds), + OpaqueTy(GenericBounds), Macro(Mac), } @@ -1707,7 +1709,7 @@ pub enum TyKind { /// /// The `NodeId` exists to prevent lowering from having to /// generate `NodeId`s on the fly, which would complicate - /// the generation of `existential type` items significantly. + /// the generation of opaque `type Foo = impl Trait` items significantly. ImplTrait(NodeId, GenericBounds), /// No-op; kept solely so that we can pretty-print faithfully. Paren(P<Ty>), @@ -2331,10 +2333,10 @@ pub enum ItemKind { /// /// E.g., `type Foo = Bar<u8>;`. Ty(P<Ty>, Generics), - /// An existential type declaration (`existential type`). + /// An opaque `impl Trait` type alias. /// - /// E.g., `existential type Foo: Bar + Boo;`. - Existential(GenericBounds, Generics), + /// E.g., `type Foo = impl Bar + Boo;`. + OpaqueTy(GenericBounds, Generics), /// An enum definition (`enum` or `pub enum`). /// /// E.g., `enum Foo<A, B> { C<A>, D<B> }`. @@ -2388,7 +2390,7 @@ impl ItemKind { ItemKind::ForeignMod(..) => "foreign module", ItemKind::GlobalAsm(..) => "global asm", ItemKind::Ty(..) => "type alias", - ItemKind::Existential(..) => "existential type", + ItemKind::OpaqueTy(..) => "opaque type", ItemKind::Enum(..) => "enum", ItemKind::Struct(..) => "struct", ItemKind::Union(..) => "union", diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index dd298ce84fa..33d10b269e1 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -2017,12 +2017,12 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { gate_feature_post!(&self, decl_macro, i.span, msg); } - ast::ItemKind::Existential(..) => { + ast::ItemKind::OpaqueTy(..) => { gate_feature_post!( &self, type_alias_impl_trait, i.span, - "existential types are unstable" + "`impl Trait` in type aliases is unstable" ); } @@ -2246,12 +2246,12 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { match ii.node { ast::ImplItemKind::Method(..) => {} - ast::ImplItemKind::Existential(..) => { + ast::ImplItemKind::OpaqueTy(..) => { gate_feature_post!( &self, type_alias_impl_trait, ii.span, - "existential types are unstable" + "`impl Trait` in type aliases is unstable" ); } ast::ImplItemKind::Type(_) => { diff --git a/src/libsyntax/mut_visit.rs b/src/libsyntax/mut_visit.rs index 7b328e817bf..a0e24b42e24 100644 --- a/src/libsyntax/mut_visit.rs +++ b/src/libsyntax/mut_visit.rs @@ -848,7 +848,7 @@ pub fn noop_visit_item_kind<T: MutVisitor>(kind: &mut ItemKind, vis: &mut T) { vis.visit_ty(ty); vis.visit_generics(generics); } - ItemKind::Existential(bounds, generics) => { + ItemKind::OpaqueTy(bounds, generics) => { visit_bounds(bounds, vis); vis.visit_generics(generics); } @@ -931,7 +931,7 @@ pub fn noop_flat_map_impl_item<T: MutVisitor>(mut item: ImplItem, visitor: &mut visitor.visit_block(body); } ImplItemKind::Type(ty) => visitor.visit_ty(ty), - ImplItemKind::Existential(bounds) => visit_bounds(bounds, visitor), + ImplItemKind::OpaqueTy(bounds) => visit_bounds(bounds, visitor), ImplItemKind::Macro(mac) => visitor.visit_mac(mac), } visitor.visit_span(span); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index ec95a2090d6..89e66e71b25 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -62,12 +62,12 @@ use std::path::{self, Path, PathBuf}; use std::slice; #[derive(Debug)] -/// Whether the type alias or associated type is a concrete type or an existential type +/// Whether the type alias or associated type is a concrete type or an opaque type pub enum AliasKind { /// Just a new name for the same type Weak(P<Ty>), /// Only trait impls of the type will be usable, not the actual type itself - Existential(GenericBounds), + OpaqueTy(GenericBounds), } bitflags::bitflags! { @@ -4265,11 +4265,6 @@ impl<'a> Parser<'a> { self.token.is_keyword(kw::Crate) && self.look_ahead(1, |t| t != &token::ModSep) } - fn is_existential_type_decl(&self) -> bool { - self.token.is_keyword(kw::Existential) && - self.is_keyword_ahead(1, &[kw::Type]) - } - fn is_auto_trait_item(&self) -> bool { // auto trait (self.token.is_keyword(kw::Auto) && @@ -4367,7 +4362,6 @@ impl<'a> Parser<'a> { !self.token.is_qpath_start() && !self.is_union_item() && !self.is_crate_vis() && - !self.is_existential_type_decl() && !self.is_auto_trait_item() && !self.is_async_fn() { let path = self.parse_path(PathStyle::Expr)?; @@ -5686,7 +5680,7 @@ impl<'a> Parser<'a> { let (name, alias, generics) = type_?; let kind = match alias { AliasKind::Weak(typ) => ast::ImplItemKind::Type(typ), - AliasKind::Existential(bounds) => ast::ImplItemKind::Existential(bounds), + AliasKind::OpaqueTy(bounds) => ast::ImplItemKind::OpaqueTy(bounds), }; (name, kind, generics) } else if self.is_const_item() { @@ -6817,7 +6811,7 @@ impl<'a> Parser<'a> { } } - /// Parses a type alias or existential type. + /// Parses a type alias or opaque type. fn parse_type_alias(&mut self) -> PResult<'a, (Ident, AliasKind, ast::Generics)> { let ident = self.parse_ident()?; let mut tps = self.parse_generics()?; @@ -6826,7 +6820,7 @@ impl<'a> Parser<'a> { let alias = if self.check_keyword(kw::Impl) { self.bump(); let bounds = self.parse_generic_bounds(Some(self.prev_span))?; - AliasKind::Existential(bounds) + AliasKind::OpaqueTy(bounds) } else { let ty = self.parse_ty()?; AliasKind::Weak(ty) @@ -7249,7 +7243,7 @@ impl<'a> Parser<'a> { // TYPE ITEM let item_ = match alias { AliasKind::Weak(ty) => ItemKind::Ty(ty, generics), - AliasKind::Existential(bounds) => ItemKind::Existential(bounds, generics), + AliasKind::OpaqueTy(bounds) => ItemKind::OpaqueTy(bounds, generics), }; let prev_span = self.prev_span; let item = self.mk_item(lo.to(prev_span), diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 88ff6ee9071..fec149f97a7 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1238,9 +1238,10 @@ impl<'a> State<'a> { self.s.word(";"); self.end(); // end the outer ibox } - ast::ItemKind::Existential(ref bounds, ref generics) => { - self.head(visibility_qualified(&item.vis, "existential type")); + ast::ItemKind::OpaqueTy(ref bounds, ref generics) => { + self.head(visibility_qualified(&item.vis, "type")); self.print_ident(item.ident); + self.word_space("= impl"); self.print_generic_params(&generics.params); self.end(); // end the inner ibox @@ -1598,9 +1599,12 @@ impl<'a> State<'a> { ast::ImplItemKind::Type(ref ty) => { self.print_associated_type(ii.ident, None, Some(ty)); } - ast::ImplItemKind::Existential(ref bounds) => { - self.word_space("existential"); - self.print_associated_type(ii.ident, Some(bounds), None); + ast::ImplItemKind::OpaqueTy(ref bounds) => { + self.word_space("type"); + self.print_ident(ii.ident); + self.word_space("= impl"); + self.print_type_bounds(":", bounds); + self.s.word(";"); } ast::ImplItemKind::Macro(ref mac) => { self.print_mac(mac); diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 5fee8ed81ab..67226c2177f 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -259,7 +259,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) { visitor.visit_ty(typ); visitor.visit_generics(generics) } - ItemKind::Existential(ref bounds, ref generics) => { + ItemKind::OpaqueTy(ref bounds, ref generics) => { walk_list!(visitor, visit_param_bound, bounds); visitor.visit_generics(generics) } @@ -619,7 +619,7 @@ pub fn walk_impl_item<'a, V: Visitor<'a>>(visitor: &mut V, impl_item: &'a ImplIt ImplItemKind::Type(ref ty) => { visitor.visit_ty(ty); } - ImplItemKind::Existential(ref bounds) => { + ImplItemKind::OpaqueTy(ref bounds) => { walk_list!(visitor, visit_param_bound, bounds); } ImplItemKind::Macro(ref mac) => { |
