mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
Prevent trailing whitespace in where clause bound predicate
resolves 5012 resolves 4850 This behavior was noticed when using the ``trailing_comma = "Never"`` configuration option (5012). This behavior was also noticed when using default configurations (4850). rustfmt would add a trailing space to where clause bounds that had an empty right hand side. Now no trailing space is added to the end of these where clause bounds.
This commit is contained in:
parent
a4d7011c18
commit
5ce82e1513
@ -1962,6 +1962,9 @@ fn choose_rhs<R: Rewrite>(
|
||||
has_rhs_comment: bool,
|
||||
) -> Option<String> {
|
||||
match orig_rhs {
|
||||
Some(ref new_str) if new_str.is_empty() => {
|
||||
return Some(String::new());
|
||||
}
|
||||
Some(ref new_str)
|
||||
if !new_str.contains('\n') && unicode_str_width(new_str) <= shape.width =>
|
||||
{
|
||||
|
8
tests/target/issue-5012/trailing_comma_always.rs
Normal file
8
tests/target/issue-5012/trailing_comma_always.rs
Normal file
@ -0,0 +1,8 @@
|
||||
// rustfmt-trailing_comma: Always
|
||||
|
||||
pub struct Matrix<T, const R: usize, const C: usize,>
|
||||
where
|
||||
[T; R * C]:,
|
||||
{
|
||||
contents: [T; R * C],
|
||||
}
|
8
tests/target/issue-5012/trailing_comma_never.rs
Normal file
8
tests/target/issue-5012/trailing_comma_never.rs
Normal file
@ -0,0 +1,8 @@
|
||||
// rustfmt-trailing_comma: Never
|
||||
|
||||
pub struct Matrix<T, const R: usize, const C: usize>
|
||||
where
|
||||
[T; R * C]:
|
||||
{
|
||||
contents: [T; R * C]
|
||||
}
|
4
tests/target/issue_4850.rs
Normal file
4
tests/target/issue_4850.rs
Normal file
@ -0,0 +1,4 @@
|
||||
impl ThisIsALongStructNameToPushTheWhereToWrapLolololol where
|
||||
[(); this_is_a_long_const_function_name()]:
|
||||
{
|
||||
}
|
Loading…
Reference in New Issue
Block a user