-
Notifications
You must be signed in to change notification settings - Fork 933
fix: wrap function without a body exceeding 100 characters (#6539) #6579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lukewilson2002
wants to merge
4
commits into
rust-lang:master
Choose a base branch
from
lukewilson2002:6539-fix-wrap-fn-without-body
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e554eba
fix: wrap function without a body exceeding 100 characters (#6539)
lukewilson2002 14b815d
fix: skip brace style for `where` clause in compute_budgets_for_param…
lukewilson2002 94a1c9d
fix: PreferSameLine and WhereSingleLine had conflicting brace rules f…
lukewilson2002 b43eefc
revert previous fix
lukewilson2002 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// rustfmt-style_edition: 2027 | ||
// rustfmt-brace_style: AlwaysNextLine | ||
// rustfmt-where_single_line: false | ||
|
||
// Top-level functions | ||
|
||
// Short function | ||
fn short_fn(a: f64, b: f64) -> f64; | ||
|
||
// Function with wrapping return type and no where clause | ||
fn fn_with_long_return_type(a: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>>; | ||
|
||
// Function with non-wrapping return type and where clause | ||
fn fn_with_short_where<T>(a: f64, b: T) -> f64 where T: Debug; | ||
|
||
// Function that wraps at a simple return type | ||
fn fn_with_wrapping_return_type<T>(aaaaaa: f64, bbbbbb: T, cccccc: f64, dddddd: f64, eeee: f64) -> f64; | ||
|
||
// Function that wraps at the where clause | ||
fn fn_with_wrapping_where_clause<T>(aaaaaa: f64, bbbbbb: T, cccccc: f64, dddddd: f64) -> f64 where T: Debug; | ||
|
||
// Function with both wrapping return type and wrapping where clause | ||
fn fn_with_long_return_and_where<T, U, 'a>(a: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator; | ||
|
||
// Function with wrapping arguments, return type, and where clause | ||
fn fn_with_everything_long<T, U, 'a>(aaaa: f64, bbbb: f64, cccc: f64, dddd: f64, eeee: f64, ffff: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator; | ||
|
||
// Same variations with bodies | ||
fn short_fn_with_body(a: f64, b: f64) -> f64 {} | ||
|
||
fn fn_with_long_return_type_and_body(a: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> {} | ||
|
||
fn fn_with_short_where_and_body<T>(a: f64, b: T) -> f64 where T: Debug {} | ||
|
||
fn fn_with_wrapping_return_type_and_body<T>(aaaaaa: f64, bbbbbb: T, ccc: f64, ddd: f64, ee: f64) -> f64 {} | ||
|
||
fn fn_with_wrapping_where_clause_and_body<T>(aaaaaa: f64, bbbbbb: T, ccc: f64, ddd: f64) -> f64 where T: Debug {} | ||
|
||
fn fn_with_long_return_and_where_and_body<T, U, 'a>(a: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator {} | ||
|
||
fn fn_with_everything_long_and_body<T, U, 'a>(aaaa: f64, bbbb: f64, cccc: f64, dddd: f64, eeee: f64, ffff: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator {} | ||
|
||
// Trait methods | ||
pub trait Trait { | ||
fn short_method(a: f64, b: f64) -> f64; | ||
|
||
fn method_with_long_return(&self) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>>; | ||
|
||
fn method_with_short_where<T>(&self, a: f64, b: T) -> f64 where T: Debug; | ||
|
||
fn method_with_wrapping_return_type<T>(self, aaa: f64, bbb: T, ccc: f64, ddd: f64, ee: f64) -> f64; | ||
|
||
fn method_with_wrapping_where_clause<T>(aaaaaa: f64, bbbbbb: T, ccc: f64, ddd: f64) -> f64 where T: Debug; | ||
|
||
fn method_with_long_return_and_where<T, U, 'a>(self) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator; | ||
|
||
fn method_with_everything_long<T, U, 'a>(&self, aaaa: f64, bbbb: f64, cccc: f64, dddd: f64, eeee: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator; | ||
|
||
// Same variations with bodies | ||
fn short_method_with_body(a: f64, b: f64) -> f64 {} | ||
|
||
fn method_with_long_return_and_body(&self) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> {} | ||
|
||
fn method_with_short_where_and_body<T>(&self, a: f64, b: T) -> f64 where T: Debug {} | ||
|
||
fn method_with_wrapping_return_type_and_body<T>(aaaa: f64, bb: T, cc: f64, d: f64, e: f64) -> f64 {} | ||
|
||
fn method_with_wrapping_where_clause_and_body<T>(aaa: f64, bb: T, cc: f64, d: f64) -> f64 where T: Debug {} | ||
|
||
fn method_with_long_return_and_where_and_body<T, U, 'a>(self) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator {} | ||
|
||
fn method_with_everything_long_and_body<T, U, 'a>(aaaa: f64, bbbb: f64, cccc: f64, dddd: f64, eeee: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator {} | ||
} |
73 changes: 73 additions & 0 deletions
73
tests/source/issue-6539/brace_next_line_where_single_line.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// rustfmt-style_edition: 2027 | ||
// rustfmt-brace_style: AlwaysNextLine | ||
// rustfmt-where_single_line: true | ||
|
||
// Top-level functions | ||
|
||
// Short function | ||
fn short_fn(a: f64, b: f64) -> f64; | ||
|
||
// Function with wrapping return type and no where clause | ||
fn fn_with_long_return_type(a: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>>; | ||
|
||
// Function with non-wrapping return type and where clause | ||
fn fn_with_short_where<T>(a: f64, b: T) -> f64 where T: Debug; | ||
|
||
// Function that wraps at a simple return type | ||
fn fn_with_wrapping_return_type<T>(aaaaaa: f64, bbbbbb: T, cccccc: f64, dddddd: f64, eeee: f64) -> f64; | ||
|
||
// Function that wraps at the where clause | ||
fn fn_with_wrapping_where_clause<T>(aaaaaa: f64, bbbbbb: T, cccccc: f64, dddddd: f64) -> f64 where T: Debug; | ||
|
||
// Function with both wrapping return type and wrapping where clause | ||
fn fn_with_long_return_and_where<T, U, 'a>(a: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator; | ||
|
||
// Function with wrapping arguments, return type, and where clause | ||
fn fn_with_everything_long<T, U, 'a>(aaaa: f64, bbbb: f64, cccc: f64, dddd: f64, eeee: f64, ffff: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator; | ||
|
||
// Same variations with bodies | ||
fn short_fn_with_body(a: f64, b: f64) -> f64 {} | ||
|
||
fn fn_with_long_return_type_and_body(a: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> {} | ||
|
||
fn fn_with_short_where_and_body<T>(a: f64, b: T) -> f64 where T: Debug {} | ||
|
||
fn fn_with_wrapping_return_type_and_body<T>(aaaaaa: f64, bbbbbb: T, ccc: f64, ddd: f64, ee: f64) -> f64 {} | ||
|
||
fn fn_with_wrapping_where_clause_and_body<T>(aaaaaa: f64, bbbbbb: T, ccc: f64, ddd: f64) -> f64 where T: Debug {} | ||
|
||
fn fn_with_long_return_and_where_and_body<T, U, 'a>(a: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator {} | ||
|
||
fn fn_with_everything_long_and_body<T, U, 'a>(aaaa: f64, bbbb: f64, cccc: f64, dddd: f64, eeee: f64, ffff: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator {} | ||
|
||
// Trait methods | ||
pub trait Trait { | ||
fn short_method(a: f64, b: f64) -> f64; | ||
|
||
fn method_with_long_return(&self) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>>; | ||
|
||
fn method_with_short_where<T>(&self, a: f64, b: T) -> f64 where T: Debug; | ||
|
||
fn method_with_wrapping_return_type<T>(self, aaa: f64, bbb: T, ccc: f64, ddd: f64, ee: f64) -> f64; | ||
|
||
fn method_with_wrapping_where_clause<T>(aaaaaa: f64, bbbbbb: T, ccc: f64, ddd: f64) -> f64 where T: Debug; | ||
|
||
fn method_with_long_return_and_where<T, U, 'a>(self) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator; | ||
|
||
fn method_with_everything_long<T, U, 'a>(&self, aaaa: f64, bbbb: f64, cccc: f64, dddd: f64, eeee: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator; | ||
|
||
// Same variations with bodies | ||
fn short_method_with_body(a: f64, b: f64) -> f64 {} | ||
|
||
fn method_with_long_return_and_body(&self) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> {} | ||
|
||
fn method_with_short_where_and_body<T>(&self, a: f64, b: T) -> f64 where T: Debug {} | ||
|
||
fn method_with_wrapping_return_type_and_body<T>(aaaa: f64, bb: T, cc: f64, d: f64, e: f64) -> f64 {} | ||
|
||
fn method_with_wrapping_where_clause_and_body<T>(aaa: f64, bb: T, cc: f64, d: f64) -> f64 where T: Debug {} | ||
|
||
fn method_with_long_return_and_where_and_body<T, U, 'a>(self) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator {} | ||
|
||
fn method_with_everything_long_and_body<T, U, 'a>(aaaa: f64, bbbb: f64, cccc: f64, dddd: f64, eeee: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator {} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// rustfmt-style_edition: 2027 | ||
// rustfmt-brace_style: PreferSameLine | ||
// rustfmt-where_single_line: false | ||
|
||
// Top-level functions | ||
|
||
// Short function | ||
fn short_fn(a: f64, b: f64) -> f64; | ||
|
||
// Function with wrapping return type and no where clause | ||
fn fn_with_long_return_type(a: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>>; | ||
|
||
// Function with non-wrapping return type and where clause | ||
fn fn_with_short_where<T>(a: f64, b: T) -> f64 where T: Debug; | ||
|
||
// Function that wraps at a simple return type | ||
fn fn_with_wrapping_return_type<T>(aaaaaa: f64, bbbbbb: T, cccccc: f64, dddddd: f64, eeee: f64) -> f64; | ||
|
||
// Function that wraps at the where clause | ||
fn fn_with_wrapping_where_clause<T>(aaaaaa: f64, bbbbbb: T, cccccc: f64, dddddd: f64) -> f64 where T: Debug; | ||
|
||
// Function with both wrapping return type and wrapping where clause | ||
fn fn_with_long_return_and_where<T, U, 'a>(a: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator; | ||
|
||
// Function with wrapping arguments, return type, and where clause | ||
fn fn_with_everything_long<T, U, 'a>(aaaa: f64, bbbb: f64, cccc: f64, dddd: f64, eeee: f64, ffff: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator; | ||
|
||
// Same variations with bodies | ||
fn short_fn_with_body(a: f64, b: f64) -> f64 {} | ||
|
||
fn fn_with_long_return_type_and_body(a: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> {} | ||
|
||
fn fn_with_short_where_and_body<T>(a: f64, b: T) -> f64 where T: Debug {} | ||
|
||
fn fn_with_wrapping_return_type_and_body<T>(aaaaaa: f64, bbbbbb: T, ccc: f64, ddd: f64, ee: f64) -> f64 {} | ||
|
||
fn fn_with_wrapping_where_clause_and_body<T>(aaaaaa: f64, bbbbbb: T, ccc: f64, ddd: f64) -> f64 where T: Debug {} | ||
|
||
fn fn_with_long_return_and_where_and_body<T, U, 'a>(a: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator {} | ||
|
||
fn fn_with_everything_long_and_body<T, U, 'a>(aaaa: f64, bbbb: f64, cccc: f64, dddd: f64, eeee: f64, ffff: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator {} | ||
|
||
// Trait methods | ||
pub trait Trait { | ||
fn short_method(a: f64, b: f64) -> f64; | ||
|
||
fn method_with_long_return(&self) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>>; | ||
|
||
fn method_with_short_where<T>(&self, a: f64, b: T) -> f64 where T: Debug; | ||
|
||
fn method_with_wrapping_return_type<T>(self, aaa: f64, bbb: T, ccc: f64, ddd: f64, ee: f64) -> f64; | ||
|
||
fn method_with_wrapping_where_clause<T>(aaaaaa: f64, bbbbbb: T, ccc: f64, ddd: f64) -> f64 where T: Debug; | ||
|
||
fn method_with_long_return_and_where<T, U, 'a>(self) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator; | ||
|
||
fn method_with_everything_long<T, U, 'a>(&self, aaaa: f64, bbbb: f64, cccc: f64, dddd: f64, eeee: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator; | ||
|
||
// Same variations with bodies | ||
fn short_method_with_body(a: f64, b: f64) -> f64 {} | ||
|
||
fn method_with_long_return_and_body(&self) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> {} | ||
|
||
fn method_with_short_where_and_body<T>(&self, a: f64, b: T) -> f64 where T: Debug {} | ||
|
||
fn method_with_wrapping_return_type_and_body<T>(aaaa: f64, bb: T, cc: f64, d: f64, e: f64) -> f64 {} | ||
|
||
fn method_with_wrapping_where_clause_and_body<T>(aaa: f64, bb: T, cc: f64, d: f64) -> f64 where T: Debug {} | ||
|
||
fn method_with_long_return_and_where_and_body<T, U, 'a>(self) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator {} | ||
|
||
fn method_with_everything_long_and_body<T, U, 'a>(aaaa: f64, bbbb: f64, cccc: f64, dddd: f64, eeee: f64) -> Result<HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>, Box<dyn Error + Send + Sync + 'static>> where T: Debug + Display + Clone + Send + Sync + 'static, U: Iterator<Item = &'a T> + ExactSizeIterator {} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.