mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 20:23:59 +00:00
LineOverflow: Count tabs as tab_spaces when measuring line length for overflow
This commit is contained in:
parent
e0e3e22248
commit
1fb172f989
@ -463,7 +463,7 @@ fn format_lines(
|
||||
is_string = false;
|
||||
} else {
|
||||
newline_count = 0;
|
||||
line_len += 1;
|
||||
line_len += if c == '\t' { config.tab_spaces() } else { 1 };
|
||||
if c.is_whitespace() {
|
||||
if last_wspace.is_none() {
|
||||
last_wspace = Some(b);
|
||||
|
@ -261,6 +261,16 @@ fn format_lines_errors_are_reported() {
|
||||
assert!(error_summary.has_formatting_errors());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_lines_errors_are_reported_with_tabs() {
|
||||
let long_identifier = String::from_utf8(vec![b'a'; 97]).unwrap();
|
||||
let input = Input::Text(format!("fn a() {{\n\t{}\n}}", long_identifier));
|
||||
let config = Config::from_toml("hard_tabs = true").unwrap();
|
||||
let (error_summary, _file_map, _report) =
|
||||
format_input::<io::Stdout>(input, &config, None).unwrap();
|
||||
assert!(error_summary.has_formatting_errors());
|
||||
}
|
||||
|
||||
// For each file, run rustfmt and collect the output.
|
||||
// Returns the number of files checked and the number of failures.
|
||||
fn check_files(files: Vec<PathBuf>) -> (Vec<FormatReport>, u32, u32) {
|
||||
|
Loading…
Reference in New Issue
Block a user