Keep array types on same line as prefix for statics - #6995
Blackgaurd wants to merge 4 commits into
Conversation
|
Reminder, once the PR becomes ready for a review, use |
|
@rustbot ready |
|
Could you add a test case where the array type is so large that it doesn't fit within the @rustbot author |
|
I've added such a test case, where the type has width 104 > 100 if put on the second line. I believe its output is desired since it mirrors how a similar case with struct fields are formatted. That is, pub struct T {
field_name_that_is_kind_of_really_long1:
[ThisTypeIsReallyLongAbcdefghikjlmnopqrstuvwxyz; usernames::constants::USERNAME_LINK_ENTROPY_SIZE],
}becomes pub struct T {
field_name_that_is_kind_of_really_long1:
[ThisTypeIsReallyLongAbcdefghikjlmnopqrstuvwxyz; usernames::constants::USERNAME_LINK_ENTROPY_SIZE],
}So the array type is still split in two, with the first part on the first line, and the second part on the second line. @rustbot ready |
| // type is really long that it doesn't fit on the next line | ||
| pub(super) const ENCRYPTED_USERNAME_ENTROPY: [ThisTypeIsReallyLongAbcdefghikjlmnopqrstuvwxyz; | ||
| usernames::constants::USERNAME_LINK_ENTROPY_SIZE] = | ||
| const_str::hex!("4302c613c092a51c5394becffeb6f697300a605348e93f03c3db95e0b03d28f1"); |
There was a problem hiding this comment.
hmmm 🤔 so when the type is too long we still end up with the same formatting that #6976 was hoping to avoid. To be honest, I'm not sure how to handle this right now. I'd like @rust-lang/style to weigh in on this one before moving forward.
Edit: Here's the link to the Zulip discussion: #t-style > Guidance on Array Type wrapping
Fix for: #6976
Mimicking how types are rewritten in
rewrite_struct_field:rewrite_assign_rhs.