Some cleanups around fatal errors and delayed bugs - #162057
Conversation
|
|
|
r? @mu001999 rustbot has assigned @mu001999. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| error: values of the type `[&usize; usize::MAX]` are too big for the target architecture | ||
| --> $SRC_DIR/alloc/src/boxed.rs:LL:COL | ||
|
|
||
| error[E0080]: values of the type `[&usize; usize::MAX]` are too big for the target architecture | ||
| --> $SRC_DIR/core/src/mem/mod.rs:LL:COL |
There was a problem hiding this comment.
Only one of these errors has the E0080 code attached to it, can you make it consistent?
There was a problem hiding this comment.
E0080 indicates that a const failed to evaluate: https://doc.rust-lang.org/error_codes/E0080.html
A constant value failed to get evaluated.
Erroneous code example:
enum Enum { X = (1 << 500), Y = (1 / 0), }This error indicates that the compiler was unable to sensibly evaluate a constant expression that had to be evaluated. Attempting to divide by 0 or causing an integer overflow are two ways to induce this error.
Ensure that the expressions given can be evaluated as the desired integer type.
See the Discriminants section of the Reference for more information about setting custom integer types on enums using the repr attribute.
The first error however doesn't happen during const eval at all. It happens when determining the function ABI.
| if let Ok(data) = self.tcx.eval_static_initializer(def_id) { | ||
| record!(self.tables.eval_static_initializer[def_id] <- data); | ||
| } |
There was a problem hiding this comment.
Is removing this unwrap sound? ( alternatively, one could delay a bug in the err case)
There was a problem hiding this comment.
eval_static_initializer returns Result<_, ErrorGuranteed>.
There was a problem hiding this comment.
It returns Result<_, ErrorHandled> and ErrorHandled has a variant without an ErrorGuaranteed. I don't know whether that could happen here.
There was a problem hiding this comment.
Right, ErrorHandled::TooGeneric can't happen here as statics are never generic. But will change it to a delayed bug anyway just in case.
There was a problem hiding this comment.
Thanks! I do occasionally see proposals for generic statics... so this delayed bug would be nice to have.
This comment has been minimized.
This comment has been minimized.
|
r? mejrs |
This comment has been minimized.
This comment has been minimized.
A fatal error that doesn't actually abort is indistinguishable from a regular error. And the only places where emit_almost_fatal is called, the produced FatalError is ignored.
8ae4868 to
716eefa
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
716eefa to
3e9e27f
Compare
This comment has been minimized.
This comment has been minimized.
3e9e27f to
aa30063
Compare
|
This PR changes a file inside |
This comment has been minimized.
This comment has been minimized.
d490eb1 to
00d1de5
Compare
This comment has been minimized.
This comment has been minimized.
This avoids a delayed bug if compilation is aborted between checking function ABIs and codegening all functions.
And remove the encoded metadata if there are any errors or delayed bugs after encoding.
00d1de5 to
34fe2b3
Compare
|
Since the review I added the delayed bug as requested and changed an ICE crash test to a build-fail test as the third commit fixes it. @rustbot ready |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
With the aim of making it easier to move some compiler passes to different locations. And in particular to allow moving them across
has_errors_or_delayed_bugscalls. This is a prerequisite for a local change that improves the effectiveness of cargo build pipelining.Fixes #152204