Skip to content

ast: Remove one @ and fix the fallout #10750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ fn encode_provided_source(ebml_w: &mut writer::Encoder,
fn encode_info_for_struct(ecx: &EncodeContext,
ebml_w: &mut writer::Encoder,
path: &[ast_map::path_elt],
fields: &[@struct_field],
fields: &[struct_field],
global_index: @mut ~[entry<i64>])
-> ~[entry<i64>] {
/* Each class has its own index, since different classes
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ impl<'self> Visitor<()> for Context<'self> {
self.cur_struct_def_id = old_id;
}

fn visit_struct_field(&mut self, s: @ast::struct_field, _: ()) {
fn visit_struct_field(&mut self, s: &ast::struct_field, _: ()) {
self.with_lint_attrs(s.node.attrs, |cx| {
check_missing_doc_struct_field(cx, s);
check_attrs_usage(cx, s.node.attrs);
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3876,9 +3876,9 @@ impl Resolver {
fn resolve_struct(&mut self,
id: NodeId,
generics: &Generics,
fields: &[@struct_field]) {
let mut ident_map: HashMap<ast::Ident,@struct_field> = HashMap::new();
for &field in fields.iter() {
fields: &[struct_field]) {
let mut ident_map: HashMap<ast::Ident, &struct_field> = HashMap::new();
for field in fields.iter() {
match field.node.kind {
named_field(ident, _) => {
match ident_map.find(&ident) {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2037,7 +2037,7 @@ pub fn trans_enum_variant(ccx: @mut CrateContext,
}

pub fn trans_tuple_struct(ccx: @mut CrateContext,
fields: &[@ast::struct_field],
fields: &[ast::struct_field],
ctor_id: ast::NodeId,
param_substs: Option<@param_substs>,
llfndecl: ValueRef) {
Expand All @@ -2062,7 +2062,7 @@ impl IdAndTy for ast::variant_arg {
fn ty<'a>(&'a self) -> &'a ast::Ty { &self.ty }
}

impl IdAndTy for @ast::struct_field {
impl IdAndTy for ast::struct_field {
fn id(&self) -> ast::NodeId { self.node.id }
fn ty<'a>(&'a self) -> &'a ast::Ty { &self.node.ty }
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3693,7 +3693,7 @@ impl VariantInfo {
},
ast::struct_variant_kind(ref struct_def) => {

let fields: &[@struct_field] = struct_def.fields;
let fields: &[struct_field] = struct_def.fields;

assert!(fields.len() > 0);

Expand Down Expand Up @@ -4082,7 +4082,7 @@ pub fn lookup_struct_field(cx: ctxt,
}
}

fn struct_field_tys(fields: &[@struct_field]) -> ~[field_ty] {
fn struct_field_tys(fields: &[struct_field]) -> ~[field_ty] {
fields.map(|field| {
match field.node.kind {
named_field(ident, visibility) => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ pub fn convert_struct(ccx: &CrateCtxt,

// Write the type of each of the members
for f in struct_def.fields.iter() {
convert_field(ccx, &tpt.generics, *f);
convert_field(ccx, &tpt.generics, f);
}
let substs = mk_item_substs(ccx, &tpt.generics, None);
let selfty = ty::mk_struct(tcx, local_def(id), substs);
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/doctree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub struct Struct {
name: Ident,
generics: ast::Generics,
attrs: ~[ast::Attribute],
fields: ~[@ast::struct_field],
fields: ~[ast::struct_field],
where: Span,
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/visit_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl RustdocVisitor {
vis: item.vis,
attrs: item.attrs.clone(),
generics: generics.clone(),
fields: sd.fields.iter().map(|x| (*x).clone()).to_owned_vec(),
fields: sd.fields.clone(),
where: item.span
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/libsyntax/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ impl visibility {
}
}

#[deriving(Eq, Encodable, Decodable,IterBytes)]
#[deriving(Clone, Eq, Encodable, Decodable,IterBytes)]
pub struct struct_field_ {
kind: struct_field_kind,
id: NodeId,
Expand All @@ -1108,15 +1108,15 @@ pub struct struct_field_ {

pub type struct_field = Spanned<struct_field_>;

#[deriving(Eq, Encodable, Decodable,IterBytes)]
#[deriving(Clone, Eq, Encodable, Decodable,IterBytes)]
pub enum struct_field_kind {
named_field(Ident, visibility),
unnamed_field // element of a tuple-like struct
}

#[deriving(Eq, Encodable, Decodable,IterBytes)]
pub struct struct_def {
fields: ~[@struct_field], /* fields, not including ctor */
fields: ~[struct_field], /* fields, not including ctor */
/* ID of the constructor. This is only used for tuple- or enum-like
* structs. */
ctor_id: Option<NodeId>
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ast_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ impl<'self, O: IdVisitingOperation> Visitor<()> for IdVisitor<'self, O> {
}
}

