Skip to content

Commit 3c7aea3

Browse files
committed
syntax: de-mode and prepare for de-modeing rustc
1 parent be9f4ef commit 3c7aea3

30 files changed

+363
-364
lines changed

src/libsyntax/abi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,13 @@ pub impl AbiSet {
255255
}
256256

257257
impl to_bytes::IterBytes for Abi {
258-
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
258+
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
259259
self.index().iter_bytes(lsb0, f)
260260
}
261261
}
262262

263263
impl to_bytes::IterBytes for AbiSet {
264-
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
264+
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
265265
self.bits.iter_bytes(lsb0, f)
266266
}
267267
}

src/libsyntax/ast.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl<D:Decoder> Decodable<D> for ident {
9797
}
9898
9999
impl to_bytes::IterBytes for ident {
100-
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
100+
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
101101
self.repr.iter_bytes(lsb0, f)
102102
}
103103
}
@@ -284,7 +284,7 @@ pub enum binding_mode {
284284
}
285285
286286
impl to_bytes::IterBytes for binding_mode {
287-
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
287+
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
288288
match *self {
289289
bind_by_copy => 0u8.iter_bytes(lsb0, f),
290290
@@ -330,7 +330,7 @@ pub enum pat_ {
330330
pub enum mutability { m_mutbl, m_imm, m_const, }
331331
332332
impl to_bytes::IterBytes for mutability {
333-
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
333+
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
334334
(*self as u8).iter_bytes(lsb0, f)
335335
}
336336
}
@@ -345,7 +345,7 @@ pub enum Sigil {
345345
}
346346
347347
impl to_bytes::IterBytes for Sigil {
348-
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
348+
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
349349
(*self as uint).iter_bytes(lsb0, f)
350350
}
351351
}
@@ -428,7 +428,7 @@ pub enum inferable<T> {
428428
}
429429
430430
impl<T:to_bytes::IterBytes> to_bytes::IterBytes for inferable<T> {
431-
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
431+
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
432432
match *self {
433433
expl(ref t) =>
434434
to_bytes::iter_bytes_2(&0u8, t, lsb0, f),
@@ -446,7 +446,7 @@ impl<T:to_bytes::IterBytes> to_bytes::IterBytes for inferable<T> {
446446
pub enum rmode { by_ref, by_copy }
447447
448448
impl to_bytes::IterBytes for rmode {
449-
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
449+
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
450450
(*self as u8).iter_bytes(lsb0, f)
451451
}
452452
}
@@ -781,7 +781,7 @@ impl ToStr for int_ty {
781781
}
782782
783783
impl to_bytes::IterBytes for int_ty {
784-
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
784+
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
785785
(*self as u8).iter_bytes(lsb0, f)
786786
}
787787
}
@@ -798,7 +798,7 @@ impl ToStr for uint_ty {
798798
}
799799
800800
impl to_bytes::IterBytes for uint_ty {
801-
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
801+
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
802802
(*self as u8).iter_bytes(lsb0, f)
803803
}
804804
}
@@ -815,7 +815,7 @@ impl ToStr for float_ty {
815815
}
816816
817817
impl to_bytes::IterBytes for float_ty {
818-
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
818+
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
819819
(*self as u8).iter_bytes(lsb0, f)
820820
}
821821
}
@@ -860,7 +860,7 @@ impl ToStr for Onceness {
860860
}
861861
862862
impl to_bytes::IterBytes for Onceness {
863-
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
863+
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
864864
(*self as uint).iter_bytes(lsb0, f);
865865
}
866866
}
@@ -911,7 +911,7 @@ pub enum ty_ {
911911
}
912912
913913
impl to_bytes::IterBytes for Ty {
914-
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
914+
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
915915
to_bytes::iter_bytes_2(&self.span.lo, &self.span.hi, lsb0, f);
916916
}
917917
}
@@ -979,7 +979,7 @@ impl ToStr for purity {
979979
}
980980
981981
impl to_bytes::IterBytes for purity {
982-
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
982+
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
983983
(*self as u8).iter_bytes(lsb0, f)
984984
}
985985
}
@@ -994,7 +994,7 @@ pub enum ret_style {
994994
}
995995
996996
impl to_bytes::IterBytes for ret_style {
997-
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
997+
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
998998
(*self as u8).iter_bytes(lsb0, f)
999999
}
10001000
}
@@ -1268,7 +1268,7 @@ pub enum item_ {
12681268
pub enum struct_mutability { struct_mutable, struct_immutable }
12691269

12701270
impl to_bytes::IterBytes for struct_mutability {
1271-
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
1271+
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
12721272
(*self as u8).iter_bytes(lsb0, f)
12731273
}
12741274
}

