about summary refs log tree commit diff
path: root/tests/ui
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-05-01 22:27:24 +0200
committerGitHub <noreply@github.com>2025-05-01 22:27:24 +0200
commit6cb75d88ebe12675eb359d7c0ecf73cb55ff4ccc (patch)
treef9defb0a63cfdffd2f1b3f6a0c2edfd0d06173b7 /tests/ui
parent786a53d2dbc5fa34d20b541176976ddf421ddd31 (diff)
parent86c6e7911d2ccf69f8306f5bfb10233025dc8e22 (diff)
downloadrust-6cb75d88ebe12675eb359d7c0ecf73cb55ff4ccc.tar.gz
rust-6cb75d88ebe12675eb359d7c0ecf73cb55ff4ccc.zip
Rollup merge of #140544 - m-ou-se:format-args-const-cleanup, r=fee1-dead
Clean up "const" situation in format_args!().

This cleans up the "const" situation in the format_args!() expansion/lowering.

Rather than marking the Argument::new_display etc. functions as non-const, this marks the Arguments::new_v1 functions as non-const.

Example expansion/lowering of format_args!() in const:

```rust
// Error: cannot call non-const formatting macro in constant functions
const {
    fmt::Arguments::new_v1( // Now the error is produced here.
        &["Hello, ", "!\n"],
        &[
            fmt::Argument::new_display(&world) // The error used to be produced here.
        ],
    )
}
```
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/consts/const-eval/format.stderr8
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/ui/consts/const-eval/format.stderr b/tests/ui/consts/const-eval/format.stderr
index 4c4cbb372a7..2f202705b7f 100644
--- a/tests/ui/consts/const-eval/format.stderr
+++ b/tests/ui/consts/const-eval/format.stderr
@@ -1,16 +1,16 @@
 error[E0015]: cannot call non-const formatting macro in constant functions
-  --> $DIR/format.rs:2:13
+  --> $DIR/format.rs:2:5
    |
 LL |     panic!("{:?}", 0);
-   |             ^^^^
+   |     ^^^^^^^^^^^^^^^^^
    |
    = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
 
 error[E0015]: cannot call non-const formatting macro in constant functions
-  --> $DIR/format.rs:7:15
+  --> $DIR/format.rs:7:5
    |
 LL |     println!("{:?}", 0);
-   |               ^^^^
+   |     ^^^^^^^^^^^^^^^^^^^
    |
    = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
    = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)