syntax: Make match arm parsing more restrictive again
Require comma separators for all expression types except the plain block
This commit is contained in:
parent
abf4421e7c
commit
2772b2e5c7
@ -30,18 +30,18 @@ impl private_methods<T> for dlist_node<T> {
|
||||
some(neighbour) => match neighbour.prev {
|
||||
some(me) => if !box::ptr_eq(*self, *me) {
|
||||
fail ~"Asymmetric next-link in dlist node."
|
||||
}
|
||||
},
|
||||
none => fail ~"One-way next-link in dlist node."
|
||||
}
|
||||
},
|
||||
none => ()
|
||||
}
|
||||
match self.prev {
|
||||
some(neighbour) => match neighbour.next {
|
||||
some(me) => if !box::ptr_eq(*me, *self) {
|
||||
fail ~"Asymmetric prev-link in dlist node."
|
||||
}
|
||||
},
|
||||
none => fail ~"One-way prev-link in dlist node."
|
||||
}
|
||||
},
|
||||
none => ()
|
||||
}
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ fn homedir() -> option<path> {
|
||||
some(p)
|
||||
} else {
|
||||
secondary()
|
||||
}
|
||||
},
|
||||
none => secondary()
|
||||
};
|
||||
|
||||
|
@ -425,7 +425,7 @@ fn try_recv<T: send, Tbuffer: send>(-p: recv_packet_buffered<T, Tbuffer>)
|
||||
}
|
||||
blocked => if first {
|
||||
fail ~"blocking on already blocked packet"
|
||||
}
|
||||
},
|
||||
full => {
|
||||
let mut payload = none;
|
||||
payload <-> p.payload;
|
||||
@ -717,7 +717,7 @@ struct send_packet_buffered<T: send, Tbuffer: send> {
|
||||
let header = ptr::addr_of(packet.header);
|
||||
//forget(packet);
|
||||
header
|
||||
}
|
||||
},
|
||||
none => fail ~"packet already consumed"
|
||||
}
|
||||
}
|
||||
@ -778,7 +778,7 @@ struct recv_packet_buffered<T: send, Tbuffer: send> : selectable {
|
||||
let header = ptr::addr_of(packet.header);
|
||||
//forget(packet);
|
||||
header
|
||||
}
|
||||
},
|
||||
none => fail ~"packet already consumed"
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ mod linear {
|
||||
match buckets[i] {
|
||||
some(bkt) => if bkt.hash == hash && self.eqfn(k, &bkt.key) {
|
||||
return found_entry(i);
|
||||
}
|
||||
},
|
||||
none => return found_hole(i)
|
||||
}
|
||||
};
|
||||
|
@ -186,9 +186,9 @@ class bitv {
|
||||
intersect => s.intersect(s1),
|
||||
assign => s.become(s1),
|
||||
difference => s.difference(s1)
|
||||
}
|
||||
},
|
||||
big(s1) => self.die()
|
||||
}
|
||||
},
|
||||
big(s) => match other.rep {
|
||||
small(_) => self.die(),
|
||||
big(s1) => match op {
|
||||
@ -282,7 +282,7 @@ class bitv {
|
||||
small(b) => match v1.rep {
|
||||
small(b1) => b.equals(b1),
|
||||
_ => false
|
||||
}
|
||||
},
|
||||
big(s) => match v1.rep {
|
||||
big(s1) => s.equals(s1),
|
||||
small(_) => return false
|
||||
|
@ -242,11 +242,11 @@ mod tests {
|
||||
one(a1) => match b {
|
||||
one(b1) => return a1 == b1,
|
||||
_ => return false
|
||||
}
|
||||
},
|
||||
two(a1, a2) => match b {
|
||||
two(b1, b2) => return a1 == b1 && a2 == b2,
|
||||
_ => return false
|
||||
}
|
||||
},
|
||||
three(a1, a2, a3) => match b {
|
||||
three(b1, b2, b3) => return a1 == b1 && a2 == b2 && a3 == b3,
|
||||
_ => return false
|
||||
@ -258,11 +258,11 @@ mod tests {
|
||||
onepar::<T>(a1) => match b {
|
||||
onepar::<T>(b1) => return a1 == b1,
|
||||
_ => return false
|
||||
}
|
||||
},
|
||||
twopar::<T>(a1, a2) => match b {
|
||||
twopar::<T>(b1, b2) => return a1 == b1 && a2 == b2,
|
||||
_ => return false
|
||||
}
|
||||
},
|
||||
threepar::<T>(a1, a2, a3) => match b {
|
||||
threepar::<T>(b1, b2, b3) => {
|
||||
return a1 == b1 && a2 == b2 && a3 == b3
|
||||
|
@ -172,7 +172,7 @@ impl parser for parser {
|
||||
'"' => match self.parse_str() {
|
||||
ok(s) => ok(string(s)),
|
||||
err(e) => err(e)
|
||||
}
|
||||
},
|
||||
'[' => self.parse_list(),
|
||||
'{' => self.parse_object(),
|
||||
_ => self.error(~"invalid syntax")
|
||||
|
@ -54,7 +54,7 @@ fn format_addr(ip: ip_addr) -> ~str {
|
||||
fail ~"failed to convert inner sockaddr_in address to str"
|
||||
}
|
||||
result
|
||||
}
|
||||
},
|
||||
ipv6(addr) => unsafe {
|
||||
let result = uv_ip6_name(&addr);
|
||||
if result == ~"" {
|
||||
|
@ -245,7 +245,7 @@ fn serialize_option<S: serializer,T>(s: S, v: option<T>, st: fn(T)) {
|
||||
do s.emit_enum(~"option") {
|
||||
match v {
|
||||
none => do s.emit_enum_variant(~"none", 0u, 0u) {
|
||||
}
|
||||
},
|
||||
|
||||
some(v) => do s.emit_enum_variant(~"some", 1u, 1u) {
|
||||
do s.emit_enum_variant_arg(0u) {
|
||||
|
@ -104,7 +104,7 @@ impl <V: copy> of map::map<uint, V> for smallintmap<V> {
|
||||
let mut idx = 0u, l = self.v.len();
|
||||
while idx < l {
|
||||
match self.v.get_elt(idx) {
|
||||
some(elt) => if !it(idx, elt) { break }
|
||||
some(elt) => if !it(idx, elt) { break },
|
||||
none => ()
|
||||
}
|
||||
idx += 1u;
|
||||
@ -120,7 +120,7 @@ impl <V: copy> of map::map<uint, V> for smallintmap<V> {
|
||||
let mut idx = 0u, l = self.v.len();
|
||||
while idx < l {
|
||||
match self.v.get_elt(idx) {
|
||||
some(elt) => if !it(&idx, &elt) { break }
|
||||
some(elt) => if !it(&idx, &elt) { break },
|
||||
none => ()
|
||||
}
|
||||
idx += 1u;
|
||||
|
@ -146,7 +146,7 @@ fn run_tests_console(opts: test_opts,
|
||||
result::err(s) => {
|
||||
fail(fmt!{"can't open output file: %s", s})
|
||||
}
|
||||
}
|
||||
},
|
||||
none => none
|
||||
};
|
||||
|
||||
|
@ -220,7 +220,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> {
|
||||
]) {
|
||||
some(item) => { let (v, pos) = item; tm.tm_wday = v; ok(pos) }
|
||||
none => err(~"Invalid day")
|
||||
}
|
||||
},
|
||||
'a' => match match_strs(s, pos, ~[
|
||||
(~"Sun", 0_i32),
|
||||
(~"Mon", 1_i32),
|
||||
@ -232,7 +232,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> {
|
||||
]) {
|
||||
some(item) => { let (v, pos) = item; tm.tm_wday = v; ok(pos) }
|
||||
none => err(~"Invalid day")
|
||||
}
|
||||
},
|
||||
'B' => match match_strs(s, pos, ~[
|
||||
(~"January", 0_i32),
|
||||
(~"February", 1_i32),
|
||||
@ -249,7 +249,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> {
|
||||
]) {
|
||||
some(item) => { let (v, pos) = item; tm.tm_mon = v; ok(pos) }
|
||||
none => err(~"Invalid month")
|
||||
}
|
||||
},
|
||||
'b' | 'h' => match match_strs(s, pos, ~[
|
||||
(~"Jan", 0_i32),
|
||||
(~"Feb", 1_i32),
|
||||
@ -266,7 +266,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> {
|
||||
]) {
|
||||
some(item) => { let (v, pos) = item; tm.tm_mon = v; ok(pos) }
|
||||
none => err(~"Invalid month")
|
||||
}
|
||||
},
|
||||
'C' => match match_digits(s, pos, 2u, false) {
|
||||
some(item) => {
|
||||
let (v, pos) = item;
|
||||
@ -274,7 +274,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> {
|
||||
ok(pos)
|
||||
}
|
||||
none => err(~"Invalid year")
|
||||
}
|
||||
},
|
||||
'c' => {
|
||||
parse_type(s, pos, 'a', tm)
|
||||
.chain(|pos| parse_char(s, pos, ' '))
|
||||
@ -296,11 +296,11 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> {
|
||||
'd' => match match_digits(s, pos, 2u, false) {
|
||||
some(item) => { let (v, pos) = item; tm.tm_mday = v; ok(pos) }
|
||||
none => err(~"Invalid day of the month")
|
||||
}
|
||||
},
|
||||
'e' => match match_digits(s, pos, 2u, true) {
|
||||
some(item) => { let (v, pos) = item; tm.tm_mday = v; ok(pos) }
|
||||
none => err(~"Invalid day of the month")
|
||||
}
|
||||
},
|
||||
'F' => {
|
||||
parse_type(s, pos, 'Y', tm)
|
||||
.chain(|pos| parse_char(s, pos, '-'))
|
||||
@ -379,13 +379,13 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> {
|
||||
|
||||
some(item) => { let (v, pos) = item; tm.tm_hour += v; ok(pos) }
|
||||
none => err(~"Invalid hour")
|
||||
}
|
||||
},
|
||||
'p' => match match_strs(s, pos,
|
||||
~[(~"AM", 0_i32), (~"PM", 12_i32)]) {
|
||||
|
||||
some(item) => { let (v, pos) = item; tm.tm_hour += v; ok(pos) }
|
||||
none => err(~"Invalid hour")
|
||||
}
|
||||
},
|
||||
'R' => {
|
||||
parse_type(s, pos, 'H', tm)
|
||||
.chain(|pos| parse_char(s, pos, ':'))
|
||||
@ -542,7 +542,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> {
|
||||
'%' => match parse_type(s, pos, rdr.read_char(), tm) {
|
||||
ok(next) => pos = next,
|
||||
err(e) => { result = err(e); break; }
|
||||
}
|
||||
},
|
||||
c => {
|
||||
if c != ch { break }
|
||||
pos = next;
|
||||
@ -581,7 +581,7 @@ fn strftime(format: ~str, tm: tm) -> ~str {
|
||||
4 => ~"Thursday",
|
||||
5 => ~"Friday",
|
||||
6 => ~"Saturday"
|
||||
}
|
||||
},
|
||||
'a' => match check tm.tm_wday as int {
|
||||
0 => ~"Sun",
|
||||
1 => ~"Mon",
|
||||
@ -590,7 +590,7 @@ fn strftime(format: ~str, tm: tm) -> ~str {
|
||||
4 => ~"Thu",
|
||||
5 => ~"Fri",
|
||||
6 => ~"Sat"
|
||||
}
|
||||
},
|
||||
'B' => match check tm.tm_mon as int {
|
||||
0 => ~"January",
|
||||
1 => ~"February",
|
||||
@ -604,7 +604,7 @@ fn strftime(format: ~str, tm: tm) -> ~str {
|
||||
9 => ~"October",
|
||||
10 => ~"November",
|
||||
11 => ~"December"
|
||||
}
|
||||
},
|
||||
'b' | 'h' => match check tm.tm_mon as int {
|
||||
0 => ~"Jan",
|
||||
1 => ~"Feb",
|
||||
@ -618,7 +618,7 @@ fn strftime(format: ~str, tm: tm) -> ~str {
|
||||
9 => ~"Oct",
|
||||
10 => ~"Nov",
|
||||
11 => ~"Dec",
|
||||
}
|
||||
},
|
||||
'C' => fmt!{"%02d", (tm.tm_year as int + 1900) / 100},
|
||||
'c' => {
|
||||
fmt!{"%s %s %s %s %s",
|
||||
@ -662,8 +662,8 @@ fn strftime(format: ~str, tm: tm) -> ~str {
|
||||
'M' => fmt!{"%02d", tm.tm_min as int},
|
||||
'm' => fmt!{"%02d", tm.tm_mon as int + 1},
|
||||
'n' => ~"\n",
|
||||
'P' => if tm.tm_hour as int < 12 { ~"am" } else { ~"pm" }
|
||||
'p' => if tm.tm_hour as int < 12 { ~"AM" } else { ~"PM" }
|
||||
'P' => if tm.tm_hour as int < 12 { ~"am" } else { ~"pm" },
|
||||
'p' => if tm.tm_hour as int < 12 { ~"AM" } else { ~"PM" },
|
||||
'R' => {
|
||||
fmt!{"%s:%s",
|
||||
parse_type('H', tm),
|
||||
|
@ -270,7 +270,7 @@ fn map_view_item(vi: @view_item, cx: ctx, _v: vt) {
|
||||
}
|
||||
};
|
||||
cx.map.insert(id, node_export(vp, extend(cx, name)));
|
||||
}
|
||||
},
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ fn is_exported(i: ident, m: _mod) -> bool {
|
||||
local = true;
|
||||
parent_enum = some(/* FIXME (#2543) */ copy it.ident);
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => ()
|
||||
}
|
||||
if local { break; }
|
||||
@ -476,7 +476,7 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> {
|
||||
visit_item: fn@(i: @item) {
|
||||
vfn(i.id);
|
||||
match i.node {
|
||||
item_enum(vs, _) => for vs.each |v| { vfn(v.node.id); }
|
||||
item_enum(vs, _) => for vs.each |v| { vfn(v.node.id); },
|
||||
_ => ()
|
||||
}
|
||||
},
|
||||
@ -603,10 +603,10 @@ fn walk_pat(pat: @pat, it: fn(@pat)) {
|
||||
match pat.node {
|
||||
pat_ident(_, pth, some(p)) => walk_pat(p, it),
|
||||
pat_rec(fields, _) | pat_struct(_, fields, _) =>
|
||||
for fields.each |f| { walk_pat(f.pat, it) }
|
||||
for fields.each |f| { walk_pat(f.pat, it) },
|
||||
pat_enum(_, some(s)) | pat_tup(s) => for s.each |p| {
|
||||
walk_pat(p, it)
|
||||
}
|
||||
},
|
||||
pat_box(s) | pat_uniq(s) => walk_pat(s, it),
|
||||
pat_wild | pat_lit(_) | pat_range(_, _) | pat_ident(_, _, _)
|
||||
| pat_enum(_, _) => ()
|
||||
|
@ -130,7 +130,7 @@ fn get_meta_item_value_str(meta: @ast::meta_item) -> option<@~str> {
|
||||
ast::meta_name_value(_, v) => match v.node {
|
||||
ast::lit_str(s) => option::some(s),
|
||||
_ => option::none
|
||||
}
|
||||
},
|
||||
_ => option::none
|
||||
}
|
||||
}
|
||||
@ -207,11 +207,11 @@ fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool {
|
||||
ast::meta_word(na) => match b.node {
|
||||
ast::meta_word(nb) => na == nb,
|
||||
_ => false
|
||||
}
|
||||
},
|
||||
ast::meta_name_value(na, va) => match b.node {
|
||||
ast::meta_name_value(nb, vb) => na == nb && va.node == vb.node,
|
||||
_ => false
|
||||
}
|
||||
},
|
||||
ast::meta_list(na, la) => {
|
||||
|
||||
// ~[Fixme-sorting]
|
||||
@ -257,7 +257,7 @@ fn last_meta_item_value_str_by_name(
|
||||
some(item) => match attr::get_meta_item_value_str(item) {
|
||||
some(value) => some(value),
|
||||
none => none
|
||||
}
|
||||
},
|
||||
none => none
|
||||
}
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, error: ~str) -> ~str {
|
||||
ast::expr_lit(l) => match l.node {
|
||||
ast::lit_str(s) => return *s,
|
||||
_ => cx.span_fatal(l.span, error)
|
||||
}
|
||||
},
|
||||
_ => cx.span_fatal(expr.span, error)
|
||||
}
|
||||
}
|
||||
@ -257,7 +257,7 @@ fn get_mac_args(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
|
||||
_ => {
|
||||
cx.span_fatal(sp, fmt!{"#%s: malformed invocation", name})
|
||||
}
|
||||
}
|
||||
},
|
||||
none => cx.span_fatal(sp, fmt!{"#%s: missing arguments", name})
|
||||
}
|
||||
}
|
||||
@ -302,7 +302,7 @@ fn tt_args_to_original_flavor(cx: ext_ctxt, sp: span, arg: ~[ast::token_tree])
|
||||
}
|
||||
_ => fail ~"badly-structured parse result"
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => fail ~"badly-structured parse result"
|
||||
};
|
||||
|
||||
|
@ -84,7 +84,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
|
||||
ty_hex(c) => match c {
|
||||
case_upper => rt_type = ~"ty_hex_upper",
|
||||
case_lower => rt_type = ~"ty_hex_lower"
|
||||
}
|
||||
},
|
||||
ty_bits => rt_type = ~"ty_bits",
|
||||
ty_octal => rt_type = ~"ty_octal",
|
||||
_ => rt_type = ~"ty_default"
|
||||
@ -125,7 +125,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
|
||||
ty_int(s) => match s {
|
||||
signed => return true,
|
||||
unsigned => return false
|
||||
}
|
||||
},
|
||||
ty_float => return true,
|
||||
_ => return false
|
||||
}
|
||||
@ -173,7 +173,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
|
||||
unsigned => {
|
||||
return make_conv_call(cx, arg.span, ~"uint", cnv, arg)
|
||||
}
|
||||
}
|
||||
},
|
||||
ty_bool => return make_conv_call(cx, arg.span, ~"bool", cnv, arg),
|
||||
ty_char => return make_conv_call(cx, arg.span, ~"char", cnv, arg),
|
||||
ty_hex(_) => {
|
||||
@ -224,12 +224,12 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
|
||||
ty_int(s) => match s {
|
||||
signed => debug!{"type: signed"},
|
||||
unsigned => debug!{"type: unsigned"}
|
||||
}
|
||||
},
|
||||
ty_bits => debug!{"type: bits"},
|
||||
ty_hex(cs) => match cs {
|
||||
case_upper => debug!{"type: uhex"},
|
||||
case_lower => debug!{"type: lhex"},
|
||||
}
|
||||
},
|
||||
ty_octal => debug!{"type: octal"},
|
||||
ty_float => debug!{"type: float"},
|
||||
ty_poly => debug!{"type: poly"}
|
||||
|
@ -312,7 +312,7 @@ fn replace_expr(repls: ~[fragment],
|
||||
ast::expr_mac({node: mac_var(i), _}) => match (repls[i]) {
|
||||
from_expr(r) => (r.node, r.span),
|
||||
_ => fail /* fixme error message */
|
||||
}
|
||||
},
|
||||
_ => orig(e,s,fld)
|
||||
}
|
||||
}
|
||||
@ -326,7 +326,7 @@ fn replace_ty(repls: ~[fragment],
|
||||
ast::ty_mac({node: mac_var(i), _}) => match (repls[i]) {
|
||||
from_ty(r) => (r.node, r.span),
|
||||
_ => fail /* fixme error message */
|
||||
}
|
||||
},
|
||||
_ => orig(e,s,fld)
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ fn elts_to_ell(cx: ext_ctxt, elts: ~[@expr]) ->
|
||||
post: vec::slice(elts, idx + 1u, vec::len(elts))});
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
},
|
||||
_ => ()
|
||||
}
|
||||
idx += 1u;
|
||||
@ -518,7 +518,7 @@ fn block_to_ident(blk: blk_) -> option<ident> {
|
||||
some(expr) => match expr.node {
|
||||
expr_path(pth) => path_to_ident(pth),
|
||||
_ => none
|
||||
}
|
||||
},
|
||||
none => none
|
||||
}
|
||||
}
|
||||
@ -530,7 +530,7 @@ fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, _s: selector, _b: binders) {
|
||||
match_expr(e) => match e.node {
|
||||
expr_mac(mac) => fn_m(mac),
|
||||
_ => none
|
||||
}
|
||||
},
|
||||
_ => cx.bug(~"broken traversal in p_t_s_r")
|
||||
}
|
||||
}
|
||||
@ -650,7 +650,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
|
||||
~"macro name must be " +
|
||||
~"consistent");
|
||||
}
|
||||
}
|
||||
},
|
||||
none => cx.span_fatal(pth.span,
|
||||
~"macro name must not be a path")
|
||||
}
|
||||
|
@ -322,7 +322,7 @@ fn parse_nt(p: parser, name: ~str) -> nonterminal {
|
||||
~"item" => match p.parse_item(~[]) {
|
||||
some(i) => token::nt_item(i),
|
||||
none => p.fatal(~"expected an item keyword")
|
||||
}
|
||||
},
|
||||
~"block" => token::nt_block(p.parse_block()),
|
||||
~"stmt" => token::nt_stmt(p.parse_stmt(~[])),
|
||||
~"pat" => token::nt_pat(p.parse_pat(true)),
|
||||
@ -333,7 +333,7 @@ fn parse_nt(p: parser, name: ~str) -> nonterminal {
|
||||
token::IDENT(sn,b) => { p.bump(); token::nt_ident(sn,b) }
|
||||
_ => p.fatal(~"expected ident, found "
|
||||
+ token::to_str(*p.reader.interner(), copy p.token))
|
||||
}
|
||||
},
|
||||
~"path" => token::nt_path(p.parse_path_with_tps(false)),
|
||||
~"tt" => {
|
||||
p.quote_depth += 1u; //but in theory, non-quoted tts might be useful
|
||||
|
@ -13,6 +13,13 @@ fn expr_requires_semi_to_be_stmt(e: @ast::expr) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
fn expr_is_simple_block(e: @ast::expr) -> bool {
|
||||
match e.node {
|
||||
ast::expr_block({node: {rules: ast::default_blk, _}, _}) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
fn stmt_ends_with_semi(stmt: ast::stmt) -> bool {
|
||||
match stmt.node {
|
||||
ast::stmt_decl(d, _) => {
|
||||
@ -52,7 +59,7 @@ fn ends_in_lit_int(ex: @ast::expr) -> bool {
|
||||
@{node: ast::lit_int(_, ast::ty_i), _}
|
||||
| @{node: ast::lit_int_unsuffixed(_), _} => true,
|
||||
_ => false
|
||||
}
|
||||
},
|
||||
ast::expr_binary(_, _, sub) | ast::expr_unary(_, sub) |
|
||||
ast::expr_move(_, sub) | ast::expr_copy(sub) |
|
||||
ast::expr_assign(_, sub) |
|
||||
@ -63,7 +70,7 @@ fn ends_in_lit_int(ex: @ast::expr) -> bool {
|
||||
ast::expr_fail(osub) | ast::expr_ret(osub) => match osub {
|
||||
some(ex) => ends_in_lit_int(ex),
|
||||
_ => false
|
||||
}
|
||||
},
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
@ -963,7 +963,7 @@ class parser {
|
||||
hi = self.span.hi;
|
||||
ex = expr_vstore(self.mk_expr(lo, hi, ex), vstore_fixed(v));
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => ()
|
||||
}
|
||||
|
||||
@ -1579,7 +1579,7 @@ class parser {
|
||||
let expr = self.parse_expr_res(RESTRICT_STMT_EXPR);
|
||||
|
||||
let require_comma =
|
||||
classify::expr_requires_semi_to_be_stmt(expr)
|
||||
!classify::expr_is_simple_block(expr)
|
||||
&& self.token != token::RBRACE;
|
||||
|
||||
if require_comma {
|
||||
@ -1839,7 +1839,7 @@ class parser {
|
||||
(token::COMMA),
|
||||
|p| p.parse_pat(refutable));
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => ()
|
||||
}
|
||||
// at this point, we're not sure whether it's a
|
||||
|
@ -649,7 +649,7 @@ fn print_item(s: ps, &&item: @ast::item) {
|
||||
/// expression arguments as expressions). It can be done! I think.
|
||||
fn print_tt(s: ps, tt: ast::token_tree) {
|
||||
match tt {
|
||||
ast::tt_delim(tts) => for tts.each() |tt_elt| { print_tt(s, tt_elt); }
|
||||
ast::tt_delim(tts) => for tts.each() |tt_elt| { print_tt(s, tt_elt); },
|
||||
ast::tt_tok(_, tk) => {
|
||||
match tk {
|
||||
parse::token::IDENT(*) => { // don't let idents run together
|
||||
@ -953,7 +953,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
|
||||
print_vstore(s, v);
|
||||
print_expr(s, e);
|
||||
}
|
||||
}
|
||||
},
|
||||
ast::expr_vec(exprs, mutbl) => {
|
||||
ibox(s, indent_unit);
|
||||
word(s.s, ~"[");
|
||||
@ -1114,7 +1114,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
|
||||
some(expr) => {
|
||||
end(s); // close the ibox for the pattern
|
||||
print_expr(s, expr);
|
||||
if expr_requires_semi_to_be_stmt(expr)
|
||||
if !expr_is_simple_block(expr)
|
||||
&& i < len - 1 {
|
||||
word(s.s, ~",");
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ fn visit_crate_directive<E>(cd: @crate_directive, e: E, v: vt<E>) {
|
||||
cdir_src_mod(_, _) => (),
|
||||
cdir_dir_mod(_, cdirs, _) => for cdirs.each |cdir| {
|
||||
visit_crate_directive(cdir, e, v);
|
||||
}
|
||||
},
|
||||
cdir_view_item(vi) => v.visit_view_item(vi, e, v),
|
||||
cdir_syntax(_) => ()
|
||||
}
|
||||
@ -191,10 +191,10 @@ fn visit_ty<E>(t: @ty, e: E, v: vt<E>) {
|
||||
}
|
||||
ty_rec(flds) => for flds.each |f| {
|
||||
v.visit_ty(f.node.mt.ty, e, v);
|
||||
}
|
||||
},
|
||||
ty_tup(ts) => for ts.each |tt| {
|
||||
v.visit_ty(tt, e, v);
|
||||
}
|
||||
},
|
||||
ty_fn(_, bounds, decl) => {
|
||||
for decl.inputs.each |a| { v.visit_ty(a.ty, e, v); }
|
||||
visit_ty_param_bounds(bounds, e, v);
|
||||
@ -222,7 +222,7 @@ fn visit_pat<E>(p: @pat, e: E, v: vt<E>) {
|
||||
}
|
||||
pat_rec(fields, _) => for fields.each |f| {
|
||||
v.visit_pat(f.pat, e, v)
|
||||
}
|
||||
},
|
||||
pat_struct(path, fields, _) => {
|
||||
visit_path(path, e, v);
|
||||
for fields.each |f| {
|
||||
@ -231,7 +231,7 @@ fn visit_pat<E>(p: @pat, e: E, v: vt<E>) {
|
||||
}
|
||||
pat_tup(elts) => for elts.each |elt| {
|
||||
v.visit_pat(elt, e, v)
|
||||
}
|
||||
},
|
||||
pat_box(inner) | pat_uniq(inner) => v.visit_pat(inner, e, v),
|
||||
pat_ident(_, path, inner) => {
|
||||
visit_path(path, e, v);
|
||||
@ -339,7 +339,7 @@ fn visit_decl<E>(d: @decl, e: E, v: vt<E>) {
|
||||
match d.node {
|
||||
decl_local(locs) => for locs.each |loc| {
|
||||
v.visit_local(loc, e, v)
|
||||
}
|
||||
},
|
||||
decl_item(it) => v.visit_item(it, e, v)
|
||||
}
|
||||
}
|
||||
@ -380,7 +380,7 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
|
||||
for flds.each |f| { v.visit_expr(f.node.expr, e, v); }
|
||||
visit_expr_opt(base, e, v);
|
||||
}
|
||||
expr_tup(elts) => for elts.each |el| { v.visit_expr(el, e, v); }
|
||||
expr_tup(elts) => for elts.each |el| { v.visit_expr(el, e, v); },
|
||||
expr_call(callee, args, _) => {
|
||||
visit_exprs(args, e, v);
|
||||
v.visit_expr(callee, e, v);
|
||||
|
@ -46,7 +46,7 @@ fn check_pat(p: @pat, &&_is_const: bool, v: visit::vt<bool>) {
|
||||
}
|
||||
match p.node {
|
||||
// Let through plain ~-string literals here
|
||||
pat_lit(a) => if !is_str(a) { v.visit_expr(a, true, v); }
|
||||
pat_lit(a) => if !is_str(a) { v.visit_expr(a, true, v); },
|
||||
pat_range(a, b) => {
|
||||
if !is_str(a) { v.visit_expr(a, true, v); }
|
||||
if !is_str(b) { v.visit_expr(b, true, v); }
|
||||
|
@ -1190,7 +1190,7 @@ class liveness {
|
||||
expr_field(e, nm, _) => match self.as_self_field(e, nm) {
|
||||
some(_) => succ,
|
||||
none => self.propagate_through_expr(e, succ)
|
||||
}
|
||||
},
|
||||
_ => self.propagate_through_expr(expr, succ)
|
||||
}
|
||||
}
|
||||
@ -1208,7 +1208,7 @@ class liveness {
|
||||
ln
|
||||
}
|
||||
none => succ
|
||||
}
|
||||
},
|
||||
|
||||
// We do not track other lvalues, so just propagate through
|
||||
// to their subcomponents. Also, it may happen that
|
||||
|
@ -27,7 +27,7 @@ fn pat_is_variant(dm: resolve3::DefMap, pat: @pat) -> bool {
|
||||
pat_ident(_, _, none) => match dm.find(pat.id) {
|
||||
some(def_variant(_, _)) => true,
|
||||
_ => false
|
||||
}
|
||||
},
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
@ -582,7 +582,7 @@ class NameBindings {
|
||||
none => return none,
|
||||
some(def_id) => return some(def_mod(def_id))
|
||||
}
|
||||
}
|
||||
},
|
||||
ImplNS => {
|
||||
// Danger: Be careful what you use this for! def_ty is not
|
||||
// necessarily the right def.
|
||||
|
@ -2851,7 +2851,7 @@ fn trans_arg_expr(cx: block, arg: ty::arg, lldestty: TypeRef, e: @ast::expr,
|
||||
let bcx = trans_loop_body(cx, e, ret_flag, save_in(scratch));
|
||||
{bcx: bcx, val: scratch, kind: lv_temporary}
|
||||
}
|
||||
}
|
||||
},
|
||||
none => {
|
||||
trans_temp_lval(cx, e)
|
||||
}
|
||||
|
@ -300,14 +300,14 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span)
|
||||
ast::ty_i16 => (~"i16", DW_ATE_signed),
|
||||
ast::ty_i32 => (~"i32", DW_ATE_signed),
|
||||
ast::ty_i64 => (~"i64", DW_ATE_signed)
|
||||
}
|
||||
},
|
||||
ast::ty_uint(m) => match m {
|
||||
ast::ty_u => (~"uint", DW_ATE_unsigned),
|
||||
ast::ty_u8 => (~"u8", DW_ATE_unsigned_char),
|
||||
ast::ty_u16 => (~"u16", DW_ATE_unsigned),
|
||||
ast::ty_u32 => (~"u32", DW_ATE_unsigned),
|
||||
ast::ty_u64 => (~"u64", DW_ATE_unsigned)
|
||||
}
|
||||
},
|
||||
ast::ty_float(m) => match m {
|
||||
ast::ty_f => (~"float", DW_ATE_float),
|
||||
ast::ty_f32 => (~"f32", DW_ATE_float),
|
||||
|
@ -1165,7 +1165,7 @@ fn abi_of_foreign_fn(ccx: @crate_ctxt, i: @ast::foreign_item)
|
||||
match attr::first_attr_value_str_by_name(i.attrs, ~"abi") {
|
||||
none => match check ccx.tcx.items.get(i.id) {
|
||||
ast_map::node_foreign_item(_, abi, _) => abi
|
||||
}
|
||||
},
|
||||
some(_) => match attr::foreign_abi(i.attrs) {
|
||||
either::right(abi) => abi,
|
||||
either::left(msg) => ccx.sess.span_fatal(i.span, msg)
|
||||
|
@ -612,7 +612,7 @@ fn mk_t(cx: ctxt, st: sty) -> t { mk_t_with_id(cx, st, none) }
|
||||
fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option<ast::def_id>) -> t {
|
||||
let key = {struct: st, o_def_id: o_def_id};
|
||||
match cx.interner.find(key) {
|
||||
some(t) => unsafe { return unsafe::reinterpret_cast(t); }
|
||||
some(t) => unsafe { return unsafe::reinterpret_cast(t); },
|
||||
_ => ()
|
||||
}
|
||||
let mut flags = 0u;
|
||||
@ -655,8 +655,8 @@ fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option<ast::def_id>) -> t {
|
||||
flags |= rflags(r);
|
||||
flags |= get(m.ty).flags;
|
||||
}
|
||||
ty_rec(flds) => for flds.each |f| { flags |= get(f.mt.ty).flags; }
|
||||
ty_tup(ts) => for ts.each |tt| { flags |= get(tt).flags; }
|
||||
ty_rec(flds) => for flds.each |f| { flags |= get(f.mt.ty).flags; },
|
||||
ty_tup(ts) => for ts.each |tt| { flags |= get(tt).flags; },
|
||||
ty_fn(f) => {
|
||||
for f.inputs.each |a| { flags |= get(a.ty).flags; }
|
||||
flags |= get(f.output).flags;
|
||||
@ -2189,19 +2189,19 @@ pure fn hash_type_structure(st: sty) -> uint {
|
||||
ast::ty_i16 => 5u,
|
||||
ast::ty_i32 => 6u,
|
||||
ast::ty_i64 => 7u
|
||||
}
|
||||
},
|
||||
ty_uint(t) => match t {
|
||||
ast::ty_u => 8u,
|
||||
ast::ty_u8 => 9u,
|
||||
ast::ty_u16 => 10u,
|
||||
ast::ty_u32 => 11u,
|
||||
ast::ty_u64 => 12u
|
||||
}
|
||||
},
|
||||
ty_float(t) => match t {
|
||||
ast::ty_f => 13u,
|
||||
ast::ty_f32 => 14u,
|
||||
ast::ty_f64 => 15u
|
||||
}
|
||||
},
|
||||
ty_estr(_) => 16u,
|
||||
ty_enum(did, substs) => {
|
||||
let mut h = hash_def(18u, did);
|
||||
@ -2473,7 +2473,7 @@ fn canon<T:copy>(tbl: hashmap<ast::node_id, ast::inferable<T>>,
|
||||
if cm1 != m1 { tbl.insert(id, cm1); }
|
||||
cm1
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => m0
|
||||
}
|
||||
}
|
||||
|
@ -1319,7 +1319,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||
ast::box(_) | ast::uniq(_) => match sty {
|
||||
ty::ty_box(mt) | ty::ty_uniq(mt) => some(mt.ty),
|
||||
_ => none
|
||||
}
|
||||
},
|
||||
ast::not | ast::neg => expected,
|
||||
ast::deref => none
|
||||
}
|
||||
@ -1430,7 +1430,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||
expr.span,
|
||||
~"`return;` in function returning non-nil");
|
||||
}
|
||||
}
|
||||
},
|
||||
some(e) => { check_expr_with(fcx, e, ret_ty); }
|
||||
}
|
||||
fcx.write_bot(id);
|
||||
@ -1933,7 +1933,7 @@ fn check_stmt(fcx: @fn_ctxt, stmt: @ast::stmt) -> bool {
|
||||
match decl.node {
|
||||
ast::decl_local(ls) => for ls.each |l| {
|
||||
bot |= check_decl_local(fcx, l);
|
||||
}
|
||||
},
|
||||
ast::decl_item(_) => {/* ignore for now */ }
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ fn replace_bound_regions_in_fn_ty(
|
||||
some(s) => match check t_self {
|
||||
some(t) => some({self_ty: t, node_id: s.node_id})
|
||||
// this 'none' case shouldn't happen
|
||||
}
|
||||
},
|
||||
none => none
|
||||
};
|
||||
|
||||
|
@ -258,14 +258,14 @@ fn convert_integral_ty_to_int_ty_set(tcx: ty::ctxt, t: ty::t)
|
||||
ast::ty_i => int_ty_set(INT_TY_SET_i),
|
||||
ast::ty_char => tcx.sess.bug(
|
||||
~"char type passed to convert_integral_ty_to_int_ty_set()")
|
||||
}
|
||||
},
|
||||
ty_uint(uint_ty) => match uint_ty {
|
||||
ast::ty_u8 => int_ty_set(INT_TY_SET_u8),
|
||||
ast::ty_u16 => int_ty_set(INT_TY_SET_u16),
|
||||
ast::ty_u32 => int_ty_set(INT_TY_SET_u32),
|
||||
ast::ty_u64 => int_ty_set(INT_TY_SET_u64),
|
||||
ast::ty_u => int_ty_set(INT_TY_SET_u)
|
||||
}
|
||||
},
|
||||
_ => tcx.sess.bug(~"non-integral type passed to \
|
||||
convert_integral_ty_to_int_ty_set()")
|
||||
}
|
||||
|
@ -1,56 +0,0 @@
|
||||
// no-reformat
|
||||
// Testing the presense or absense of commas separating block-structure
|
||||
// match arm expressions
|
||||
|
||||
fn fun(_f: fn()) {
|
||||
}
|
||||
|
||||
fn it(_f: fn() -> bool) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
match 0 {
|
||||
00 => {
|
||||
}
|
||||
01 => if true {
|
||||
} else {
|
||||
}
|
||||
03 => match 0 {
|
||||
_ => ()
|
||||
}
|
||||
04 => do fun {
|
||||
}
|
||||
05 => for it {
|
||||
}
|
||||
06 => while false {
|
||||
}
|
||||
07 => loop {
|
||||
}
|
||||
08 => unsafe {
|
||||
}
|
||||
09 => unchecked {
|
||||
}
|
||||
10 => {
|
||||
},
|
||||
11 => if true {
|
||||
} else {
|
||||
},
|
||||
13 => match 0 {
|
||||
_ => ()
|
||||
},
|
||||
14 => do fun {
|
||||
},
|
||||
15 => for it {
|
||||
},
|
||||
16 => while false {
|
||||
},
|
||||
17 => loop {
|
||||
},
|
||||
18 => unsafe {
|
||||
},
|
||||
19 => unchecked {
|
||||
},
|
||||
_ => ()
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user