Some cleanups around fatal errors and delayed bugs - #162057
Conversation
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.
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.
|
|
|
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.
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
r? mejrs |
|
☔ The latest upstream changes (presumably #162284) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
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.