Skip to content

Convert to inline diagnostics in rustc_const_eval#152186

Open
GuillaumeGomez wants to merge 1 commit intorust-lang:mainfrom
GuillaumeGomez:inline-diag-rustc_const_eval
Open

Convert to inline diagnostics in rustc_const_eval#152186
GuillaumeGomez wants to merge 1 commit intorust-lang:mainfrom
GuillaumeGomez:inline-diag-rustc_const_eval

Conversation

@GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Feb 5, 2026

@rustbot
Copy link
Collaborator

rustbot commented Feb 5, 2026

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

Some changes occurred to constck

cc @fee1-dead

⚠️ #[rustc_intrinsic_const_stable_indirect] controls whether intrinsics can be exposed to stable const
code; adding it needs t-lang approval.

cc @rust-lang/wg-const-eval

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

@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 Feb 5, 2026
Comment on lines +699 to +701
DanglingIntPointer { addr: 0, .. } => inline_fluent!("{$operation ->
[MemoryAccess] memory access failed
[InboundsPointerArithmetic] in-bounds pointer arithmetic failed
Copy link
Member

Choose a reason for hiding this comment

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

Here and in many other places, the indentation is rather broken, making this quite hard to read. Is there a way to avoid that?

Copy link
Contributor

@JonathanBrouwer JonathanBrouwer Feb 5, 2026

Choose a reason for hiding this comment

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

On my PRs I manually indented all of these to align with the surrounding code, is very possible to fix :)

@@ -1,10 +1,12 @@
//! Manages calling a concrete function (with known MIR body) with argument passing,
//! and returning the return value to the caller.
//! and returning the return value to the caller.use rustc_errors::inline_fluent;
Copy link
Member

Choose a reason for hiding this comment

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

Something seems to have gone wrong here...

= note: see issue #143874 <https://github.com/rust-lang/rust/issues/143874> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did this diagnostic change?

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
fmt check
Diff in /checkout/compiler/rustc_const_eval/src/errors.rs:21:
 use crate::interpret::InternKind;
 
 #[derive(Diagnostic)]
-#[diag(r#"encountered dangling pointer in final value of {$kind ->
+#[diag(
+    r#"encountered dangling pointer in final value of {$kind ->
     [static] static
     [static_mut] mutable static
     [const] constant
Diff in /checkout/compiler/rustc_const_eval/src/errors.rs:28:
     [promoted] promoted
     *[other] {""}
-}"#)]
+}"#
+)]
 pub(crate) struct DanglingPtrInFinal {
     #[primary_span]
     pub span: Span,
Diff in /checkout/compiler/rustc_const_eval/src/errors.rs:44:
 }
 
 #[derive(Diagnostic)]
-#[diag(r#"encountered mutable pointer in final value of {$kind ->
+#[diag(
+    r#"encountered mutable pointer in final value of {$kind ->
     [static] static
     [static_mut] mutable static
     [const] constant
Diff in /checkout/compiler/rustc_const_eval/src/errors.rs:51:
     [promoted] promoted
     *[other] {""}
-}"#)]
+}"#
+)]
 pub(crate) struct MutablePtrInFinal {
     #[primary_span]
     pub span: Span,
Diff in /checkout/compiler/rustc_const_eval/src/errors.rs:68:
 }
 
 #[derive(Diagnostic)]
-#[diag(r#"encountered partial pointer in final value of {$kind ->
+#[diag(
+    r#"encountered partial pointer in final value of {$kind ->
     [static] static
     [static_mut] mutable static
     [const] constant
Diff in /checkout/compiler/rustc_const_eval/src/errors.rs:75:
     [promoted] promoted
     *[other] {""}
-}"#)]
+}"#
+)]
 #[note(
     "while pointers can be broken apart into individual bytes during const-evaluation, only complete pointers (with all their bytes in the right order) are supported in the final value"
 )]
Diff in /checkout/compiler/rustc_const_eval/src/errors.rs:119:
 #[derive(Diagnostic)]
 #[diag("pointers cannot be cast to integers during const eval")]
 #[note("at compile-time, pointers do not have an integer value")]
-#[note("avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior")]
+#[note(
+    "avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior"
+)]
 pub(crate) struct RawPtrToIntErr {
     #[primary_span]
     pub span: Span,
Diff in /checkout/compiler/rustc_const_eval/src/errors.rs:213:
 #[note(
     "temporaries in constants and statics can have their lifetime extended until the end of the program"
 )]
-#[note(
-    "to avoid accidentally creating global mutable state, such temporaries must be immutable"
-)]
+#[note("to avoid accidentally creating global mutable state, such temporaries must be immutable")]
 #[help(
     "if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut`"
 )]
Diff in /checkout/compiler/rustc_const_eval/src/errors.rs:292:
 }s"#, code = E0010)]
 pub(crate) struct UnallowedHeapAllocations {
     #[primary_span]
-    #[label(r#"allocation not allowed in {$kind ->
+    #[label(
+        r#"allocation not allowed in {$kind ->
     [const] constant
     [static] static
     [const_fn] constant function
Diff in /checkout/compiler/rustc_const_eval/src/errors.rs:299:
     *[other] {""}
-}s"#)]
+}s"#
+    )]
     pub span: Span,
     pub kind: ConstContext,
     #[note(
Diff in /checkout/compiler/rustc_const_eval/src/errors.rs:324:
 #[note(
     "temporaries in constants and statics can have their lifetime extended until the end of the program"
 )]
-#[note(
-    "to avoid accidentally creating global mutable state, such temporaries must be immutable"
+#[note("to avoid accidentally creating global mutable state, such temporaries must be immutable")]
+#[help(
+    "if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut`"
 )]
-#[help("if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut`")]
 pub(crate) struct InteriorMutableBorrowEscaping {
     #[primary_span]
     #[label("this borrow of an interior mutable value refers to such a temporary")]
fmt: checked 6701 files
Bootstrap failed while executing `--stage 2 test --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`
Build completed unsuccessfully in 0:00:26
  local time: Thu Feb  5 21:33:13 UTC 2026
  network time: Thu, 05 Feb 2026 21:33:14 GMT

@JonathanBrouwer
Copy link
Contributor

@rustbot author

@rustbot rustbot 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 Feb 6, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 6, 2026

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

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.

5 participants