Skip to content

Some cleanups around fatal errors and delayed bugs - #162057

Open
bjorn3 wants to merge 4 commits into
rust-lang:mainfrom
bjorn3:fatal_cleanup
Open

Some cleanups around fatal errors and delayed bugs#162057
bjorn3 wants to merge 4 commits into
rust-lang:mainfrom
bjorn3:fatal_cleanup

Conversation

@bjorn3

@bjorn3 bjorn3 commented Aug 31, 2026

Copy link
Copy Markdown
Member

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_bugs calls. This is a prerequisite for a local change that improves the effectiveness of cargo build pipelining.

bjorn3 added 4 commits August 31, 2026 12:16
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.
@rustbot

rustbot commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

rustc_codegen_gcc is developed in its own repository. If possible, consider making this change to rust-lang/rustc_codegen_gcc instead.

cc @antoyo, @GuillaumeGomez

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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 Aug 31, 2026
@rustbot

rustbot commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

r? @mu001999

rustbot has assigned @mu001999.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 18 candidates

Comment on lines +1 to 5
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

@mejrs mejrs Aug 31, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Only one of these errors has the E0080 code attached to it, can you make it consistent?

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Comment on lines +1588 to +1590
if let Ok(data) = self.tcx.eval_static_initializer(def_id) {
record!(self.tables.eval_static_initializer[def_id] <- data);
}

@mejrs mejrs Aug 31, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is removing this unwrap sound? ( alternatively, one could delay a bug in the err case)

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

eval_static_initializer returns Result<_, ErrorGuranteed>.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It returns Result<_, ErrorHandled> and ErrorHandled has a variant without an ErrorGuaranteed. I don't know whether that could happen here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Right, ErrorHandled::TooGeneric can't happen here as statics are never generic. But will change it to a delayed bug anyway just in case.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! I do occasionally see proposals for generic statics... so this delayed bug would be nice to have.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job x86_64-gnu-llvm-21 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
---- [ui] tests/ui/limits/issue-17913.rs stdout ----
Saved the actual 32bit.stderr to `/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/limits/issue-17913/issue-17913.32bit.stderr`
diff of 32bit.stderr:

+ error: values of the type `[&usize; usize::MAX]` are too big for the target architecture
+   --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
+ 
1 error[E0080]: values of the type `[&usize; usize::MAX]` are too big for the target architecture
2   --> $SRC_DIR/core/src/mem/mod.rs:LL:COL
3    |

9 LL |     let a: Box<_> = Box::new([&n; SIZE]);
10    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11 
- error: aborting due to 1 previous error
+ error: aborting due to 2 previous errors
13 
14 For more information about this error, try `rustc --explain E0080`.
15 

Note: some mismatched output was normalized before being compared
-   --> /rustc/FAKE_PREFIX/library/alloc/src/boxed.rs:290:4
+ error: values of the type `[&usize; usize::MAX]` are too big for the target architecture
+   --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
+ 
+ error: aborting due to 2 previous errors


The actual 32bit.stderr differed from the expected 32bit.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args limits/issue-17913.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/limits/issue-17913.rs" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=i686-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/limits/issue-17913" "-Znext-solver=coherence" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/i686-unknown-linux-gnu/native/rust-test-helpers" "-Clinker=x86_64-linux-gnu-gcc"
stdout: none
--- stderr -------------------------------
error: values of the type `[&usize; usize::MAX]` are too big for the target architecture
##[error]  --> /rustc/FAKE_PREFIX/library/alloc/src/boxed.rs:290:4

error[E0080]: values of the type `[&usize; usize::MAX]` are too big for the target architecture
##[error]  --> /rustc/FAKE_PREFIX/library/core/src/mem/mod.rs:1463:24
   |
   = note: evaluation of `<[&usize; usize::MAX] as std::mem::SizedTypeProperties>::SIZE` failed here

note: the above error was encountered while instantiating `fn Box::<[&usize; usize::MAX]>::new`
  --> /checkout/tests/ui/limits/issue-17913.rs:16:21
   |
LL |     let a: Box<_> = Box::new([&n; 0xFFFFFFFF_usize]);
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0080`.

@mu001999

Copy link
Copy Markdown
Member

r? mejrs

@rustbot rustbot assigned mejrs and unassigned mu001999 Aug 31, 2026

@mejrs mejrs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

r=me with delayed bug added and ci green

View changes since this review

@rust-bors

rust-bors Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #162284) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants