diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-03-21 19:00:13 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-21 19:00:13 +0100 |
| commit | 25b062d586118b2c58e151ed4f0aa467271b03d9 (patch) | |
| tree | 996a7f3191c18d7958594dacabd58b29c6dafb93 | |
| parent | 081c607b0afb496fa61ab1b66a6615f9ea6ac663 (diff) | |
| parent | cbb8066321b65cc6762ee2645bea5fc050e62eee (diff) | |
| download | rust-25b062d586118b2c58e151ed4f0aa467271b03d9.tar.gz rust-25b062d586118b2c58e151ed4f0aa467271b03d9.zip | |
Rollup merge of #109403 - chenyukang:yukang/fix-109396, r=estebank
Avoid ICE of attempt to add with overflow in emitter Fixes #109396 r? ```@estebank```
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 2 | ||||
| -rw-r--r-- | tests/ui/suggestions/issue-109396.rs | 12 | ||||
| -rw-r--r-- | tests/ui/suggestions/issue-109396.stderr | 34 |
3 files changed, 47 insertions, 1 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index bab4f31e777..9866a9bffe0 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -331,7 +331,7 @@ impl CodeSuggestion { }); buf.push_str(&part.snippet); let cur_hi = sm.lookup_char_pos(part.span.hi()); - if cur_hi.line == cur_lo.line { + if cur_hi.line == cur_lo.line && !part.snippet.is_empty() { // Account for the difference between the width of the current code and the // snippet being suggested, so that the *later* suggestions are correctly // aligned on the screen. diff --git a/tests/ui/suggestions/issue-109396.rs b/tests/ui/suggestions/issue-109396.rs new file mode 100644 index 00000000000..b6c464d45a2 --- /dev/null +++ b/tests/ui/suggestions/issue-109396.rs @@ -0,0 +1,12 @@ +fn main() { + { + let mut mutex = std::mem::zeroed( + //~^ ERROR this function takes 0 arguments but 4 arguments were supplied + file.as_raw_fd(), + //~^ ERROR expected value, found macro `file` + 0, + 0, + 0, + ); + } +} diff --git a/tests/ui/suggestions/issue-109396.stderr b/tests/ui/suggestions/issue-109396.stderr new file mode 100644 index 00000000000..eca160e2fab --- /dev/null +++ b/tests/ui/suggestions/issue-109396.stderr @@ -0,0 +1,34 @@ +error[E0423]: expected value, found macro `file` + --> $DIR/issue-109396.rs:5:13 + | +LL | file.as_raw_fd(), + | ^^^^ not a value + +error[E0061]: this function takes 0 arguments but 4 arguments were supplied + --> $DIR/issue-109396.rs:3:25 + | +LL | let mut mutex = std::mem::zeroed( + | ^^^^^^^^^^^^^^^^ +LL | +LL | file.as_raw_fd(), + | ---------------- unexpected argument +LL | +LL | 0, + | - unexpected argument of type `{integer}` +LL | 0, + | - unexpected argument of type `{integer}` +LL | 0, + | - unexpected argument of type `{integer}` + | +note: function defined here + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL +help: remove the extra arguments + | +LL - file.as_raw_fd(), +LL + , + | + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0061, E0423. +For more information about an error, try `rustc --explain E0061`. |
