Skip to content

Commit efc5123

Browse files
committed
libsyntax: Remove all non-proc do syntax.
1 parent a61a367 commit efc5123

26 files changed

+178
-192
lines changed

src/libsyntax/abi.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ pub fn lookup(name: &str) -> Option<Abi> {
104104

105105
let mut res = None;
106106

107-
do each_abi |abi| {
107+
each_abi(|abi| {
108108
if name == abi.data().name {
109109
res = Some(abi);
110110
false
111111
} else {
112112
true
113113
}
114-
};
114+
});
115115
res
116116
}
117117

@@ -217,21 +217,21 @@ impl AbiSet {
217217

218218
let mut res = None;
219219

220-
do self.each |abi| {
220+
self.each(|abi| {
221221
let data = abi.data();
222222
match data.abi_arch {
223223
Archs(a) if (a & arch.bit()) != 0 => { res = Some(abi); false }
224224
Archs(_) => { true }
225225
RustArch | AllArch => { res = Some(abi); false }
226226
}
227-
};
227+
});
228228

229229
res.map(|r| r.for_target(os, arch))
230230
}
231231

232232
pub fn check_valid(&self) -> Option<(Abi, Abi)> {
233233
let mut abis = ~[];
234-
do self.each |abi| { abis.push(abi); true };
234+
self.each(|abi| { abis.push(abi); true });
235235

236236
for (i, abi) in abis.iter().enumerate() {
237237
let data = abi.data();
@@ -285,10 +285,10 @@ impl ToStr for Abi {
285285
impl ToStr for AbiSet {
286286
fn to_str(&self) -> ~str {
287287
let mut strs = ~[];
288-
do self.each |abi| {
288+
self.each(|abi| {
289289
strs.push(abi.data().name);
290290
true
291-
};
291+
});
292292
format!("\"{}\"", strs.connect(" "))
293293
}
294294
}

src/libsyntax/ast_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ pub type path = ~[path_elt];
5252

5353
pub fn path_to_str_with_sep(p: &[path_elt], sep: &str, itr: @ident_interner)
5454
-> ~str {
55-
let strs = do p.map |e| {
55+
let strs = p.map(|e| {
5656
match *e {
5757
path_mod(s) | path_name(s) | path_pretty_name(s, _) => {
5858
itr.get(s.name)
5959
}
6060
}
61-
};
61+
});
6262
strs.connect(sep)
6363
}
6464

src/libsyntax/ast_util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,12 @@ pub fn unguarded_pat(a: &Arm) -> Option<~[@Pat]> {
254254
}
255255

256256
pub fn public_methods(ms: ~[@method]) -> ~[@method] {
257-
do ms.move_iter().filter |m| {
257+
ms.move_iter().filter(|m| {
258258
match m.vis {
259259
public => true,
260260
_ => false
261261
}
262-
}.collect()
262+
}).collect()
263263
}
264264

265265
// extract a TypeMethod from a trait_method. if the trait_method is

src/libsyntax/attr.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,18 @@ pub fn mk_sugared_doc_attr(text: @str, lo: BytePos, hi: BytePos) -> Attribute {
169169
pub fn contains(haystack: &[@ast::MetaItem],
170170
needle: @ast::MetaItem) -> bool {
171171
debug!("attr::contains (name={})", needle.name());
172-
do haystack.iter().any |item| {
172+
haystack.iter().any(|item| {
173173
debug!(" testing: {}", item.name());
174174
item.node == needle.node
175-
}
175+
})
176176
}
177177

178178
pub fn contains_name<AM: AttrMetaMethods>(metas: &[AM], name: &str) -> bool {
179179
debug!("attr::contains_name (name={})", name);
180-
do metas.iter().any |item| {
180+
metas.iter().any(|item| {
181181
debug!(" testing: {}", item.name());
182182
name == item.name()
183-
}
183+
})
184184
}
185185

186186
pub fn first_attr_value_str_by_name(attrs: &[Attribute], name: &str)
@@ -204,12 +204,10 @@ pub fn sort_meta_items(items: &[@MetaItem]) -> ~[@MetaItem] {
204204
.map(|&mi| (mi.name(), mi))
205205
.collect::<~[(@str, @MetaItem)]>();
206206

207-
do extra::sort::quick_sort(v) |&(a, _), &(b, _)| {
208-
a <= b
209-
}
207+
extra::sort::quick_sort(v, |&(a, _), &(b, _)| a <= b);
210208

211209
// There doesn't seem to be a more optimal way to do this
212-
do v.move_iter().map |(_, m)| {
210+
v.move_iter().map(|(_, m)| {
213211
match m.node {
214212
MetaList(n, ref mis) => {
215213
@Spanned {
@@ -219,7 +217,7 @@ pub fn sort_meta_items(items: &[@MetaItem]) -> ~[@MetaItem] {
219217
}
220218
_ => m
221219
}
222-
}.collect()
220+
}).collect()
223221
}
224222

225223
/**
@@ -248,7 +246,7 @@ pub enum InlineAttr {
248246
/// True if something like #[inline] is found in the list of attrs.
249247
pub fn find_inline_attr(attrs: &[Attribute]) -> InlineAttr {
250248
// FIXME (#2809)---validate the usage of #[inline] and #[inline]
251-
do attrs.iter().fold(InlineNone) |ia,attr| {
249+
attrs.iter().fold(InlineNone, |ia,attr| {
252250
match attr.node.value.node {
253251
MetaWord(n) if "inline" == n => InlineHint,
254252
MetaList(n, ref items) if "inline" == n => {
@@ -262,7 +260,7 @@ pub fn find_inline_attr(attrs: &[Attribute]) -> InlineAttr {
262260
}
263261
_ => ia
264262
}
265-
}
263+
})
266264
}
267265

268266
/// Tests if any `cfg(...)` meta items in `metas` match `cfg`. e.g.
@@ -278,7 +276,7 @@ pub fn test_cfg<AM: AttrMetaMethods, It: Iterator<AM>>
278276

279277
// this would be much nicer as a chain of iterator adaptors, but
280278
// this doesn't work.
281-
let some_cfg_matches = do metas.any |mi| {
279+
let some_cfg_matches = metas.any(|mi| {
282280
debug!("testing name: {}", mi.name());
283281
if "cfg" == mi.name() { // it is a #[cfg()] attribute
284282
debug!("is cfg");
@@ -287,7 +285,7 @@ pub fn test_cfg<AM: AttrMetaMethods, It: Iterator<AM>>
287285
match mi.meta_item_list() {
288286
Some(cfg_meta) => {
289287
debug!("is cfg(...)");
290-
do cfg_meta.iter().all |cfg_mi| {
288+
cfg_meta.iter().all(|cfg_mi| {
291289
debug!("cfg({}[...])", cfg_mi.name());
292290
match cfg_mi.node {
293291
ast::MetaList(s, ref not_cfgs) if "not" == s => {
@@ -301,14 +299,14 @@ pub fn test_cfg<AM: AttrMetaMethods, It: Iterator<AM>>
301299
}
302300
_ => contains(cfg, *cfg_mi)
303301
}
304-
}
302+
})
305303
}
306304
None => false
307305
}
308306
} else {
309307
false
310308
}
311-
};
309+
});
312310
debug!("test_cfg (no_cfgs={}, some_cfg_matches={})", no_cfgs, some_cfg_matches);
313311
no_cfgs || some_cfg_matches
314312
}

src/libsyntax/diagnostic.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,7 @@ fn highlight_lines(cm: @codemap::CodeMap,
314314
// Skip is the number of characters we need to skip because they are
315315
// part of the 'filename:line ' part of the previous line.
316316
let skip = fm.name.len() + digits + 3u;
317-
do skip.times() {
318-
s.push_char(' ');
319-
}
317+
skip.times(|| s.push_char(' '));
320318
let orig = fm.get_line(lines.lines[0] as int);
321319
for pos in range(0u, left-skip) {
322320
let curChar = (orig[pos] as char);
@@ -335,9 +333,7 @@ fn highlight_lines(cm: @codemap::CodeMap,
335333
if hi.col != lo.col {
336334
// the ^ already takes up one space
337335
let num_squigglies = hi.col.to_uint()-lo.col.to_uint()-1u;
338-
do num_squigglies.times() {
339-
s.push_char('~')
340-
}
336+
num_squigglies.times(|| s.push_char('~'));
341337
}
342338
print_maybe_styled(s + "\n", term::attr::ForegroundColor(diagnosticcolor(lvl)));
343339
}

src/libsyntax/ext/build.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,9 @@ impl AstBuilder for @ExtCtxt {
370370
}
371371

372372
fn strip_bounds(&self, generics: &Generics) -> Generics {
373-
let new_params = do generics.ty_params.map |ty_param| {
373+
let new_params = generics.ty_params.map(|ty_param| {
374374
ast::TyParam { bounds: opt_vec::Empty, ..*ty_param }
375-
};
375+
});
376376
Generics {
377377
ty_params: new_params,
378378
.. (*generics).clone()
@@ -883,9 +883,9 @@ impl AstBuilder for @ExtCtxt {
883883

884884
fn view_use_list(&self, sp: Span, vis: ast::visibility,
885885
path: ~[ast::Ident], imports: &[ast::Ident]) -> ast::view_item {
886-
let imports = do imports.map |id| {
886+
let imports = imports.map(|id| {
887887
respan(sp, ast::path_list_ident_ { name: *id, id: ast::DUMMY_NODE_ID })
888-
};
888+
});
889889

890890
self.view_use(sp, vis,
891891
~[@respan(sp,

src/libsyntax/ext/deriving/clone.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ fn cs_clone(
103103
},
104104
_ => {
105105
// struct-like
106-
let fields = do all_fields.map |field| {
106+
let fields = all_fields.map(|field| {
107107
let ident = match field.name {
108108
Some(i) => i,
109109
None => cx.span_bug(span,
110110
format!("unnamed field in normal struct in `deriving({})`",
111111
name))
112112
};
113113
cx.field_imm(span, ident, subcall(field.self_))
114-
};
114+
});
115115

116116
if fields.is_empty() {
117117
// no fields, so construct like `None`

src/libsyntax/ext/deriving/decodable.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,16 @@ fn decodable_substructure(cx: @ExtCtxt, span: Span,
7070
};
7171
let read_struct_field = cx.ident_of("read_struct_field");
7272

73-
let result = do decode_static_fields(cx, span, substr.type_ident,
74-
summary) |span, name, field| {
73+
let result = decode_static_fields(cx,
74+
span,
75+
substr.type_ident,
76+
summary,
77+
|span, name, field| {
7578
cx.expr_method_call(span, blkdecoder, read_struct_field,
7679
~[cx.expr_str(span, name),
7780
cx.expr_uint(span, field),
7881
lambdadecode])
79-
};
82+
});
8083
cx.expr_method_call(span, decoder, cx.ident_of("read_struct"),
8184
~[cx.expr_str(span, cx.str_of(substr.type_ident)),
8285
cx.expr_uint(span, nfields),
@@ -93,12 +96,15 @@ fn decodable_substructure(cx: @ExtCtxt, span: Span,
9396
let (name, parts) = match *f { (i, ref p) => (i, p) };
9497
variants.push(cx.expr_str(span, cx.str_of(name)));
9598

96-
let decoded = do decode_static_fields(cx, span, name,
97-
parts) |span, _, field| {
99+
let decoded = decode_static_fields(cx,
100+
span,
101+
name,
102+
parts,
103+
|span, _, field| {
98104
cx.expr_method_call(span, blkdecoder, rvariant_arg,
99105
~[cx.expr_uint(span, field),
100106
lambdadecode])
101-
};
107+
});
102108

103109
arms.push(cx.arm(span,
104110
~[cx.pat_lit(span, cx.expr_uint(span, i))],
@@ -135,18 +141,18 @@ fn decode_static_fields(cx: @ExtCtxt,
135141
if fields.is_empty() {
136142
cx.expr_ident(outer_span, outer_pat_ident)
137143
} else {
138-
let fields = do fields.iter().enumerate().map |(i, &span)| {
144+
let fields = fields.iter().enumerate().map(|(i, &span)| {
139145
getarg(span, format!("_field{}", i).to_managed(), i)
140-
}.collect();
146+
}).collect();
141147

142148
cx.expr_call_ident(outer_span, outer_pat_ident, fields)
143149
}
144150
}
145151
Named(ref fields) => {
146152
// use the field's span to get nicer error messages.
147-
let fields = do fields.iter().enumerate().map |(i, &(name, span))| {
153+
let fields = fields.iter().enumerate().map(|(i, &(name, span))| {
148154
cx.field_imm(span, name, getarg(span, cx.str_of(name), i))
149-
}.collect();
155+
}).collect();
150156
cx.expr_struct_ident(outer_span, outer_pat_ident, fields)
151157
}
152158
}

src/libsyntax/ext/deriving/default.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ fn default_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Exp
6060
}
6161
}
6262
Named(ref fields) => {
63-
let default_fields = do fields.map |&(ident, span)| {
63+
let default_fields = fields.map(|&(ident, span)| {
6464
cx.field_imm(span, ident, default_call(span))
65-
};
65+
});
6666
cx.expr_struct_ident(span, substr.type_ident, default_fields)
6767
}
6868
}

src/libsyntax/ext/deriving/encodable.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ would generate two implementations like:
2424
2525
impl<S:extra::serialize::Encoder> Encodable<S> for Node {
2626
fn encode(&self, s: &S) {
27-
do s.emit_struct("Node", 1) {
27+
s.emit_struct("Node", 1, || {
2828
s.emit_field("id", 0, || s.emit_uint(self.id))
29-
}
29+
})
3030
}
3131
}
3232
3333
impl<D:Decoder> Decodable for node_id {
3434
fn decode(d: &D) -> Node {
35-
do d.read_struct("Node", 1) {
35+
d.read_struct("Node", 1, || {
3636
Node {
3737
id: d.read_field(~"x", 0, || decode(d))
3838
}
39-
}
39+
})
4040
}
4141
}
4242
@@ -53,10 +53,10 @@ would yield functions like:
5353
T: Encodable<S>
5454
> spanned<T>: Encodable<S> {
5555
fn encode<S:Encoder>(s: &S) {
56-
do s.emit_rec {
56+
s.emit_rec(|| {
5757
s.emit_field("node", 0, || self.node.encode(s));
5858
s.emit_field("span", 1, || self.span.encode(s));
59-
}
59+
})
6060
}
6161
}
6262
@@ -65,12 +65,12 @@ would yield functions like:
6565
T: Decodable<D>
6666
> spanned<T>: Decodable<D> {
6767
fn decode(d: &D) -> spanned<T> {
68-
do d.read_rec {
68+
d.read_rec(|| {
6969
{
7070
node: d.read_field(~"node", 0, || decode(d)),
7171
span: d.read_field(~"span", 1, || decode(d)),
7272
}
73-
}
73+
})
7474
}
7575
}
7676
*/

0 commit comments

Comments
 (0)