Skip to content

Commit 801edb2

Browse files
committed
---
yaml --- r: 276866 b: refs/heads/try c: 552af51 h: refs/heads/master
1 parent 5c5225e commit 801edb2

File tree

13 files changed

+84
-158
lines changed

13 files changed

+84
-158
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 6dbb0e86aec11050480beb76eade6fb805010ba7
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
4-
refs/heads/try: e8a8dfb056fb3654bacd6aaa6acbc4536358df23
4+
refs/heads/try: 552af51ffb9f4ae08a7ee3bf27b0e8309006ca6f
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/librustc/hir/lowering.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -621,12 +621,11 @@ pub fn lower_struct_field(lctx: &LoweringContext,
621621
-> hir::StructField {
622622
hir::StructField {
623623
span: f.span,
624-
id: f.node.id,
625-
name: f.node.ident().map(|ident| ident.name)
626-
.unwrap_or(token::intern(&index.to_string())),
627-
vis: lower_visibility(lctx, f.node.kind.visibility()),
628-
ty: lower_ty(lctx, &f.node.ty),
629-
attrs: lower_attrs(lctx, &f.node.attrs),
624+
id: f.id,
625+
name: f.ident.map(|ident| ident.name).unwrap_or(token::intern(&index.to_string())),
626+
vis: lower_visibility(lctx, &f.vis),
627+
ty: lower_ty(lctx, &f.ty),
628+
attrs: lower_attrs(lctx, &f.attrs),
630629
}
631630
}
632631

branches/try/src/librustc/lint/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ impl<'a, 'v> ast_visit::Visitor<'v> for EarlyContext<'a> {
966966
}
967967

968968
fn visit_struct_field(&mut self, s: &ast::StructField) {
969-
self.with_lint_attrs(&s.node.attrs, |cx| {
969+
self.with_lint_attrs(&s.attrs, |cx| {
970970
run_lints!(cx, check_struct_field, early_passes, s);
971971
ast_visit::walk_struct_field(cx, s);
972972
})

branches/try/src/librustc_save_analysis/dump_visitor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ where D: Dump
563563
// fields
564564
for field in def.fields() {
565565
self.process_struct_field_def(field, item.id);
566-
self.visit_ty(&field.node.ty);
566+
self.visit_ty(&field.ty);
567567
}
568568

569569
self.process_generic_params(ty_params, item.span, &qualname, item.id);
@@ -624,7 +624,7 @@ where D: Dump
624624

625625
for field in variant.node.data.fields() {
626626
self.process_struct_field_def(field, variant.node.data.id());
627-
self.visit_ty(&field.node.ty);
627+
self.visit_ty(&field.ty);
628628
}
629629
}
630630
self.process_generic_params(ty_params, item.span, &enum_data.qualname, enum_data.id);

branches/try/src/librustc_save_analysis/lib.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -244,23 +244,22 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
244244

245245
pub fn get_field_data(&self, field: &ast::StructField,
246246
scope: NodeId) -> Option<VariableData> {
247-
match field.node.kind {
248-
ast::NamedField(ident, _) => {
249-
let qualname = format!("::{}::{}", self.tcx.node_path_str(scope), ident);
250-
let typ = self.tcx.node_types().get(&field.node.id).unwrap().to_string();
251-
let sub_span = self.span_utils.sub_span_before_token(field.span, token::Colon);
252-
filter!(self.span_utils, sub_span, field.span, None);
253-
Some(VariableData {
254-
id: field.node.id,
255-
name: ident.to_string(),
256-
qualname: qualname,
257-
span: sub_span.unwrap(),
258-
scope: scope,
259-
value: "".to_owned(),
260-
type_value: typ,
261-
})
262-
}
263-
_ => None,
247+
if let Some(ident) = field.ident {
248+
let qualname = format!("::{}::{}", self.tcx.node_path_str(scope), ident);
249+
let typ = self.tcx.node_types().get(&field.id).unwrap().to_string();
250+
let sub_span = self.span_utils.sub_span_before_token(field.span, token::Colon);
251+
filter!(self.span_utils, sub_span, field.span, None);
252+
Some(VariableData {
253+
id: field.id,
254+
name: ident.to_string(),
255+
qualname: qualname,
256+
span: sub_span.unwrap(),
257+
scope: scope,
258+
value: "".to_owned(),
259+
type_value: typ,
260+
})
261+
} else {
262+
None
264263
}
265264
}
266265

branches/try/src/libsyntax/ast.rs

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// The Rust abstract syntax tree.
1212

13-
pub use self::StructFieldKind::*;
1413
pub use self::TyParamBound::*;
1514
pub use self::UnsafeSource::*;
1615
pub use self::ViewPath_::*;
@@ -1894,46 +1893,15 @@ pub enum Visibility {
18941893
}
18951894

18961895
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1897-
pub struct StructField_ {
1898-
pub kind: StructFieldKind,
1896+
pub struct StructField {
1897+
pub span: Span,
1898+
pub ident: Option<Ident>,
1899+
pub vis: Visibility,
18991900
pub id: NodeId,
19001901
pub ty: P<Ty>,
19011902
pub attrs: Vec<Attribute>,
19021903
}
19031904

1904-
impl StructField_ {
1905-
pub fn ident(&self) -> Option<Ident> {
1906-
match self.kind {
1907-
NamedField(ref ident, _) => Some(ident.clone()),
1908-
UnnamedField(_) => None
1909-
}
1910-
}
1911-
}
1912-
1913-
pub type StructField = Spanned<StructField_>;
1914-
1915-
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1916-
pub enum StructFieldKind {
1917-
NamedField(Ident, Visibility),
1918-
/// Element of a tuple-like struct
1919-
UnnamedField(Visibility),
1920-
}
1921-
1922-
impl StructFieldKind {
1923-
pub fn is_unnamed(&self) -> bool {
1924-
match *self {
1925-
UnnamedField(..) => true,
1926-
NamedField(..) => false,
1927-
}
1928-
}
1929-
1930-
pub fn visibility(&self) -> &Visibility {
1931-
match *self {
1932-
NamedField(_, ref vis) | UnnamedField(ref vis) => vis
1933-
}
1934-
}
1935-
}
1936-
19371905
/// Fields and Ids of enum variants and structs
19381906
///
19391907
/// For enum variants: `NodeId` represents both an Id of the variant itself (relevant for all

branches/try/src/libsyntax/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,12 @@ fn fold_struct<F>(cx: &mut Context<F>, vdata: ast::VariantData) -> ast::VariantD
180180
match vdata {
181181
ast::VariantData::Struct(fields, id) => {
182182
ast::VariantData::Struct(fields.into_iter().filter(|m| {
183-
(cx.in_cfg)(&m.node.attrs)
183+
(cx.in_cfg)(&m.attrs)
184184
}).collect(), id)
185185
}
186186
ast::VariantData::Tuple(fields, id) => {
187187
ast::VariantData::Tuple(fields.into_iter().filter(|m| {
188-
(cx.in_cfg)(&m.node.attrs)
188+
(cx.in_cfg)(&m.attrs)
189189
}).collect(), id)
190190
}
191191
ast::VariantData::Unit(id) => ast::VariantData::Unit(id)
@@ -434,7 +434,7 @@ impl<'v, 'a, 'b> visit::Visitor<'v> for StmtExprAttrFeatureVisitor<'a, 'b> {
434434
}
435435

436436
fn visit_struct_field(&mut self, s: &'v ast::StructField) {
437-
if node_survives_cfg(&s.node.attrs, self.config) {
437+
if node_survives_cfg(&s.attrs, self.config) {
438438
visit::walk_struct_field(self, s);
439439
}
440440
}

branches/try/src/libsyntax/ext/build.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,12 +1007,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
10071007

10081008
fn variant(&self, span: Span, name: Ident, tys: Vec<P<ast::Ty>> ) -> ast::Variant {
10091009
let fields: Vec<_> = tys.into_iter().map(|ty| {
1010-
Spanned { span: ty.span, node: ast::StructField_ {
1010+
ast::StructField {
1011+
span: ty.span,
10111012
ty: ty,
1012-
kind: ast::UnnamedField(ast::Visibility::Inherited),
1013+
ident: None,
1014+
vis: ast::Visibility::Inherited,
10131015
attrs: Vec::new(),
10141016
id: ast::DUMMY_NODE_ID,
1015-
}}
1017+
}
10161018
}).collect();
10171019

10181020
let vdata = if fields.is_empty() {

branches/try/src/libsyntax/fold.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -846,15 +846,13 @@ pub fn noop_fold_poly_trait_ref<T: Folder>(p: PolyTraitRef, fld: &mut T) -> Poly
846846
}
847847

848848
pub fn noop_fold_struct_field<T: Folder>(f: StructField, fld: &mut T) -> StructField {
849-
let StructField {node: StructField_ {id, kind, ty, attrs}, span} = f;
850-
Spanned {
851-
node: StructField_ {
852-
id: fld.new_id(id),
853-
kind: kind,
854-
ty: fld.fold_ty(ty),
855-
attrs: fold_attrs(attrs, fld),
856-
},
857-
span: fld.new_span(span)
849+
StructField {
850+
span: fld.new_span(f.span),
851+
id: fld.new_id(f.id),
852+
ident: f.ident.map(|ident| fld.fold_ident(ident)),
853+
vis: f.vis,
854+
ty: fld.fold_ty(f.ty),
855+
attrs: fold_attrs(f.attrs, fld),
858856
}
859857
}
860858

branches/try/src/libsyntax/parse/parser.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use ast::Local;
2929
use ast::MacStmtStyle;
3030
use ast::Mac_;
3131
use ast::{MutTy, Mutability};
32-
use ast::NamedField;
3332
use ast::{Pat, PatKind};
3433
use ast::{PolyTraitRef, QSelf};
3534
use ast::{Stmt, StmtKind};
@@ -38,7 +37,6 @@ use ast::StrStyle;
3837
use ast::SelfKind;
3938
use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef};
4039
use ast::{Ty, TyKind, TypeBinding, TyParam, TyParamBounds};
41-
use ast::UnnamedField;
4240
use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple};
4341
use ast::{Visibility, WhereClause};
4442
use attr::{ThinAttributes, ThinAttributesExt, AttributesExt};
@@ -3851,12 +3849,14 @@ impl<'a> Parser<'a> {
38513849
let name = self.parse_ident()?;
38523850
self.expect(&token::Colon)?;
38533851
let ty = self.parse_ty_sum()?;
3854-
Ok(spanned(lo, self.last_span.hi, ast::StructField_ {
3855-
kind: NamedField(name, pr),
3852+
Ok(StructField {
3853+
span: mk_sp(lo, self.last_span.hi),
3854+
ident: Some(name),
3855+
vis: pr,
38563856
id: ast::DUMMY_NODE_ID,
38573857
ty: ty,
38583858
attrs: attrs,
3859-
}))
3859+
})
38603860
}
38613861

38623862
/// Emit an expected item after attributes error.
@@ -5250,13 +5250,16 @@ impl<'a> Parser<'a> {
52505250
|p| {
52515251
let attrs = p.parse_outer_attributes()?;
52525252
let lo = p.span.lo;
5253-
let struct_field_ = ast::StructField_ {
5254-
kind: UnnamedField(p.parse_visibility()?),
5253+
let vis = p.parse_visibility()?;
5254+
let ty = p.parse_ty_sum()?;
5255+
Ok(StructField {
5256+
span: mk_sp(lo, p.span.hi),
5257+
vis: vis,
5258+
ident: None,
52555259
id: ast::DUMMY_NODE_ID,
5256-
ty: p.parse_ty_sum()?,
5260+
ty: ty,
52575261
attrs: attrs,
5258-
};
5259-
Ok(spanned(lo, p.span.hi, struct_field_))
5262+
})
52605263
})?;
52615264

52625265
Ok(fields)

branches/try/src/libsyntax/print/pprust.rs

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,14 +1407,9 @@ impl<'a> State<'a> {
14071407
self.commasep(
14081408
Inconsistent, struct_def.fields(),
14091409
|s, field| {
1410-
match field.node.kind {
1411-
ast::NamedField(..) => panic!("unexpected named field"),
1412-
ast::UnnamedField(ref vis) => {
1413-
s.print_visibility(vis)?;
1414-
s.maybe_print_comment(field.span.lo)?;
1415-
s.print_type(&field.node.ty)
1416-
}
1417-
}
1410+
s.print_visibility(&field.vis)?;
1411+
s.maybe_print_comment(field.span.lo)?;
1412+
s.print_type(&field.ty)
14181413
}
14191414
)?;
14201415
self.pclose()?;
@@ -1432,19 +1427,14 @@ impl<'a> State<'a> {
14321427
self.hardbreak_if_not_bol()?;
14331428

14341429
for field in struct_def.fields() {
1435-
match field.node.kind {
1436-
ast::UnnamedField(..) => panic!("unexpected unnamed field"),
1437-
ast::NamedField(ident, ref visibility) => {
1438-
self.hardbreak_if_not_bol()?;
1439-
self.maybe_print_comment(field.span.lo)?;
1440-
self.print_outer_attributes(&field.node.attrs)?;
1441-
self.print_visibility(visibility)?;
1442-
self.print_ident(ident)?;
1443-
self.word_nbsp(":")?;
1444-
self.print_type(&field.node.ty)?;
1445-
word(&mut self.s, ",")?;
1446-
}
1447-
}
1430+
self.hardbreak_if_not_bol()?;
1431+
self.maybe_print_comment(field.span.lo)?;
1432+
self.print_outer_attributes(&field.attrs)?;
1433+
self.print_visibility(&field.vis)?;
1434+
self.print_ident(field.ident.unwrap())?;
1435+
self.word_nbsp(":")?;
1436+
self.print_type(&field.ty)?;
1437+
word(&mut self.s, ",")?;
14481438
}
14491439

14501440
self.bclose(span)

branches/try/src/libsyntax/visit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,9 +619,9 @@ pub fn walk_struct_def<'v, V: Visitor<'v>>(visitor: &mut V,
619619

620620
pub fn walk_struct_field<'v, V: Visitor<'v>>(visitor: &mut V,
621621
struct_field: &'v StructField) {
622-
walk_opt_ident(visitor, struct_field.span, struct_field.node.ident());
623-
visitor.visit_ty(&struct_field.node.ty);
624-
walk_list!(visitor, visit_attribute, &struct_field.node.attrs);
622+
walk_opt_ident(visitor, struct_field.span, struct_field.ident);
623+
visitor.visit_ty(&struct_field.ty);
624+
walk_list!(visitor, visit_attribute, &struct_field.attrs);
625625
}
626626

627627
pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block) {

0 commit comments

Comments
 (0)