Get rid of hir::StructFieldKind
This commit is contained in:
parent
0400d929e8
commit
8b60b948d9
13 changed files with 78 additions and 117 deletions
|
@ -151,7 +151,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
|
||||||
self.create_def_with_parent(
|
self.create_def_with_parent(
|
||||||
Some(variant_def_index),
|
Some(variant_def_index),
|
||||||
field.node.id,
|
field.node.id,
|
||||||
DefPathData::Field(field.node.kind));
|
DefPathData::Field(field.node.name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
|
||||||
}
|
}
|
||||||
|
|
||||||
for field in struct_def.fields() {
|
for field in struct_def.fields() {
|
||||||
self.create_def(field.node.id, DefPathData::Field(field.node.kind));
|
self.create_def(field.node.id, DefPathData::Field(field.node.name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ItemTrait(_, _, ref bounds, _) => {
|
ItemTrait(_, _, ref bounds, _) => {
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
use middle::cstore::LOCAL_CRATE;
|
use middle::cstore::LOCAL_CRATE;
|
||||||
use middle::def_id::{DefId, DefIndex};
|
use middle::def_id::{DefId, DefIndex};
|
||||||
use rustc_data_structures::fnv::FnvHashMap;
|
use rustc_data_structures::fnv::FnvHashMap;
|
||||||
use rustc_front::hir;
|
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::parse::token::InternedString;
|
use syntax::parse::token::InternedString;
|
||||||
use util::nodemap::NodeMap;
|
use util::nodemap::NodeMap;
|
||||||
|
@ -84,8 +83,7 @@ pub enum DefPathData {
|
||||||
TypeParam(ast::Name),
|
TypeParam(ast::Name),
|
||||||
LifetimeDef(ast::Name),
|
LifetimeDef(ast::Name),
|
||||||
EnumVariant(ast::Name),
|
EnumVariant(ast::Name),
|
||||||
PositionalField,
|
Field(Option<ast::Name>),
|
||||||
Field(hir::StructFieldKind),
|
|
||||||
StructCtor, // implicit ctor for a tuple-like struct
|
StructCtor, // implicit ctor for a tuple-like struct
|
||||||
Initializer, // initializer for a const
|
Initializer, // initializer for a const
|
||||||
Binding(ast::Name), // pattern binding
|
Binding(ast::Name), // pattern binding
|
||||||
|
@ -186,16 +184,12 @@ impl DefPathData {
|
||||||
LifetimeDef(name) |
|
LifetimeDef(name) |
|
||||||
EnumVariant(name) |
|
EnumVariant(name) |
|
||||||
DetachedCrate(name) |
|
DetachedCrate(name) |
|
||||||
Binding(name) => {
|
Binding(name) |
|
||||||
|
Field(Some(name)) => {
|
||||||
name.as_str()
|
name.as_str()
|
||||||
}
|
}
|
||||||
|
|
||||||
Field(hir::StructFieldKind::NamedField(name, _)) => {
|
Field(None) => {
|
||||||
name.as_str()
|
|
||||||
}
|
|
||||||
|
|
||||||
PositionalField |
|
|
||||||
Field(hir::StructFieldKind::UnnamedField(_)) => {
|
|
||||||
InternedString::new("{{field}}")
|
InternedString::new("{{field}}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -221,10 +221,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> {
|
||||||
let has_extern_repr = self.struct_has_extern_repr;
|
let has_extern_repr = self.struct_has_extern_repr;
|
||||||
let inherited_pub_visibility = self.inherited_pub_visibility;
|
let inherited_pub_visibility = self.inherited_pub_visibility;
|
||||||
let live_fields = def.fields().iter().filter(|f| {
|
let live_fields = def.fields().iter().filter(|f| {
|
||||||
has_extern_repr || inherited_pub_visibility || match f.node.kind {
|
has_extern_repr || inherited_pub_visibility || f.node.vis == hir::Public
|
||||||
hir::NamedField(_, hir::Public) => true,
|
|
||||||
_ => false
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
self.live_symbols.extend(live_fields.map(|f| f.node.id));
|
self.live_symbols.extend(live_fields.map(|f| f.node.id));
|
||||||
|
|
||||||
|
@ -432,7 +429,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn should_warn_about_field(&mut self, node: &hir::StructField_) -> bool {
|
fn should_warn_about_field(&mut self, node: &hir::StructField_) -> bool {
|
||||||
let is_named = node.name().is_some();
|
let is_named = node.name.is_some();
|
||||||
let field_type = self.tcx.node_id_to_type(node.id);
|
let field_type = self.tcx.node_id_to_type(node.id);
|
||||||
let is_marker_field = match field_type.ty_to_def_id() {
|
let is_marker_field = match field_type.ty_to_def_id() {
|
||||||
Some(def_id) => self.tcx.lang_items.items().iter().any(|item| *item == Some(def_id)),
|
Some(def_id) => self.tcx.lang_items.items().iter().any(|item| *item == Some(def_id)),
|
||||||
|
@ -549,7 +546,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
|
||||||
fn visit_struct_field(&mut self, field: &hir::StructField) {
|
fn visit_struct_field(&mut self, field: &hir::StructField) {
|
||||||
if self.should_warn_about_field(&field.node) {
|
if self.should_warn_about_field(&field.node) {
|
||||||
self.warn_dead_code(field.node.id, field.span,
|
self.warn_dead_code(field.node.id, field.span,
|
||||||
field.node.name().unwrap(), "struct field");
|
field.node.name.unwrap(), "struct field");
|
||||||
}
|
}
|
||||||
|
|
||||||
intravisit::walk_struct_field(self, field);
|
intravisit::walk_struct_field(self, field);
|
||||||
|
|
|
@ -700,11 +700,12 @@ pub fn noop_fold_poly_trait_ref<T: Folder>(p: PolyTraitRef, fld: &mut T) -> Poly
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn noop_fold_struct_field<T: Folder>(f: StructField, fld: &mut T) -> StructField {
|
pub fn noop_fold_struct_field<T: Folder>(f: StructField, fld: &mut T) -> StructField {
|
||||||
let StructField {node: StructField_ {id, kind, ty, attrs}, span} = f;
|
let StructField {node: StructField_ {id, name, vis, ty, attrs}, span} = f;
|
||||||
Spanned {
|
Spanned {
|
||||||
node: StructField_ {
|
node: StructField_ {
|
||||||
id: fld.new_id(id),
|
id: fld.new_id(id),
|
||||||
kind: kind,
|
name: name,
|
||||||
|
vis: vis,
|
||||||
ty: fld.fold_ty(ty),
|
ty: fld.fold_ty(ty),
|
||||||
attrs: fold_attrs(attrs, fld),
|
attrs: fold_attrs(attrs, fld),
|
||||||
},
|
},
|
||||||
|
|
|
@ -24,7 +24,6 @@ pub use self::Mutability::*;
|
||||||
pub use self::PathListItem_::*;
|
pub use self::PathListItem_::*;
|
||||||
pub use self::PrimTy::*;
|
pub use self::PrimTy::*;
|
||||||
pub use self::Stmt_::*;
|
pub use self::Stmt_::*;
|
||||||
pub use self::StructFieldKind::*;
|
|
||||||
pub use self::TraitItem_::*;
|
pub use self::TraitItem_::*;
|
||||||
pub use self::Ty_::*;
|
pub use self::Ty_::*;
|
||||||
pub use self::TyParamBound::*;
|
pub use self::TyParamBound::*;
|
||||||
|
@ -1243,44 +1242,45 @@ impl Visibility {
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub struct StructField_ {
|
pub struct StructField_ {
|
||||||
pub kind: StructFieldKind,
|
pub name: Option<Name>,
|
||||||
|
pub vis: Visibility,
|
||||||
pub id: NodeId,
|
pub id: NodeId,
|
||||||
pub ty: P<Ty>,
|
pub ty: P<Ty>,
|
||||||
pub attrs: HirVec<Attribute>,
|
pub attrs: HirVec<Attribute>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StructField_ {
|
// impl StructField_ {
|
||||||
pub fn name(&self) -> Option<Name> {
|
// pub fn name(&self) -> Option<Name> {
|
||||||
match self.kind {
|
// match self.kind {
|
||||||
NamedField(name, _) => Some(name),
|
// NamedField(name, _) => Some(name),
|
||||||
UnnamedField(_) => None,
|
// UnnamedField(_) => None,
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
pub type StructField = Spanned<StructField_>;
|
pub type StructField = Spanned<StructField_>;
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
|
// #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
|
||||||
pub enum StructFieldKind {
|
// pub enum StructFieldKind {
|
||||||
NamedField(Name, Visibility),
|
// NamedField(Name, Visibility),
|
||||||
/// Element of a tuple-like struct
|
// /// Element of a tuple-like struct
|
||||||
UnnamedField(Visibility),
|
// UnnamedField(Visibility),
|
||||||
}
|
// }
|
||||||
|
|
||||||
impl StructFieldKind {
|
// impl StructFieldKind {
|
||||||
pub fn is_unnamed(&self) -> bool {
|
// pub fn is_unnamed(&self) -> bool {
|
||||||
match *self {
|
// match *self {
|
||||||
UnnamedField(..) => true,
|
// UnnamedField(..) => true,
|
||||||
NamedField(..) => false,
|
// NamedField(..) => false,
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
pub fn visibility(&self) -> Visibility {
|
// pub fn visibility(&self) -> Visibility {
|
||||||
match *self {
|
// match *self {
|
||||||
NamedField(_, vis) | UnnamedField(vis) => vis,
|
// NamedField(_, vis) | UnnamedField(vis) => vis,
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// Fields and Ids of enum variants and structs
|
/// Fields and Ids of enum variants and structs
|
||||||
///
|
///
|
||||||
|
|
|
@ -669,7 +669,7 @@ pub fn walk_struct_def<'v, V: Visitor<'v>>(visitor: &mut V, struct_definition: &
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn walk_struct_field<'v, V: Visitor<'v>>(visitor: &mut V, struct_field: &'v StructField) {
|
pub fn walk_struct_field<'v, V: Visitor<'v>>(visitor: &mut V, struct_field: &'v StructField) {
|
||||||
walk_opt_name(visitor, struct_field.span, struct_field.node.name());
|
walk_opt_name(visitor, struct_field.span, struct_field.node.name);
|
||||||
visitor.visit_ty(&struct_field.node.ty);
|
visitor.visit_ty(&struct_field.node.ty);
|
||||||
walk_list!(visitor, visit_attribute, &struct_field.node.attrs);
|
walk_list!(visitor, visit_attribute, &struct_field.node.attrs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -611,7 +611,8 @@ pub fn lower_struct_field(lctx: &LoweringContext, f: &StructField) -> hir::Struc
|
||||||
Spanned {
|
Spanned {
|
||||||
node: hir::StructField_ {
|
node: hir::StructField_ {
|
||||||
id: f.node.id,
|
id: f.node.id,
|
||||||
kind: lower_struct_field_kind(lctx, &f.node.kind),
|
name: f.node.ident().map(|ident| ident.name),
|
||||||
|
vis: lower_visibility(lctx, f.node.kind.visibility()),
|
||||||
ty: lower_ty(lctx, &f.node.ty),
|
ty: lower_ty(lctx, &f.node.ty),
|
||||||
attrs: lower_attrs(lctx, &f.node.attrs),
|
attrs: lower_attrs(lctx, &f.node.attrs),
|
||||||
},
|
},
|
||||||
|
@ -1589,15 +1590,6 @@ pub fn lower_binding_mode(lctx: &LoweringContext, b: &BindingMode) -> hir::Bindi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn lower_struct_field_kind(lctx: &LoweringContext,
|
|
||||||
s: &StructFieldKind)
|
|
||||||
-> hir::StructFieldKind {
|
|
||||||
match *s {
|
|
||||||
NamedField(ident, vis) => hir::NamedField(ident.name, lower_visibility(lctx, vis)),
|
|
||||||
UnnamedField(vis) => hir::UnnamedField(lower_visibility(lctx, vis)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn lower_unsafe_source(_lctx: &LoweringContext, u: UnsafeSource) -> hir::UnsafeSource {
|
pub fn lower_unsafe_source(_lctx: &LoweringContext, u: UnsafeSource) -> hir::UnsafeSource {
|
||||||
match u {
|
match u {
|
||||||
CompilerGenerated => hir::CompilerGenerated,
|
CompilerGenerated => hir::CompilerGenerated,
|
||||||
|
|
|
@ -915,14 +915,9 @@ impl<'a> State<'a> {
|
||||||
if struct_def.is_tuple() {
|
if struct_def.is_tuple() {
|
||||||
try!(self.popen());
|
try!(self.popen());
|
||||||
try!(self.commasep(Inconsistent, struct_def.fields(), |s, field| {
|
try!(self.commasep(Inconsistent, struct_def.fields(), |s, field| {
|
||||||
match field.node.kind {
|
try!(s.print_visibility(field.node.vis));
|
||||||
hir::NamedField(..) => panic!("unexpected named field"),
|
|
||||||
hir::UnnamedField(vis) => {
|
|
||||||
try!(s.print_visibility(vis));
|
|
||||||
try!(s.maybe_print_comment(field.span.lo));
|
try!(s.maybe_print_comment(field.span.lo));
|
||||||
s.print_type(&field.node.ty)
|
s.print_type(&field.node.ty)
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
try!(self.pclose());
|
try!(self.pclose());
|
||||||
}
|
}
|
||||||
|
@ -939,20 +934,15 @@ impl<'a> State<'a> {
|
||||||
try!(self.hardbreak_if_not_bol());
|
try!(self.hardbreak_if_not_bol());
|
||||||
|
|
||||||
for field in struct_def.fields() {
|
for field in struct_def.fields() {
|
||||||
match field.node.kind {
|
|
||||||
hir::UnnamedField(..) => panic!("unexpected unnamed field"),
|
|
||||||
hir::NamedField(name, visibility) => {
|
|
||||||
try!(self.hardbreak_if_not_bol());
|
try!(self.hardbreak_if_not_bol());
|
||||||
try!(self.maybe_print_comment(field.span.lo));
|
try!(self.maybe_print_comment(field.span.lo));
|
||||||
try!(self.print_outer_attributes(&field.node.attrs));
|
try!(self.print_outer_attributes(&field.node.attrs));
|
||||||
try!(self.print_visibility(visibility));
|
try!(self.print_visibility(field.node.vis));
|
||||||
try!(self.print_name(name));
|
try!(self.print_name(field.node.name.unwrap()));
|
||||||
try!(self.word_nbsp(":"));
|
try!(self.word_nbsp(":"));
|
||||||
try!(self.print_type(&field.node.ty));
|
try!(self.print_type(&field.node.ty));
|
||||||
try!(word(&mut self.s, ","));
|
try!(word(&mut self.s, ","));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self.bclose(span)
|
self.bclose(span)
|
||||||
}
|
}
|
||||||
|
|
|
@ -283,7 +283,7 @@ impl LateLintPass for NonSnakeCase {
|
||||||
fn check_struct_def(&mut self, cx: &LateContext, s: &hir::VariantData,
|
fn check_struct_def(&mut self, cx: &LateContext, s: &hir::VariantData,
|
||||||
_: ast::Name, _: &hir::Generics, _: ast::NodeId) {
|
_: ast::Name, _: &hir::Generics, _: ast::NodeId) {
|
||||||
for sf in s.fields() {
|
for sf in s.fields() {
|
||||||
if let hir::StructField_ { kind: hir::NamedField(name, _), .. } = sf.node {
|
if let Some(name) = sf.node.name {
|
||||||
self.check_snake_case(cx, "structure field", &name.as_str(),
|
self.check_snake_case(cx, "structure field", &name.as_str(),
|
||||||
Some(sf.span));
|
Some(sf.span));
|
||||||
}
|
}
|
||||||
|
|
|
@ -428,8 +428,8 @@ impl LateLintPass for MissingDoc {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_struct_field(&mut self, cx: &LateContext, sf: &hir::StructField) {
|
fn check_struct_field(&mut self, cx: &LateContext, sf: &hir::StructField) {
|
||||||
if let hir::NamedField(_, vis) = sf.node.kind {
|
if sf.node.name.is_some() {
|
||||||
if vis == hir::Public || self.in_variant {
|
if sf.node.vis == hir::Public || self.in_variant {
|
||||||
let cur_struct_def = *self.struct_def_stack.last()
|
let cur_struct_def = *self.struct_def_stack.last()
|
||||||
.expect("empty struct_def_stack");
|
.expect("empty struct_def_stack");
|
||||||
self.check_missing_docs_attrs(cx, Some(cur_struct_def),
|
self.check_missing_docs_attrs(cx, Some(cur_struct_def),
|
||||||
|
|
|
@ -288,7 +288,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
|
||||||
self.update(def.id(), item_level);
|
self.update(def.id(), item_level);
|
||||||
}
|
}
|
||||||
for field in def.fields() {
|
for field in def.fields() {
|
||||||
if field.node.kind.visibility() == hir::Public {
|
if field.node.vis == hir::Public {
|
||||||
self.update(field.node.id, item_level);
|
self.update(field.node.id, item_level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1178,7 +1178,7 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
|
||||||
hir::ItemEnum(ref def, _) => {
|
hir::ItemEnum(ref def, _) => {
|
||||||
for variant in &def.variants {
|
for variant in &def.variants {
|
||||||
for field in variant.node.data.fields() {
|
for field in variant.node.data.fields() {
|
||||||
check_inherited(field.span, field.node.kind.visibility(),
|
check_inherited(field.span, field.vis,
|
||||||
"visibility qualifiers have no effect on variant fields");
|
"visibility qualifiers have no effect on variant fields");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1514,10 +1514,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx>
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_struct_field(&mut self, s: &hir::StructField) {
|
fn visit_struct_field(&mut self, s: &hir::StructField) {
|
||||||
let vis = match s.node.kind {
|
if s.node.vis == hir::Public || self.in_variant {
|
||||||
hir::NamedField(_, vis) | hir::UnnamedField(vis) => vis
|
|
||||||
};
|
|
||||||
if vis == hir::Public || self.in_variant {
|
|
||||||
intravisit::walk_struct_field(self, s);
|
intravisit::walk_struct_field(self, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1728,7 +1725,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivateItemsInPublicInterfacesVisitor<'a, 'tc
|
||||||
if item.vis == hir::Public {
|
if item.vis == hir::Public {
|
||||||
check.visit_generics(generics);
|
check.visit_generics(generics);
|
||||||
for field in struct_def.fields() {
|
for field in struct_def.fields() {
|
||||||
if field.node.kind.visibility() == hir::Public {
|
if field.node.vis == hir::Public {
|
||||||
check.visit_struct_field(field);
|
check.visit_struct_field(field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,9 +41,7 @@ use rustc_front::hir::{ForeignItem, ForeignItemFn, ForeignItemStatic};
|
||||||
use rustc_front::hir::{Item, ItemConst, ItemEnum, ItemExternCrate, ItemFn};
|
use rustc_front::hir::{Item, ItemConst, ItemEnum, ItemExternCrate, ItemFn};
|
||||||
use rustc_front::hir::{ItemForeignMod, ItemImpl, ItemMod, ItemStatic, ItemDefaultImpl};
|
use rustc_front::hir::{ItemForeignMod, ItemImpl, ItemMod, ItemStatic, ItemDefaultImpl};
|
||||||
use rustc_front::hir::{ItemStruct, ItemTrait, ItemTy, ItemUse};
|
use rustc_front::hir::{ItemStruct, ItemTrait, ItemTy, ItemUse};
|
||||||
use rustc_front::hir::{NamedField, PathListIdent, PathListMod};
|
use rustc_front::hir::{PathListIdent, PathListMod, StmtDecl};
|
||||||
use rustc_front::hir::StmtDecl;
|
|
||||||
use rustc_front::hir::UnnamedField;
|
|
||||||
use rustc_front::hir::{Variant, ViewPathGlob, ViewPathList, ViewPathSimple};
|
use rustc_front::hir::{Variant, ViewPathGlob, ViewPathList, ViewPathSimple};
|
||||||
use rustc_front::hir::Visibility;
|
use rustc_front::hir::Visibility;
|
||||||
use rustc_front::intravisit::{self, Visitor};
|
use rustc_front::intravisit::{self, Visitor};
|
||||||
|
@ -384,12 +382,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
||||||
// Record the def ID and fields of this struct.
|
// Record the def ID and fields of this struct.
|
||||||
let named_fields = struct_def.fields()
|
let named_fields = struct_def.fields()
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|f| {
|
.filter_map(|f| f.node.name)
|
||||||
match f.node.kind {
|
|
||||||
NamedField(name, _) => Some(name),
|
|
||||||
UnnamedField(_) => None,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect();
|
.collect();
|
||||||
let item_def_id = self.ast_map.local_def_id(item.id);
|
let item_def_id = self.ast_map.local_def_id(item.id);
|
||||||
self.structs.insert(item_def_id, named_fields);
|
self.structs.insert(item_def_id, named_fields);
|
||||||
|
|
|
@ -978,8 +978,7 @@ fn convert_struct_variant<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||||
let mut seen_fields: FnvHashMap<ast::Name, Span> = FnvHashMap();
|
let mut seen_fields: FnvHashMap<ast::Name, Span> = FnvHashMap();
|
||||||
let fields = def.fields().iter().map(|f| {
|
let fields = def.fields().iter().map(|f| {
|
||||||
let fid = tcx.map.local_def_id(f.node.id);
|
let fid = tcx.map.local_def_id(f.node.id);
|
||||||
match f.node.kind {
|
if let Some(name) = f.node.name {
|
||||||
hir::NamedField(name, vis) => {
|
|
||||||
let dup_span = seen_fields.get(&name).cloned();
|
let dup_span = seen_fields.get(&name).cloned();
|
||||||
if let Some(prev_span) = dup_span {
|
if let Some(prev_span) = dup_span {
|
||||||
let mut err = struct_span_err!(tcx.sess, f.span, E0124,
|
let mut err = struct_span_err!(tcx.sess, f.span, E0124,
|
||||||
|
@ -991,11 +990,9 @@ fn convert_struct_variant<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||||
seen_fields.insert(name, f.span);
|
seen_fields.insert(name, f.span);
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::FieldDefData::new(fid, name, vis)
|
ty::FieldDefData::new(fid, name, f.node.vis)
|
||||||
},
|
} else {
|
||||||
hir::UnnamedField(vis) => {
|
ty::FieldDefData::new(fid, special_idents::unnamed_field.name, f.node.vis)
|
||||||
ty::FieldDefData::new(fid, special_idents::unnamed_field.name, vis)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}).collect();
|
}).collect();
|
||||||
ty::VariantDefData {
|
ty::VariantDefData {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue