Skip to content

Commit 25b062d

Browse files
authored
Rollup merge of #109403 - chenyukang:yukang/fix-109396, r=estebank
Avoid ICE of attempt to add with overflow in emitter Fixes #109396 r? ```@estebank```
2 parents 081c607 + cbb8066 commit 25b062d

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

compiler/rustc_errors/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ impl CodeSuggestion {
331331
});
332332
buf.push_str(&part.snippet);
333333
let cur_hi = sm.lookup_char_pos(part.span.hi());
334-
if cur_hi.line == cur_lo.line {
334+
if cur_hi.line == cur_lo.line && !part.snippet.is_empty() {
335335
// Account for the difference between the width of the current code and the
336336
// snippet being suggested, so that the *later* suggestions are correctly
337337
// aligned on the screen.

tests/ui/suggestions/issue-109396.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fn main() {
2+
{
3+
let mut mutex = std::mem::zeroed(
4+
//~^ ERROR this function takes 0 arguments but 4 arguments were supplied
5+
file.as_raw_fd(),
6+
//~^ ERROR expected value, found macro `file`
7+
0,
8+
0,
9+
0,
10+
);
11+
}
12+
}
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
error[E0423]: expected value, found macro `file`
2+
--> $DIR/issue-109396.rs:5:13
3+
|
4+
LL | file.as_raw_fd(),
5+
| ^^^^ not a value
6+
7+
error[E0061]: this function takes 0 arguments but 4 arguments were supplied
8+
--> $DIR/issue-109396.rs:3:25
9+
|
10+
LL | let mut mutex = std::mem::zeroed(
11+
| ^^^^^^^^^^^^^^^^
12+
LL |
13+
LL | file.as_raw_fd(),
14+
| ---------------- unexpected argument
15+
LL |
16+
LL | 0,
17+
| - unexpected argument of type `{integer}`
18+
LL | 0,
19+
| - unexpected argument of type `{integer}`
20+
LL | 0,
21+
| - unexpected argument of type `{integer}`
22+
|
23+
note: function defined here
24+
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
25+
help: remove the extra arguments
26+
|
27+
LL - file.as_raw_fd(),
28+
LL + ,
29+
|
30+
31+
error: aborting due to 2 previous errors
32+
33+
Some errors have detailed explanations: E0061, E0423.
34+
For more information about an error, try `rustc --explain E0061`.

0 commit comments

Comments
 (0)