reserved width for unsafe in match arm pattern - #7097
Conversation
|
one question? should this change be gated? |
|
@AsthaMishra Thank you for working on this. Yeah, let's gate this fix on |
|
Also are we sure that things are correct for other types of blocks? Let's add test cases for them just to be sure. |
…iles also updated for same
| try {} | ||
| } | ||
| _ => {} | ||
| } |
There was a problem hiding this comment.
Looks like we're forcing const, async, gen, and try blocks to be wrapped in an outer block. Does that always happen or just when we can't fit everything onto one line?
unsafe 6 chars
const 5 chars
async 5 chars
gen 3 chars
try 3 chars
All of these are getting tested against the same ( ExampleTypeX::VariantAlphaSampleXYZ, ExampleTypeX::VariantBetaXYZ) tuple. To make sure we're exhaustively testing this I would like to test the following cases for each type of block:
- 1 char below the
max_widthlimit when accounting for the pattern,=>,keyword,{, and any whitespace in between.. - everything properly fits on 1 line at exactly the
max_widthlimit when accounting for the pattern,=>,keyword,{, and any whitespace in between.. - 1 char over the
max_widthlimit when accounting for the pattern,=>,keyword,{, and any whitespace in between.
Issue :
unsafeis a block with labelNoneand when patterns code executes and label: None is found, execution goes to fallback arm where only 5 column spaces are reserved (which is correct forasync,const,genandtryblocks) but unsafe needs 12 column spaces, this is what causingmax_widthviolation and when run with--config error_on_line_overflow=trueit does give line overflow error for max-width 80Fix : added an arm for unsafe block to reserve required space for unsafe
Fixes : #6848