-> Option<DefIndex>;
fn def_key(&self, def: DefId) -> hir_map::DefKey;
fn relative_def_path(&self, def: DefId) -> Option<hir_map::DefPath>;
+ fn variant_kind(&self, def_id: DefId) -> Option<ty::VariantKind>;
fn struct_ctor_def_id(&self, struct_def_id: DefId) -> Option<DefId>;
fn struct_field_names(&self, def: DefId) -> Vec<ast::Name>;
fn item_children(&self, did: DefId) -> Vec<def::Export>;
fn stability(&self, def: DefId) -> Option<attr::Stability> { bug!("stability") }
fn deprecation(&self, def: DefId) -> Option<attr::Deprecation> { bug!("deprecation") }
fn visibility(&self, def: DefId) -> ty::Visibility { bug!("visibility") }
- fn closure_kind(&self, def_id: DefId) -> ty::ClosureKind { bug!("closure_kind") }
+ fn closure_kind(&self, def_id: DefId) -> ty::ClosureKind { bug!("closure_kind") }
fn closure_ty<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
-> ty::ClosureTy<'tcx> { bug!("closure_ty") }
fn item_variances(&self, def: DefId) -> Vec<ty::Variance> { bug!("item_variances") }
fn relative_def_path(&self, def: DefId) -> Option<hir_map::DefPath> {
bug!("relative_def_path")
}
+ fn variant_kind(&self, def_id: DefId) -> Option<ty::VariantKind> { bug!("variant_kind") }
fn struct_ctor_def_id(&self, struct_def_id: DefId) -> Option<DefId>
{ bug!("struct_ctor_def_id") }
fn struct_field_names(&self, def: DefId) -> Vec<ast::Name> { bug!("struct_field_names") }
self.get_crate_data(def.krate).def_path(def.index)
}
+ fn variant_kind(&self, def_id: DefId) -> Option<ty::VariantKind>
+ {
+ self.dep_graph.read(DepNode::MetaData(def_id));
+ self.get_crate_data(def_id.krate).get_variant_kind(def_id.index)
+ }
+
fn struct_ctor_def_id(&self, struct_def_id: DefId) -> Option<DefId>
{
self.dep_graph.read(DepNode::MetaData(struct_def_id));
self.entry(id).variances.decode(self).collect()
}
+ pub fn get_variant_kind(&self, node_id: DefIndex) -> Option<ty::VariantKind> {
+ match self.entry(node_id).kind {
+ EntryKind::Struct(data) |
+ EntryKind::Union(data) |
+ EntryKind::Variant(data) => Some(data.decode(self).kind),
+ _ => None
+ }
+ }
+
pub fn get_struct_ctor_def_id(&self, node_id: DefIndex) -> Option<DefId> {
match self.entry(node_id).kind {
EntryKind::Struct(data) => {
let module = self.new_module(parent_link, Some(def), None);
let _ = self.try_define(parent, name, TypeNS, (module, DUMMY_SP, vis));
}
- Def::Variant(..) => {
+ Def::Variant(variant_id) => {
debug!("(building reduced graph for external crate) building variant {}", name);
// Variants are always treated as importable to allow them to be glob used.
// All variants are defined in both type and value namespaces as future-proofing.
let _ = self.try_define(parent, name, TypeNS, (def, DUMMY_SP, vis));
let _ = self.try_define(parent, name, ValueNS, (def, DUMMY_SP, vis));
+ if self.session.cstore.variant_kind(variant_id) == Some(ty::VariantKind::Struct) {
+ // Not adding fields for variants as they are not accessed with a self receiver
+ self.structs.insert(variant_id, Vec::new());
+ }
}
Def::Fn(..) |
Def::Static(..) |
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub enum Homura {
+ Madoka { age: u32 }
+}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// aux-build:issue_19452_aux.rs
+extern crate issue_19452_aux;
+
enum Homura {
Madoka { age: u32 }
}
let homura = Homura::Madoka;
//~^ ERROR uses it like a function
//~| struct called like a function
+
+ let homura = issue_19452_aux::Homura::Madoka;
+ //~^ ERROR uses it like a function
+ //~| struct called like a function
}