mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-14 21:16:50 +00:00
Merge pull request #1325 from C4K3/master
Add error_on_line_overflow option
This commit is contained in:
commit
db10a0b9b2
@ -333,6 +333,7 @@ create_config! {
|
||||
via the --file-lines option";
|
||||
max_width: usize, 100, "Maximum width of each line";
|
||||
ideal_width: usize, 80, "Ideal width of each line";
|
||||
error_on_line_overflow: bool, true, "Error if unable to get all lines within max_width";
|
||||
tab_spaces: usize, 4, "Number of spaces per tab";
|
||||
fn_call_width: usize, 60,
|
||||
"Maximum width of the args of a function call before falling back to vertical formatting";
|
||||
|
@ -489,7 +489,7 @@ fn format_lines(text: &mut StringBuffer, name: &str, config: &Config, report: &m
|
||||
line_len -= b - lw;
|
||||
}
|
||||
// Check for any line width errors we couldn't correct.
|
||||
if line_len > config.max_width {
|
||||
if config.error_on_line_overflow && line_len > config.max_width {
|
||||
errors.push(FormattingError {
|
||||
line: cur_line,
|
||||
kind: ErrorKind::LineOverflow(line_len, config.max_width),
|
||||
|
@ -18,7 +18,7 @@ fn test() {
|
||||
* amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis
|
||||
* felis, pulvinar a semper sed, adipiscing id dolor. */
|
||||
|
||||
// Very looooooooooooooooooooooooooooooooooooooooooooooooooooooooong comment that should be split
|
||||
// Very loooooooooooooooooooooooooooooooooooooooooooooooooooooooong comment that should be split
|
||||
|
||||
// println!("{:?}", rewrite_comment(subslice,
|
||||
// false,
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
// Enums test
|
||||
|
||||
#[atrr]
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-file_lines: [{"file":"tests/source/file-lines-3.rs","range":[4,8]},{"file":"tests/source/file-lines-3.rs","range":[10,15]}]
|
||||
// rustfmt-file_lines: [{"file":"tests/source/file-lines-3.rs","range":[5,9]},{"file":"tests/source/file-lines-3.rs","range":[11,16]}]
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
fn floaters() {
|
||||
let x = Foo {
|
||||
|
@ -2,6 +2,7 @@
|
||||
// rustfmt-single_line_if_else_max_width: 0
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-hard_tabs: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
fn main() {
|
||||
let x = Bar;
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
// Imports.
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
mod client {
|
||||
impl Client {
|
||||
fn test(self) -> Result<()> {
|
||||
@ -10,7 +12,7 @@ mod client {
|
||||
let next_state = match self.state {
|
||||
State::V5(v5::State::Command(v5::comand::State::WriteVersion(ref mut response))) => {
|
||||
// The pattern cannot be formatted in a way that the match stays
|
||||
// within the column limit. The rewrite should therefore be
|
||||
// within the column limit. The rewrite should therefore be
|
||||
// skipped.
|
||||
let x = dont . reformat . meeee();
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-force_format_strings: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
// Long string literals
|
||||
|
||||
fn main() -> &'static str {
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-format_strings: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
fn main() {
|
||||
println!("ThisIsAReallyLongStringWithNoSpaces.It_should_prefer_to_break_onpunctuation:Likethisssssssssssss");
|
||||
|
@ -1,5 +1,6 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
// Struct literal expressions.
|
||||
|
||||
fn main() {
|
||||
|
@ -1,6 +1,7 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-struct_lit_style: Visual
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
// Struct literal expressions.
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-struct_lit_style: Visual
|
||||
// rustfmt-struct_lit_multiline_style: ForceMulti
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
// Struct literal expressions.
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
/// A Doc comment
|
||||
#[AnAttribute]
|
||||
|
@ -179,6 +179,10 @@ fn check_files<I>(files: I) -> (Vec<FormatReport>, u32, u32)
|
||||
println!("Testing '{}'...", file_name);
|
||||
|
||||
match idempotent_check(file_name) {
|
||||
Ok(ref report) if report.has_warnings() => {
|
||||
print!("{}", report);
|
||||
fails += 1;
|
||||
}
|
||||
Ok(report) => reports.push(report),
|
||||
Err(msg) => {
|
||||
print_mismatches(msg);
|
||||
|
@ -18,7 +18,7 @@ fn test() {
|
||||
* amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis
|
||||
* felis, pulvinar a semper sed, adipiscing id dolor. */
|
||||
|
||||
// Very looooooooooooooooooooooooooooooooooooooooooooooooooooooooong comment that should be split
|
||||
// Very loooooooooooooooooooooooooooooooooooooooooooooooooooooooong comment that should be split
|
||||
|
||||
// println!("{:?}", rewrite_comment(subslice,
|
||||
// false,
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
// Enums test
|
||||
|
||||
#[atrr]
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-file_lines: [{"file":"tests/source/file-lines-3.rs","range":[4,8]},{"file":"tests/source/file-lines-3.rs","range":[10,15]}]
|
||||
// rustfmt-file_lines: [{"file":"tests/source/file-lines-3.rs","range":[5,9]},{"file":"tests/source/file-lines-3.rs","range":[11,16]}]
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
fn floaters() {
|
||||
let x = Foo {
|
||||
|
@ -2,6 +2,7 @@
|
||||
// rustfmt-single_line_if_else_max_width: 0
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-hard_tabs: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
fn main() {
|
||||
let x = Bar;
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
// Imports.
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
mod client {
|
||||
impl Client {
|
||||
fn test(self) -> Result<()> {
|
||||
@ -10,7 +12,7 @@ mod client {
|
||||
let next_state = match self.state {
|
||||
State::V5(v5::State::Command(v5::comand::State::WriteVersion(ref mut response))) => {
|
||||
// The pattern cannot be formatted in a way that the match stays
|
||||
// within the column limit. The rewrite should therefore be
|
||||
// within the column limit. The rewrite should therefore be
|
||||
// skipped.
|
||||
let x = dont . reformat . meeee();
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-force_format_strings: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
// Long string literals
|
||||
|
||||
fn main() -> &'static str {
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-format_strings: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
fn main() {
|
||||
println!("ThisIsAReallyLongStringWithNoSpaces.It_should_prefer_to_break_onpunctuation:\
|
||||
|
@ -1,5 +1,6 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
// Struct literal expressions.
|
||||
|
||||
fn main() {
|
||||
|
@ -1,6 +1,7 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-struct_lit_style: Visual
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
// Struct literal expressions.
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-struct_lit_style: Visual
|
||||
// rustfmt-struct_lit_multiline_style: ForceMulti
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
// Struct literal expressions.
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
/// A Doc comment
|
||||
#[AnAttribute]
|
||||
|
Loading…
Reference in New Issue
Block a user