Skip to content

Commit 13f2bc9

Browse files
committed
Specialize assert_pred.
It has only two uses, and both use `matches_codepattern`. So just change it to `assert_matches_codepattern`.
1 parent 95b4c07 commit 13f2bc9

File tree

1 file changed

+6
-12
lines changed
  • compiler/rustc_parse/src/parser/mut_visit

1 file changed

+6
-12
lines changed

Diff for: compiler/rustc_parse/src/parser/mut_visit/tests.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ impl MutVisitor for ToZzIdentMutVisitor {
2121
}
2222
}
2323

24-
// Maybe add to `expand.rs`.
25-
macro_rules! assert_pred {
26-
($pred:expr, $predname:expr, $a:expr , $b:expr) => {{
27-
let pred_val = $pred;
24+
macro_rules! assert_matches_codepattern {
25+
($a:expr , $b:expr) => {{
2826
let a_val = $a;
2927
let b_val = $b;
30-
if !(pred_val(&a_val, &b_val)) {
31-
panic!("expected args satisfying {}, got {} and {}", $predname, a_val, b_val);
28+
if !matches_codepattern(&a_val, &b_val) {
29+
panic!("expected args satisfying `matches_codepattern`, got {} and {}", a_val, b_val);
3230
}
3331
}};
3432
}
@@ -41,9 +39,7 @@ fn ident_transformation() {
4139
let mut krate =
4240
string_to_crate("#[a] mod b {fn c (d : e, f : g) {h!(i,j,k);l;m}}".to_string());
4341
zz_visitor.visit_crate(&mut krate);
44-
assert_pred!(
45-
matches_codepattern,
46-
"matches_codepattern",
42+
assert_matches_codepattern!(
4743
print_crate_items(&krate),
4844
"#[zz]mod zz{fn zz(zz:zz,zz:zz){zz!(zz,zz,zz);zz;zz}}".to_string()
4945
);
@@ -61,9 +57,7 @@ fn ident_transformation_in_defs() {
6157
.to_string(),
6258
);
6359
zz_visitor.visit_crate(&mut krate);
64-
assert_pred!(
65-
matches_codepattern,
66-
"matches_codepattern",
60+
assert_matches_codepattern!(
6761
print_crate_items(&krate),
6862
"macro_rules! zz{(zz$zz:zz$(zz $zz:zz)zz+=>(zz$(zz$zz$zz)+))}".to_string()
6963
);

0 commit comments

Comments
 (0)