Do not panic when special macros have less args than expected

This commit is contained in:
Seiichi Uchida 2018-01-18 00:50:16 +09:00
parent c87bd9e92e
commit 298f29a57d
3 changed files with 13 additions and 1 deletions

View File

@ -2163,7 +2163,7 @@ fn maybe_get_args_offset<T: ToExpr>(callee_str: &str, args: &[&T]) -> Option<(bo
.iter()
.find(|&&(s, _)| s == callee_str)
{
let all_simple = args.len() >= num_args_before && is_every_args_simple(args);
let all_simple = args.len() > num_args_before && is_every_args_simple(args);
Some((all_simple, num_args_before))
} else {

View File

@ -218,6 +218,7 @@ make_test!(str_searcher_ascii_haystack, "bb", "abbcbbd", [
}
fn special_case_macros() {
let p = eprint!();
let q = eprint!("{}", 1);
let r = eprint!("{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
let s = eprint!("{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26);
@ -266,10 +267,15 @@ fn special_case_macros() {
warn!("{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
warn!("{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26);
assert!();
assert!(result == 42);
assert!(result == 42, "Ahoy there, {}!", target);
assert!(result == 42, "Arr! While plunderin' the hold, we got '{}' when given '{}' (we expected '{}')", result, input, expected);
assert!(result == 42, "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26);
assert_eq!();
assert_eq!(left);
assert_eq!(left, right);
assert_eq!(left, right, "Ahoy there, {}!", target);
assert_eq!(left, right, "Arr! While plunderin' the hold, we got '{}' when given '{}' (we expected '{}')", result, input, expected);
assert_eq!(first_realllllllllllly_long_variable_that_doesnt_fit_one_one_line, second_reallllllllllly_long_variable_that_doesnt_fit_one_one_line, "Arr! While plunderin' the hold, we got '{}' when given '{}' (we expected '{}')", result, input, expected);

View File

@ -271,6 +271,7 @@ fn issue2214() {
}
fn special_case_macros() {
let p = eprint!();
let q = eprint!("{}", 1);
let r = eprint!(
"{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
@ -691,6 +692,8 @@ fn special_case_macros() {
26
);
assert!();
assert!(result == 42);
assert!(result == 42, "Ahoy there, {}!", target);
assert!(
result == 42,
@ -730,6 +733,9 @@ fn special_case_macros() {
26
);
assert_eq!();
assert_eq!(left);
assert_eq!(left, right);
assert_eq!(left, right, "Ahoy there, {}!", target);
assert_eq!(
left, right,