Skip to content

fix: correct generic bound indentation [2.x/master] #4640

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

Merged

Conversation

calebcartwright
Copy link
Member

Fixes #4636

@@ -933,7 +933,7 @@ fn join_bounds_inner(
_ => false,
};

let shape = if i > 0 && need_indent && force_newline {
let shape = if need_indent && force_newline {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way the code is structured, force_newline will always be false on the first pass through and a second pass is only triggered in situations where we have to use multiple lines to format. As such this index check only serves to cause a bug

Comment on lines +967 to +969
let (extendable, trailing_str) = if i == 0 {
let bound_str = item.rewrite(context, shape)?;
let bound_str_clone = bound_str.clone();
(bound_str, is_bound_extendable(&bound_str_clone, item))
(is_bound_extendable(&bound_str, item), bound_str)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither related to the underlying bug nor necessary to fix it, just noticed while in here that we were unnecessarily cloning the formatted bound

@calebcartwright calebcartwright merged commit a97fd77 into rust-lang:master Jan 13, 2021
@calebcartwright calebcartwright deleted the fix-generic-bound-indentation branch January 13, 2021 00:34
@karyon
Copy link
Contributor

karyon commented Oct 25, 2021

backport in #4653

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Indentation issue on first item in generic bounds
2 participants