Skip to content

ICE: added error handle for values greater than 9999 in #140700

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Kivooeo
Copy link
Contributor

@Kivooeo Kivooeo commented May 6, 2025

removed panic in case where we do --explain > 9999 and added check for it

now error looks like this instead of ICE

$ rustc.exe --explain E10000
error: E10000 is not a valid error code

fixes #140647
r? @fmease

@rustbot
Copy link
Collaborator

rustbot commented May 6, 2025

fmease is on vacation.

Please choose another assignee.

@rustbot
Copy link
Collaborator

rustbot commented May 6, 2025

r? @davidtwco

rustbot has assigned @davidtwco.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 6, 2025
@rust-log-analyzer

This comment has been minimized.

@fmease fmease assigned fmease and unassigned davidtwco May 6, 2025
@fmease fmease added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 6, 2025
@jieyouxu
Copy link
Member

jieyouxu commented May 6, 2025

I feel like this is very arbitrary. The 9999 limit is just an internal implementation detail (an internal "this is obviously wrong" check and would be bumped if we ever get to that many error codes) and shouldn't be exposed to the user. I would've just expected

$ rustc --explain E12345
error: E12345 is not a valid error code

to behave the same as

$ rustc --explain E4444
error: E4444 is not a valid error code

and

$ rustc --explain E12345678901234567890 # exceeds u32::MAX
error: E12345678901234567890 is not a valid error code

to gracefully fail with the same error message.

@Kivooeo
Copy link
Contributor Author

Kivooeo commented May 6, 2025

@jieyouxu any actual idea why tidy start fails here?

tidy check
tidy error: Error code `E9999` is used in the compiler but not defined and documented in `compiler/rustc_error_codes/src/lib.rs`.

like... should I just add E9999 there..?
and about your suggestion, you asking to merge both errors into one error_code is not a valid error code right?

@rustbot
Copy link
Collaborator

rustbot commented May 6, 2025

Some changes occurred in diagnostic error codes

cc @GuillaumeGomez

@Kivooeo
Copy link
Contributor Author

Kivooeo commented May 6, 2025

oh no, looks like adding E9999 was a miskate here
but it actually makes tidy pass, so idk, correct me here pls

Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any actual idea why tidy start fails here?

I'm pretty sure it's simply due to tidy (src/tools/tidy/src/error_codes.rs:361) grepping through ~all Rust compiler source files looking for \bE\d{4}\b and finding the E9999 in your previous error message that you've since removed.

@rust-log-analyzer

This comment has been minimized.

@Kivooeo Kivooeo force-pushed the new-fix-six branch 2 times, most recently from affc073 to 7af4bb6 Compare May 6, 2025 13:37
@ShE3py
Copy link
Contributor

ShE3py commented May 6, 2025

You may want to add a regression test based on tests/ui/explain.rs

@Kivooeo
Copy link
Contributor Author

Kivooeo commented May 6, 2025

@ShE3py oh, yes i want to add tests for it, didnt knew that there is some for --explain, should i create it separate tests or can do it in one file?

yeah, i guess i cant do this in one file
error: Option 'explain' given more than once

@ShE3py
Copy link
Contributor

ShE3py commented May 6, 2025

Yup, that's unfortunate but AFAIK you can only run rustc once per file.

Btw, //~? may be interesting to use:
https://rustc-dev-guide.rust-lang.org/tests/ui.html#error-without-line-information

@Kivooeo
Copy link
Contributor Author

Kivooeo commented May 6, 2025

yep, //~? is a nice one

Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two suggestions then we should be good to go!

@Kivooeo
Copy link
Contributor Author

Kivooeo commented May 6, 2025

@fmease seems done, but check pls if i got you and made all right
i also may should add some tests for other cases like valid error code for error that not exists or just something weird like word instead of number etc

@fmease
Copy link
Member

fmease commented May 6, 2025

i also may should add some tests for other cases like valid error code for error that not exists or just something weird like word instead of number etc

If you'd like to, go right ahead, sure sounds like a good idea.

@Kivooeo
Copy link
Contributor Author

Kivooeo commented May 6, 2025

@fmease should be good to go, added few more test cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rustc explain panics with error code longer than 4 digits
7 participants