about summary refs log tree commit diff
path: root/tests/codegen/patchable-function-entry
diff options
context:
space:
mode:
authortdanniels <tdanniels@gmail.com>2023-07-18 18:48:57 -0700
committerGitHub <noreply@github.com>2023-07-18 20:48:57 -0500
commitb944a32e5cd153344ec93827821d8607c3988a09 (patch)
treeb81e57b70396a00458ef68f4f8fbe4421192bae3 /tests/codegen/patchable-function-entry
parent184296754238c78e97fa469cf2b6983f5d0b513c (diff)
downloadrust-b944a32e5cd153344ec93827821d8607c3988a09.tar.gz
rust-b944a32e5cd153344ec93827821d8607c3988a09.zip
Prevent ICE when formatting an empty-ish macro arm (#5833)
Fixes 5730

Previously rustfmt was attempting to slice a string with an invalid
range (`start > end`), leading to the ICE.

When formatting a macro transcriber snippet consisting of a lone
semicolon, the snippet was being formatted into the empty string,
leading the enclosing `fn main() {\n}` added by `format_code_block` to
be formatted into `fn main() {}`. However, rustfmt was assuming that the
enclosing function string's length had been left unchanged. This was
leading to an invalid range being constructed when attempting to trim
off the enclosing function.

The fix is to just clamp the range's start to be less than or equal
to the range's end, since if `end < start` there's nothing to iterate
over anyway.
Diffstat (limited to 'tests/codegen/patchable-function-entry')
0 files changed, 0 insertions, 0 deletions