diff options
| author | Oliver Schneider <github35764891676564198441@oli-obk.de> | 2018-07-03 19:38:14 +0200 |
|---|---|---|
| committer | Oliver Schneider <github35764891676564198441@oli-obk.de> | 2018-07-18 10:53:08 +0200 |
| commit | 53d2ebb0adbe677a811ae130523ebceb285a8029 (patch) | |
| tree | aa5bf290ab3240ee1028359cef335f22dc1a2cdb /src/librustc_resolve | |
| parent | 1c84d8187395b641616649a0f16f15a78ea8bbce (diff) | |
| download | rust-53d2ebb0adbe677a811ae130523ebceb285a8029.tar.gz rust-53d2ebb0adbe677a811ae130523ebceb285a8029.zip | |
Implement existential types
Diffstat (limited to 'src/librustc_resolve')
| -rw-r--r-- | src/librustc_resolve/build_reduced_graph.rs | 5 | ||||
| -rw-r--r-- | src/librustc_resolve/lib.rs | 16 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 29312912a24..e00919547fc 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -361,6 +361,11 @@ impl<'a> Resolver<'a> { self.define(parent, ident, TypeNS, (def, vis, sp, expansion)); } + ItemKind::Existential(_, _) => { + let def = Def::Existential(self.definitions.local_def_id(item.id)); + self.define(parent, ident, TypeNS, (def, vis, sp, expansion)); + } + ItemKind::Enum(ref enum_definition, _) => { let def = Def::Enum(self.definitions.local_def_id(item.id)); let module_kind = ModuleKind::Def(def, ident.name); diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index f388b911feb..617ae4b787f 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -207,7 +207,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver, Def::AssociatedTy(..) | Def::PrimTy(..) | Def::Fn(..) | Def::Const(..) | Def::Static(..) | Def::StructCtor(..) | Def::VariantCtor(..) | Def::Method(..) | Def::AssociatedConst(..) | Def::Local(..) | Def::Upvar(..) | Def::Label(..) | - Def::Existential(..) | + Def::Existential(..) | Def::AssociatedExistential(..) | Def::Macro(..) | Def::GlobalAsm(..) | Def::Err => bug!("TypeParametersFromOuterFunction should only be used with Def::SelfTy or \ Def::TyParam") @@ -535,6 +535,7 @@ impl<'a> PathSource<'a> { Def::Struct(..) | Def::Union(..) | Def::Enum(..) | Def::Trait(..) | Def::TyAlias(..) | Def::AssociatedTy(..) | Def::PrimTy(..) | Def::TyParam(..) | Def::SelfTy(..) | + Def::Existential(..) | Def::TyForeign(..) => true, _ => false, }, @@ -2148,6 +2149,7 @@ impl<'a> Resolver<'a> { match item.node { ItemKind::Enum(_, ref generics) | ItemKind::Ty(_, ref generics) | + ItemKind::Existential(_, ref generics) | ItemKind::Struct(_, ref generics) | ItemKind::Union(_, ref generics) | ItemKind::Fn(_, _, ref generics, _) => { @@ -2486,6 +2488,18 @@ impl<'a> Resolver<'a> { this.visit_ty(ty); } + ImplItemKind::Existential(ref bounds) => { + // If this is a trait impl, ensure the type + // exists in trait + this.check_trait_item(impl_item.ident, + TypeNS, + impl_item.span, + |n, s| TypeNotMemberOfTrait(n, s)); + + for bound in bounds { + this.visit_param_bound(bound); + } + } ImplItemKind::Macro(_) => panic!("unexpanded macro in resolve!"), } |
