Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid ICE of attempt to add with overflow in emitter #109403

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions tests/ui/suggestions/issue-109396.rs
Original file line number Diff line number Diff line change
@@ -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,
);
}
}
34 changes: 34 additions & 0 deletions tests/ui/suggestions/issue-109396.stderr
Original file line number Diff line number Diff line change
@@ -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`.