src/libsyntax/ast_map.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pub struct Ctx {
115115

116116
pub type vt = visit::vt<@mut Ctx>;
117117

118-
pub fn extend(cx: @mut Ctx, +elt: ident) -> @path {
118+
pub fn extend(cx: @mut Ctx, elt: ident) -> @path {
119119
@(vec::append(copy cx.path, ~[path_name(elt)]))
120120
}
121121

@@ -132,7 +132,7 @@ pub fn mk_ast_map_visitor() -> vt {
132132
});
133133
}
134134

135-
pub fn map_crate(diag: @span_handler, c: crate) -> map {
135+
pub fn map_crate(diag: @span_handler, c: @crate) -> map {
136136
let cx = @mut Ctx {
137137
map: @mut HashMap::new(),
138138
path: ~[],
@@ -148,8 +148,8 @@ pub fn map_crate(diag: @span_handler, c: crate) -> map {
148148
// the item itself.
149149
pub fn map_decoded_item(diag: @span_handler,
150150
map: map,
151-
+path: path,
152-
ii: inlined_item) {
151+
path: path,
152+
ii: &inlined_item) {
153153
// I believe it is ok for the local IDs of inlined items from other crates
154154
// to overlap with the local ids from this crate, so just generate the ids
155155
// starting from 0. (In particular, I think these ids are only used in
@@ -167,7 +167,7 @@ pub fn map_decoded_item(diag: @span_handler,
167167
// methods get added to the AST map when their impl is visited. Since we
168168
// don't decode and instantiate the impl, but just the method, we have to
169169
// add it to the table now:
170-
match ii {
170+
match *ii {
171171
ii_item(*) | ii_dtor(*) => { /* fallthrough */ }
172172
ii_foreign(i) => {
173173
cx.map.insert(i.id, node_foreign_item(i,
@@ -190,7 +190,7 @@ pub fn map_fn(
190190
body: &blk,
191191
sp: codemap::span,
192192
id: node_id,
193-
&&cx: @mut Ctx,
193+
cx: @mut Ctx,
194194
v: visit::vt<@mut Ctx>
195195
) {
196196
for decl.inputs.each |a| {
@@ -222,7 +222,7 @@ pub fn map_fn(
222222
visit::visit_fn(fk, decl, body, sp, id, cx, v);
223223
}
224224

225-
pub fn map_block(b: &blk, &&cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
225+
pub fn map_block(b: &blk, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
226226
cx.map.insert(b.node.id, node_block(/* FIXME (#2543) */ copy *b));
227227
visit::visit_block(b, cx, v);
228228
}
@@ -239,24 +239,24 @@ pub fn number_pat(cx: @mut Ctx, pat: @pat) {
239239
};
240240
}
241241

242-
pub fn map_local(loc: @local, &&cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
242+
pub fn map_local(loc: @local, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
243243
number_pat(cx, loc.node.pat);
244244
visit::visit_local(loc, cx, v);
245245
}
246246

247-
pub fn map_arm(arm: &arm, &&cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
247+
pub fn map_arm(arm: &arm, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
248248
number_pat(cx, arm.pats[0]);
249249
visit::visit_arm(arm, cx, v);
250250
}
251251

252252
pub fn map_method(impl_did: def_id, impl_path: @path,
253-
m: @method, &&cx: @mut Ctx) {
253+
m: @method, cx: @mut Ctx) {
254254
cx.map.insert(m.id, node_method(m, impl_did, impl_path));
255255
cx.map.insert(m.self_id, node_local(cx.local_id));
256256
cx.local_id += 1u;
257257
}
258258

259-
pub fn map_item(i: @item, &&cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
259+
pub fn map_item(i: @item, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
260260
let item_path = @/* FIXME (#2543) */ copy cx.path;
261261
cx.map.insert(i.id, node_item(i, item_path));
262262
match i.node {
@@ -355,13 +355,13 @@ pub fn map_struct_def(
355355
}
356356
}
357357
358-
pub fn map_expr(ex: @expr, &&cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
358+
pub fn map_expr(ex: @expr, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
359359
cx.map.insert(ex.id, node_expr(ex));
360360
visit::visit_expr(ex, cx, v);
361361
}
362362
363-
pub fn map_stmt(stmt: @stmt, &&cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
364-
cx.map.insert(stmt_id(*stmt), node_stmt(stmt));
363+
pub fn map_stmt(stmt: @stmt, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
364+
cx.map.insert(stmt_id(stmt), node_stmt(stmt));
365365
visit::visit_stmt(stmt, cx, v);
366366
}
367367
@@ -408,7 +408,7 @@ pub fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str {
408408
}
409409
Some(&node_stmt(stmt)) => {
410410
fmt!("stmt %s (id=%?)",
411-
pprust::stmt_to_str(*stmt, itr), id)
411+
pprust::stmt_to_str(stmt, itr), id)
412412
}
413413
Some(&node_arg(_, _)) => { // add more info here
414414
fmt!("arg (id=%?)", id)
@@ -430,7 +430,7 @@ pub fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str {
430430

431431
pub fn node_item_query<Result>(items: map, id: node_id,
432432
query: &fn(@item) -> Result,
433-
+error_msg: ~str) -> Result {
433+
error_msg: ~str) -> Result {
434434
match items.find(&id) {
435435
Some(&node_item(it, _)) => query(it),
436436
_ => fail!(error_msg)

src/libsyntax/ast_util.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn local_def(id: node_id) -> def_id {
3939

4040
pub fn is_local(did: ast::def_id) -> bool { did.crate == local_crate }
4141

42-
pub fn stmt_id(s: stmt) -> node_id {
42+
pub fn stmt_id(s: &stmt) -> node_id {
4343
match s.node {
4444
stmt_decl(_, id) => id,
4545
stmt_expr(_, id) => id,
@@ -200,7 +200,7 @@ pub fn is_call_expr(e: @expr) -> bool {
200200
// This makes def_id hashable
201201
impl to_bytes::IterBytes for def_id {
202202
#[inline(always)]
203-
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
203+
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
204204
to_bytes::iter_bytes_2(&self.crate, &self.node, lsb0, f);
205205
}
206206
}
@@ -211,7 +211,7 @@ pub fn block_from_expr(e: @expr) -> blk {
211211
}
212212
213213
pub fn default_block(
214-
+stmts1: ~[@stmt],
214+
stmts1: ~[@stmt],
215215
expr1: Option<@expr>,
216216
id1: node_id
217217
) -> blk_ {
@@ -224,15 +224,15 @@ pub fn default_block(
224224
}
225225
}
226226
227-
pub fn ident_to_path(s: span, +i: ident) -> @Path {
227+
pub fn ident_to_path(s: span, i: ident) -> @Path {
228228
@ast::Path { span: s,
229229
global: false,
230230
idents: ~[i],
231231
rp: None,
232232
types: ~[] }
233233
}
234234
235-
pub fn ident_to_pat(id: node_id, s: span, +i: ident) -> @pat {
235+
pub fn ident_to_pat(id: node_id, s: span, i: ident) -> @pat {
236236
@ast::pat { id: id,
237237
node: pat_ident(bind_by_copy, ident_to_path(s, i), None),
238238
span: s }
@@ -300,7 +300,7 @@ pub fn struct_field_visibility(field: ast::struct_field) -> visibility {
300300
pub trait inlined_item_utils {
301301
fn ident(&self) -> ident;
302302
fn id(&self) -> ast::node_id;
303-
fn accept<E>(&self, e: E, v: visit::vt<E>);
303+
fn accept<E: Copy>(&self, e: E, v: visit::vt<E>);
304304
}
305305
306306
impl inlined_item_utils for inlined_item {
@@ -322,7 +322,7 @@ impl inlined_item_utils for inlined_item {
322322
}
323323
}
324324
325-
fn accept<E>(&self, e: E, v: visit::vt<E>) {
325+
fn accept<E: Copy>(&self, e: E, v: visit::vt<E>) {
326326
match *self {
327327
ii_item(i) => (v.visit_item)(i, e, v),
328328
ii_foreign(i) => (v.visit_foreign_item)(i, e, v),
@@ -435,7 +435,7 @@ pub fn id_visitor(vfn: @fn(node_id)) -> visit::vt<()> {
435435
436436
visit_local: |l| vfn(l.node.id),
437437
visit_block: |b| vfn(b.node.id),
438-
visit_stmt: |s| vfn(ast_util::stmt_id(*s)),
438+
visit_stmt: |s| vfn(ast_util::stmt_id(s)),
439439
visit_arm: |_| {},
440440
visit_pat: |p| vfn(p.id),
441441
visit_decl: |_| {},
@@ -491,7 +491,7 @@ pub fn id_visitor(vfn: @fn(node_id)) -> visit::vt<()> {
491491
})
492492
}
493493
494-
pub fn visit_ids_for_inlined_item(item: inlined_item, vfn: @fn(node_id)) {
494+
pub fn visit_ids_for_inlined_item(item: &inlined_item, vfn: @fn(node_id)) {
495495
item.accept((), id_visitor(vfn));
496496
}
497497
@@ -505,7 +505,7 @@ pub fn compute_id_range(visit_ids_fn: &fn(@fn(node_id))) -> id_range {
505505
id_range { min: *min, max: *max }
506506
}
507507
508-
pub fn compute_id_range_for_inlined_item(item: inlined_item) -> id_range {
508+
pub fn compute_id_range_for_inlined_item(item: &inlined_item) -> id_range {
509509
compute_id_range(|f| visit_ids_for_inlined_item(item, f))
510510
}
511511
@@ -609,7 +609,7 @@ pub fn mk_rename (id:ident, to:Name, tail:SyntaxContext, table: &mut SCTable)
609609
pub fn mk_sctable() -> SCTable { ~[EmptyCtxt] }
610610
611611
/// Add a value to the end of a vec, return its index
612-
fn idx_push<T>(vec: &mut ~[T], +val: T) -> uint {
612+
fn idx_push<T>(vec: &mut ~[T], val: T) -> uint {
613613
vec.push(val);
614614
vec.len() - 1
615615
}

src/libsyntax/attr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ pub fn mk_name_value_item_str(name: @~str, value: @~str)
3131
mk_name_value_item(name, value_lit)
3232
}
3333

34-
pub fn mk_name_value_item(name: @~str, +value: ast::lit)
34+
pub fn mk_name_value_item(name: @~str, value: ast::lit)
3535
-> @ast::meta_item {
3636
@dummy_spanned(ast::meta_name_value(name, value))
3737
}
3838

39-
pub fn mk_list_item(name: @~str, +items: ~[@ast::meta_item]) ->
39+
pub fn mk_list_item(name: @~str, items: ~[@ast::meta_item]) ->
4040
@ast::meta_item {
4141
@dummy_spanned(ast::meta_list(name, items))
4242
}
@@ -51,8 +51,8 @@ pub fn mk_attr(item: @ast::meta_item) -> ast::attribute {
5151
is_sugared_doc: false })
5252
}
5353

54-
pub fn mk_sugared_doc_attr(+text: ~str,
55-
+lo: BytePos, +hi: BytePos) -> ast::attribute {
54+
pub fn mk_sugared_doc_attr(text: ~str,
55+
lo: BytePos, hi: BytePos) -> ast::attribute {
5656
let style = doc_comment_style(text);
5757
let lit = spanned(lo, hi, ast::lit_str(@text));
5858
let attr = ast::attribute_ {

0 commit comments

Comments
 (0)