fn visit_struct_field(&mut self, struct_field: @struct_field, env: ()) {
fn visit_struct_field(&mut self, struct_field: &struct_field, env: ()) {
self.operation.visit_id(struct_field.node.id);
visit::walk_struct_field(self, struct_field, env)
}
Expand Down
12 changes: 6 additions & 6 deletions src/libsyntax/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ pub trait ast_fold {
noop_fold_item(i, self)
}

fn fold_struct_field(&self, sf: @struct_field) -> @struct_field {
fn fold_struct_field(&self, sf: &struct_field) -> struct_field {
let fold_attribute = |x| fold_attribute_(x, self);

@Spanned {
Spanned {
node: ast::struct_field_ {
kind: sf.node.kind,
id: self.new_id(sf.node.id),
Expand Down Expand Up @@ -312,7 +312,7 @@ pub trait ast_fold {
struct_variant_kind(ref struct_def) => {
kind = struct_variant_kind(@ast::struct_def {
fields: struct_def.fields.iter()
.map(|f| self.fold_struct_field(*f)).collect(),
.map(|f| self.fold_struct_field(f)).collect(),
ctor_id: struct_def.ctor_id.map(|c| self.new_id(c))
})
}
Expand Down Expand Up @@ -536,7 +536,7 @@ pub fn fold_generics<T:ast_fold>(generics: &Generics, fld: &T) -> Generics {
fn fold_struct_def<T:ast_fold>(struct_def: @ast::struct_def, fld: &T)
-> @ast::struct_def {
@ast::struct_def {
fields: struct_def.fields.map(|f| fold_struct_field(*f, fld)),
fields: struct_def.fields.map(|f| fold_struct_field(f, fld)),
ctor_id: struct_def.ctor_id.map(|cid| fld.new_id(cid)),
}
}
Expand All @@ -562,8 +562,8 @@ fn fold_trait_ref<T:ast_fold>(p: &trait_ref, fld: &T) -> trait_ref {
}
}

fn fold_struct_field<T:ast_fold>(f: @struct_field, fld: &T) -> @struct_field {
@Spanned {
fn fold_struct_field<T:ast_fold>(f: &struct_field, fld: &T) -> struct_field {
Spanned {
node: ast::struct_field_ {
kind: f.node.kind,
id: fld.new_id(f.node.id),
Expand Down
14 changes: 7 additions & 7 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3162,15 +3162,15 @@ impl Parser {
// parse a structure field
fn parse_name_and_ty(&self,
pr: visibility,
attrs: ~[Attribute]) -> @struct_field {
attrs: ~[Attribute]) -> struct_field {
let lo = self.span.lo;
if !is_plain_ident(&*self.token) {
self.fatal("expected ident");
}
let name = self.parse_ident();
self.expect(&token::COLON);
let ty = self.parse_ty(false);
@spanned(lo, self.last_span.hi, ast::struct_field_ {
spanned(lo, self.last_span.hi, ast::struct_field_ {
kind: named_field(name, pr),
id: ast::DUMMY_NODE_ID,
ty: ty,
Expand Down Expand Up @@ -4006,7 +4006,7 @@ impl Parser {
let class_name = self.parse_ident();
let generics = self.parse_generics();

let mut fields: ~[@struct_field];
let mut fields: ~[struct_field];
let is_tuple_like;

if self.eat(&token::LBRACE) {
Expand Down Expand Up @@ -4037,7 +4037,7 @@ impl Parser {
ty: p.parse_ty(false),
attrs: attrs,
};
@spanned(lo, p.span.hi, struct_field_)
spanned(lo, p.span.hi, struct_field_)
});
self.expect(&token::SEMI);
} else if self.eat(&token::SEMI) {
Expand Down Expand Up @@ -4075,7 +4075,7 @@ impl Parser {
pub fn parse_single_struct_field(&self,
vis: visibility,
attrs: ~[Attribute])
-> @struct_field {
-> struct_field {
let a_var = self.parse_name_and_ty(vis, attrs);
match *self.token {
token::COMMA => {
Expand All @@ -4092,7 +4092,7 @@ impl Parser {
}

// parse an element of a struct definition
fn parse_struct_decl_field(&self) -> @struct_field {
fn parse_struct_decl_field(&self) -> struct_field {

let attrs = self.parse_outer_attributes();

Expand Down Expand Up @@ -4454,7 +4454,7 @@ impl Parser {
// parse a structure-like enum variant definition
// this should probably be renamed or refactored...
fn parse_struct_def(&self) -> @struct_def {
let mut fields: ~[@struct_field] = ~[];
let mut fields: ~[struct_field] = ~[];
while *self.token != token::RBRACE {
fields.push(self.parse_struct_decl_field());
}
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub trait Visitor<E:Clone> {
fn visit_struct_def(&mut self, s:@struct_def, i:Ident, g:&Generics, n:NodeId, e:E) {
walk_struct_def(self, s, i, g, n, e)
}
fn visit_struct_field(&mut self, s:@struct_field, e:E) { walk_struct_field(self, s, e) }
fn visit_struct_field(&mut self, s:&struct_field, e:E) { walk_struct_field(self, s, e) }
fn visit_variant(&mut self, v:&variant, g:&Generics, e:E) { walk_variant(self, v, g, e) }
fn visit_opt_lifetime_ref(&mut self,
_span: Span,
Expand Down Expand Up @@ -538,7 +538,7 @@ pub fn walk_struct_def<E:Clone, V:Visitor<E>>(visitor: &mut V,
_: NodeId,
env: E) {
for field in struct_definition.fields.iter() {
visitor.visit_struct_field(*field, env.clone())
visitor.visit_struct_field(field, env.clone())
}
}

Expand Down