mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-15 12:39:31 +03:00
Fix off-by-one error in assert_eq! line wrapping
If two really long conditions are checked for equality, they wouldn't be split into multiple lines if the last condition is the one to push the line past the width limit. Fix the off-by-one error that caused this, and add a test-case for it.
This commit is contained in:
+3
-3
@@ -2081,7 +2081,7 @@ fn try_overflow_last_arg<'a, T>(
|
||||
{
|
||||
let one_line_before = all_simple_before
|
||||
&& definitive_tactic(
|
||||
&item_vec[..num_args_before - 1],
|
||||
&item_vec[..num_args_before],
|
||||
ListTactic::HorizontalVertical,
|
||||
Separator::Comma,
|
||||
nested_shape.width,
|
||||
@@ -2140,8 +2140,8 @@ fn maybe_get_args_offset<T: ToExpr>(callee_str: &str, args: &[&T]) -> Option<(bo
|
||||
.iter()
|
||||
.find(|&&(s, _)| s == callee_str)
|
||||
{
|
||||
let all_simple_before = num_args_before >= 1 && args.len() >= num_args_before
|
||||
&& is_every_args_simple(&args[..num_args_before]);
|
||||
let all_simple_before =
|
||||
args.len() >= num_args_before && is_every_args_simple(&args[..num_args_before]);
|
||||
|
||||
let all_simple_after =
|
||||
args.len() >= num_args_before + 1 && is_every_args_simple(&args[num_args_before + 1..]);
|
||||
|
||||
@@ -272,6 +272,7 @@ fn special_case_macros() {
|
||||
|
||||
assert_eq!(left, right, "Ahoy there, {}!", target);
|
||||
assert_eq!(left, right, "Arr! Batten down the hatches, we got '{}' but not '{}' (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! Batten down the hatches, we got '{}' but not '{}' (we expected '{}')", result, input, expected);
|
||||
assert_eq!(left + 42, right, "Arr! Batten down the hatches, we got '{}' but not '{}' (we expected '{}')", result, input, expected);
|
||||
assert_eq!(left, right, "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", 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);
|
||||
|
||||
|
||||
@@ -734,6 +734,12 @@ fn special_case_macros() {
|
||||
"Arr! Batten down the hatches, we got '{}' but not '{}' (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! Batten down the hatches, we got '{}' but not '{}' (we expected '{}')",
|
||||
result, input, expected
|
||||
);
|
||||
assert_eq!(
|
||||
left + 42,
|
||||
right,
|
||||
|
||||
Reference in New Issue
Block a user