diff options
| author | bors <bors@rust-lang.org> | 2013-05-08 17:09:37 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-05-08 17:09:37 -0700 |
| commit | d82d9874a6f88e0afa021796e9efaba5b3670c31 (patch) | |
| tree | 4270207820c8eca6e33cf2bbf9f1bbcafe9d74a9 /src/libsyntax | |
| parent | 5a65f51d666855d7685850808cc06e49c3d21c72 (diff) | |
| parent | d20e63ab65f7ba28db36ae43379706ca9dba1ca5 (diff) | |
| download | rust-d82d9874a6f88e0afa021796e9efaba5b3670c31.tar.gz rust-d82d9874a6f88e0afa021796e9efaba5b3670c31.zip | |
auto merge of #6232 : pcwalton/rust/demuting, r=pcwalton
They're still parsed for bootstrapping purposes, but the qualifier is immediately dropped on the floor. r? @nikomatsakis
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 37 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/auto_encode.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 18 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/decodable.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/encodable.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/iter_bytes.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/mod.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/rand.rs | 15 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/pipec.rs | 15 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 23 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/util/interner.rs | 2 |
15 files changed, 85 insertions, 63 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 2216226ecb3..c8fc04eaea1 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1168,7 +1168,7 @@ pub type struct_field = spanned<struct_field_>; #[auto_decode] #[deriving(Eq)] pub enum struct_field_kind { - named_field(ident, struct_mutability, visibility), + named_field(ident, visibility), unnamed_field // element of a tuple-like struct } @@ -1221,17 +1221,6 @@ pub enum item_ { #[auto_encode] #[auto_decode] #[deriving(Eq)] -pub enum struct_mutability { struct_mutable, struct_immutable } - -impl to_bytes::IterBytes for struct_mutability { - fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) { - (*self as u8).iter_bytes(lsb0, f) - } -} - -#[auto_encode] -#[auto_decode] -#[deriving(Eq)] pub struct foreign_item { ident: ident, attrs: ~[attribute], @@ -1291,6 +1280,21 @@ mod test { #[test] fn test_marksof () { let stopname = uints_to_name(&~[12,14,78]); + assert_eq!(s,~[]); + xorPush(&mut s,14); + assert_eq!(s,~[14]); + xorPush(&mut s,15); + assert_eq!(s,~[14,15]); + xorPush (&mut s,16); + assert_eq! (s,~[14,15,16]); + xorPush (&mut s,16); + assert_eq! (s,~[14,15]); + xorPush (&mut s,15); + assert_eq! (s,~[14]); + } + + #[test] fn test_marksof () { + let stopname = uints_to_name(&~[12,14,78]); let name1 = uints_to_name(&~[4,9,7]); assert_eq!(marksof (MT,stopname),~[]); assert_eq! (marksof (Mark (4,@Mark(98,@MT)),stopname),~[4,98]); @@ -1347,3 +1351,12 @@ mod test { } */ +// +// Local Variables: +// mode: rust +// fill-column: 78; +// indent-tabs-mode: nil +// c-basic-offset: 4 +// buffer-file-coding-system: utf-8-unix +// End: +// diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index a6094903d7b..7b20d71fdc4 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -285,7 +285,7 @@ pub fn split_trait_methods(trait_methods: &[trait_method]) pub fn struct_field_visibility(field: ast::struct_field) -> visibility { match field.node.kind { - ast::named_field(_, _, visibility) => visibility, + ast::named_field(_, visibility) => visibility, ast::unnamed_field => ast::public } } diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index bdf0a2a1dd0..5bd4f89a3b3 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -914,19 +914,15 @@ struct field { fn mk_struct_fields(fields: &[@ast::struct_field]) -> ~[field] { do fields.map |field| { - let (ident, mutbl) = match field.node.kind { - ast::named_field(ident, mutbl, _) => (ident, mutbl), - _ => fail!(~"[auto_encode] does not support \ - unnamed fields") + let ident = match field.node.kind { + ast::named_field(ident, _) => ident, + _ => fail!(~"[auto_encode] does not support unnamed fields") }; field { span: field.span, ident: ident, - mutbl: match mutbl { - ast::struct_mutable => ast::m_mutbl, - ast::struct_immutable => ast::m_imm, - }, + mutbl: ast::m_imm, } } } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index c1163fda844..3097cb799a2 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -11,6 +11,7 @@ use ast; use codemap; use codemap::span; +use fold; use ext::base::ext_ctxt; use ext::build; @@ -516,3 +517,20 @@ pub fn mk_unreachable(cx: @ext_ctxt, span: span) -> @ast::expr { pub fn mk_unreachable_arm(cx: @ext_ctxt, span: span) -> ast::arm { mk_arm(cx, span, ~[mk_pat_wild(cx, span)], mk_unreachable(cx, span)) } + +// +// Duplication functions +// +// These functions just duplicate AST nodes. +// + +pub fn duplicate_expr(cx: @ext_ctxt, expr: @ast::expr) -> @ast::expr { + let folder = fold::default_ast_fold(); + let folder = @fold::AstFoldFns { + new_id: |_| cx.next_id(), + ..*folder + }; + let folder = fold::make_fold(folder); + folder.fold_expr(expr) +} + diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs index 79cc4a3bda8..2bdfe51c50e 100644 --- a/src/libsyntax/ext/deriving/decodable.rs +++ b/src/libsyntax/ext/deriving/decodable.rs @@ -280,7 +280,7 @@ fn expand_deriving_decodable_struct_method( let mut fields = ~[]; for struct_def.fields.each |struct_field| { match struct_field.node.kind { - named_field(ident, _, _) => { + named_field(ident, _) => { fields.push(create_read_struct_field(cx, span, i, ident)); } unnamed_field => { diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs index 8b86173dc24..54e5687f415 100644 --- a/src/libsyntax/ext/deriving/encodable.rs +++ b/src/libsyntax/ext/deriving/encodable.rs @@ -211,7 +211,7 @@ fn expand_deriving_encodable_struct_method( let mut statements = ~[]; for struct_def.fields.each |struct_field| { match struct_field.node.kind { - named_field(ident, _, _) => { + named_field(ident, _) => { // Create the accessor for this field. let self_field = build::mk_access( cx, diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index 565d6dd59ba..d785f3816de 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -818,12 +818,8 @@ fn summarise_struct(cx: @ext_ctxt, span: span, let mut unnamed_count = 0; for struct_def.fields.each |field| { match field.node.kind { - ast::named_field(ident, _, _) => { - named_idents.push(ident) - } - ast::unnamed_field => { - unnamed_count += 1; - } + ast::named_field(ident, _) => named_idents.push(ident), + ast::unnamed_field => unnamed_count += 1, } } diff --git a/src/libsyntax/ext/deriving/iter_bytes.rs b/src/libsyntax/ext/deriving/iter_bytes.rs index c1c34c9a53a..3d66506d6ca 100644 --- a/src/libsyntax/ext/deriving/iter_bytes.rs +++ b/src/libsyntax/ext/deriving/iter_bytes.rs @@ -90,4 +90,4 @@ fn iter_bytes_substructure(cx: @ext_ctxt, span: span, substr: &Substructure) -> } build::mk_block(cx, span, ~[], stmts, None) -} \ No newline at end of file +} diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs index d48ff98be06..2bd45e1466c 100644 --- a/src/libsyntax/ext/deriving/mod.rs +++ b/src/libsyntax/ext/deriving/mod.rs @@ -281,8 +281,8 @@ pub fn create_struct_pattern(cx: @ext_ctxt, for struct_def.fields.eachi |i, struct_field| { let opt_id = match struct_field.node.kind { - ast::named_field(ident, _, _) if (struct_type == Unknown || - struct_type == Record) => { + ast::named_field(ident, _) if (struct_type == Unknown || + struct_type == Record) => { struct_type = Record; Some(ident) } diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs index 03202801d20..604686f442f 100644 --- a/src/libsyntax/ext/deriving/rand.rs +++ b/src/libsyntax/ext/deriving/rand.rs @@ -35,7 +35,7 @@ pub fn expand_deriving_rand(cx: @ext_ctxt, self_ty: None, args: ~[ Ptr(~Literal(Path::new_local(~"R")), - Borrowed(None, ast::m_imm)) + Borrowed(None, ast::m_mutbl)) ], ret_ty: Self, const_nonmatching: false, @@ -59,8 +59,10 @@ fn rand_substructure(cx: @ext_ctxt, span: span, substr: &Substructure) -> @expr cx.ident_of(~"rand") ]; let rand_call = || { - build::mk_call_global(cx, span, - copy rand_ident, copy rng) + build::mk_call_global(cx, + span, + copy rand_ident, + ~[ build::duplicate_expr(cx, rng[0]) ]) }; return match *substr.fields { @@ -80,7 +82,10 @@ fn rand_substructure(cx: @ext_ctxt, span: span, substr: &Substructure) -> @expr let rand_name = build::mk_raw_path_(span, copy rand_ident, None, ~[ u32_ty, r_ty ]); let rand_name = build::mk_path_raw(cx, span, rand_name); - let rv_call = build::mk_call_(cx, span, rand_name, copy rng); + let rv_call = build::mk_call_(cx, + span, + rand_name, + ~[ build::duplicate_expr(cx, rng[0]) ]); // rand() % variants.len() let rand_variant = build::mk_binary(cx, span, ast::rem, @@ -133,4 +138,4 @@ fn rand_substructure(cx: @ext_ctxt, span: span, substr: &Substructure) -> @expr } } } -} \ No newline at end of file +} diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index e876972fe68..7ac3ea4789d 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -64,6 +64,7 @@ impl gen_send for message { let mut body = ~"{\n"; body += fmt!("use super::%s;\n", name); + body += ~"let mut pipe = pipe;\n"; if this.proto.is_bounded() { let (sp, rp) = match (this.dir, next.dir) { @@ -73,12 +74,12 @@ impl gen_send for message { (recv, recv) => (~"c", ~"s") }; - body += ~"let b = pipe.reuse_buffer();\n"; + body += ~"let mut b = pipe.reuse_buffer();\n"; body += fmt!("let %s = ::core::pipes::SendPacketBuffered(\ - &(b.buffer.data.%s));\n", + &mut (b.buffer.data.%s));\n", sp, next.name); body += fmt!("let %s = ::core::pipes::RecvPacketBuffered(\ - &(b.buffer.data.%s));\n", + &mut (b.buffer.data.%s));\n", rp, next.name); } else { @@ -366,7 +367,7 @@ impl gen_init for protocol { fmt!("data.%s.set_buffer(buffer)", s.name))), ext_cx.parse_expr(fmt!( - "::core::ptr::to_unsafe_ptr(&(data.%s))", + "::core::ptr::to_mut_unsafe_ptr(&mut (data.%s))", self.states[0].name)))); quote_expr!({ @@ -410,10 +411,8 @@ impl gen_init for protocol { @spanned { node: ast::struct_field_ { - kind: ast::named_field( - cx.ident_of(s.name), - ast::struct_immutable, - ast::inherited), + kind: ast::named_field(cx.ident_of(s.name), + ast::inherited), id: cx.next_id(), ty: fty, attrs: ~[], diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 229a8664d0c..d181dd87e38 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -859,3 +859,4 @@ impl AstFoldExtensions for @ast_fold { pub fn make_fold(afp: ast_fold_fns) -> @ast_fold { afp as @ast_fold } + diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 810efd39177..0543295eb4e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -45,7 +45,7 @@ use ast::{pat_tup, pat_uniq, pat_wild, private}; use ast::{rem, required}; use ast::{ret_style, return_val, self_ty, shl, shr, stmt, stmt_decl}; use ast::{stmt_expr, stmt_semi, stmt_mac, struct_def, struct_field}; -use ast::{struct_immutable, struct_mutable, struct_variant_kind, subtract}; +use ast::{struct_variant_kind, subtract}; use ast::{sty_box, sty_region, sty_static, sty_uniq, sty_value}; use ast::{token_tree, trait_method, trait_ref, tt_delim, tt_seq, tt_tok}; use ast::{tt_nonterminal, tuple_variant_kind, Ty, ty_, ty_bot, ty_box}; @@ -390,8 +390,8 @@ pub impl Parser { // parse a ty_closure type fn parse_ty_closure(&self, sigil: ast::Sigil, - region: Option<@ast::Lifetime>) -> ty_ - { + region: Option<@ast::Lifetime>) + -> ty_ { /* (&|~|@) ['r] [pure|unsafe] [once] fn <'lt> (S) -> T @@ -773,20 +773,17 @@ pub impl Parser { return ty_rptr(opt_lifetime, mt); } - // parse an optional mode. - // XXX: Remove after snapshot. + // parse an optional, obsolete argument mode. fn parse_arg_mode(&self) { if self.eat(&token::BINOP(token::MINUS)) { self.obsolete(*self.span, ObsoleteMode); } else if self.eat(&token::ANDAND) { - // Ignore. + self.obsolete(*self.span, ObsoleteMode); } else if self.eat(&token::BINOP(token::PLUS)) { if self.eat(&token::BINOP(token::PLUS)) { - // ++ mode is obsolete, but we need a snapshot - // to stop parsing it. - // Ignore. + self.obsolete(*self.span, ObsoleteMode); } else { - // Ignore. + self.obsolete(*self.span, ObsoleteMode); } } else { // Ignore. @@ -2528,10 +2525,10 @@ pub impl Parser { fn parse_name_and_ty(&self, pr: visibility, attrs: ~[attribute]) -> @struct_field { - let mut is_mutbl = struct_immutable; let lo = self.span.lo; if self.eat_keyword(&~"mut") { - is_mutbl = struct_mutable; + // Do nothing, for backwards compatibility. + // XXX: Remove after snapshot. } if !is_plain_ident(&*self.token) { self.fatal(~"expected ident"); @@ -2540,7 +2537,7 @@ pub impl Parser { self.expect(&token::COLON); let ty = self.parse_ty(false); @spanned(lo, self.last_span.hi, ast::struct_field_ { - kind: named_field(name, is_mutbl, pr), + kind: named_field(name, pr), id: self.get_id(), ty: ty, attrs: attrs, diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 6f3d6604d5b..f12fb21992e 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -703,14 +703,11 @@ pub fn print_struct(s: @ps, for struct_def.fields.each |field| { match field.node.kind { ast::unnamed_field => fail!(~"unexpected unnamed field"), - ast::named_field(ident, mutability, visibility) => { + ast::named_field(ident, visibility) => { hardbreak_if_not_bol(s); maybe_print_comment(s, field.span.lo); print_outer_attributes(s, field.node.attrs); print_visibility(s, visibility); - if mutability == ast::struct_mutable { - word_nbsp(s, ~"mut"); - } print_ident(s, ident); word_nbsp(s, ~":"); print_type(s, field.node.ty); diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index e3a87277622..23084c34209 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -84,7 +84,7 @@ pub impl<T:Eq + IterBytes + Hash + Const + Copy> Interner<T> { * for another case of this. */ macro_rules! interner_key ( () => (cast::transmute::<(uint, uint), - &fn(+v: @@::parse::token::ident_interner)>( + &fn(v: @@::parse::token::ident_interner)>( (-3 as uint, 0u))) ) |
