syntax: Patch up code that was using irrefutable patterns incorrectly
This commit is contained in:
parent
9999622e44
commit
366a233dbd
2 changed files with 20 additions and 12 deletions
|
|
@ -589,7 +589,7 @@ impl<'self> MethodDef<'self> {
|
|||
|
||||
// transpose raw_fields
|
||||
let fields = match raw_fields {
|
||||
[self_arg, .. rest] => {
|
||||
[ref self_arg, .. rest] => {
|
||||
do self_arg.iter().enumerate().transform |(i, &(opt_id, field))| {
|
||||
let other_fields = do rest.map |l| {
|
||||
match &l[i] {
|
||||
|
|
@ -738,16 +738,20 @@ impl<'self> MethodDef<'self> {
|
|||
|
||||
let mut enum_matching_fields = vec::from_elem(self_vec.len(), ~[]);
|
||||
|
||||
for matches_so_far.tail().iter().advance |&(_, _, other_fields)| {
|
||||
for other_fields.iter().enumerate().advance |(i, &(_, other_field))| {
|
||||
enum_matching_fields[i].push(other_field);
|
||||
for matches_so_far.tail().iter().advance |triple| {
|
||||
match triple {
|
||||
&(_, _, ref other_fields) => {
|
||||
for other_fields.iter().enumerate().advance |(i, pair)| {
|
||||
enum_matching_fields[i].push(pair.second());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let field_tuples =
|
||||
do self_vec.iter()
|
||||
.zip(enum_matching_fields.iter())
|
||||
.transform |(&(id, self_f), &other)| {
|
||||
(id, self_f, other)
|
||||
.transform |(&(id, self_f), other)| {
|
||||
(id, self_f, copy *other)
|
||||
}.collect();
|
||||
substructure = EnumMatching(variant_index, variant, field_tuples);
|
||||
}
|
||||
|
|
@ -1015,7 +1019,8 @@ left-to-right (`true`) or right-to-left (`false`).
|
|||
pub fn cs_fold(use_foldl: bool,
|
||||
f: &fn(@ExtCtxt, span,
|
||||
old: @expr,
|
||||
self_f: @expr, other_fs: &[@expr]) -> @expr,
|
||||
self_f: @expr,
|
||||
other_fs: &[@expr]) -> @expr,
|
||||
base: @expr,
|
||||
enum_nonmatch_f: EnumNonMatchFunc,
|
||||
cx: @ExtCtxt, span: span,
|
||||
|
|
@ -1023,11 +1028,13 @@ pub fn cs_fold(use_foldl: bool,
|
|||
match *substructure.fields {
|
||||
EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => {
|
||||
if use_foldl {
|
||||
do all_fields.iter().fold(base) |old, &(_, self_f, other_fs)| {
|
||||
do all_fields.iter().fold(base) |old, triple| {
|
||||
let (_, self_f, other_fs) = copy *triple;
|
||||
f(cx, span, old, self_f, other_fs)
|
||||
}
|
||||
} else {
|
||||
do all_fields.rev_iter().fold(base) |old, &(_, self_f, other_fs)| {
|
||||
do all_fields.rev_iter().fold(base) |old, triple| {
|
||||
let (_, self_f, other_fs) = copy *triple;
|
||||
f(cx, span, old, self_f, other_fs)
|
||||
}
|
||||
}
|
||||
|
|
@ -1059,7 +1066,8 @@ pub fn cs_same_method(f: &fn(@ExtCtxt, span, ~[@expr]) -> @expr,
|
|||
match *substructure.fields {
|
||||
EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => {
|
||||
// call self_n.method(other_1_n, other_2_n, ...)
|
||||
let called = do all_fields.map |&(_, self_field, other_fields)| {
|
||||
let called = do all_fields.map |triple| {
|
||||
let (_, self_field, other_fields) = copy *triple;
|
||||
cx.expr_method_call(span,
|
||||
self_field,
|
||||
substructure.method_ident,
|
||||
|
|
|
|||
|
|
@ -215,8 +215,8 @@ pub fn visit<Tproto, Tstate, Tmessage, V: visitor<Tproto, Tstate, Tmessage>>(
|
|||
|
||||
// the copy keywords prevent recursive use of dvec
|
||||
let states: ~[Tstate] = do (copy proto.states).iter().transform |&s| {
|
||||
let messages: ~[Tmessage] = do (copy s.messages).iter().transform |&m| {
|
||||
let message(name, span, tys, this, next) = m;
|
||||
let messages: ~[Tmessage] = do (copy s.messages).iter().transform |m| {
|
||||
let message(name, span, tys, this, next) = copy *m;
|
||||
visitor.visit_message(name, span, tys, this, next)
|
||||
}.collect();
|
||||
visitor.visit_state(s, messages)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue