Skip to content

Commit

Permalink
Rename vector patterns to array patterns
Browse files Browse the repository at this point in the history
Closes #17765.
  • Loading branch information
ftxqxd committed Oct 4, 2014
1 parent e434aa1 commit 88baca7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/librustc/middle/typeck/check/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,30 +670,30 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) {
(ty, default_region_var, ast::MutImmutable, None)
}
_ => {
check_err("a vector pattern".to_string());
check_err("an array pattern".to_string());
return;
}
},
ty::ty_rptr(r, mt) => match ty::get(mt.ty).sty {
ty::ty_vec(ty, None) => (ty, r, mt.mutbl, None),
_ => {
check_err("a vector pattern".to_string());
check_err("an array pattern".to_string());
return;
}
},
_ => {
check_err("a vector pattern".to_string());
check_err("an array pattern".to_string());
return;
}
};

let min_len = before.len() + after.len();
fixed.and_then(|count| match *slice {
Some(_) if count < min_len =>
Some(format!("a fixed vector pattern of size at least {}", min_len)),
Some(format!("a fixed array pattern of size at least {}", min_len)),

None if count != min_len =>
Some(format!("a fixed vector pattern of size {}", min_len)),
Some(format!("a fixed array pattern of size {}", min_len)),

_ => None
}).map(check_err);
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-13482.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn main() {
let x = [1,2];
let y = match x {
[] => None,
//~^ ERROR expected `[<generic integer #0>, ..2]`, found a fixed vector pattern of size 0
//~^ ERROR expected `[<generic integer #0>, ..2]`, found a fixed array pattern of size 0
[a,_] => Some(a)
};
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/match-vec-mismatch-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

fn main() {
match () {
[()] => { } //~ ERROR mismatched types: expected `()`, found a vector pattern
[()] => { } //~ ERROR mismatched types: expected `()`, found an array pattern
}
}

0 comments on commit 88baca7

Please sign in to comment.