]> git.lizzy.rs Git - rust.git/commit - src/tools/rust-analyzer
Rollup merge of #91273 - Badel2:ice-index-str, r=estebank
authorMatthias Krüger <matthias.krueger@famsik.de>
Fri, 3 Dec 2021 05:24:14 +0000 (06:24 +0100)
committerGitHub <noreply@github.com>
Fri, 3 Dec 2021 05:24:14 +0000 (06:24 +0100)
commita5ee722f1ea6f9519d213a2304cc8edcf53f4cc3
treea02c1d736e429df8a9423482c8f68e111a4cc89b
parent0ccd56682578790abc045cfd0d0555f47e92f6b0
parent0da3a0f56eda3c360e63499b4ee452e55630d9ff
Rollup merge of #91273 - Badel2:ice-index-str, r=estebank

Fix ICE #91268 by checking that the snippet ends with a `)`

Fix #91268

Previously it was assumed that the last character of `snippet` will be a `)`, so using `snippet.len() - 1` as an index should be safe. However as we see in the test, it is possible to enter that branch without a closing `)`, and it will trigger the panic if the last character happens to be multibyte.

The fix is to ensure that the snippet ends with `)`, and skip the suggestion otherwise.
compiler/rustc_ast_lowering/src/path.rs