Files
rust/tests/ui
Matthias Krüger bc99a045cb Rollup merge of #139624 - m-ou-se:unconst-format-args, r=jhpratt
Don't allow flattened format_args in const.

Fixes https://github.com/rust-lang/rust/issues/139136

Fixes https://github.com/rust-lang/rust/issues/139621

We allow `format_args!("a")` in const, but don't allow any format_args with arguments in const, such as `format_args!("{}", arg)`.

However, we accidentally allow `format_args!("hello {}", "world")` in const, as it gets flattened to `format_args!("hello world")`.

This also applies to panic in const.

This wasn't supposed to happen. I added protection against this in the format args flattening code, ~~but I accidentally marked a function as const that shouldn't have been const~~ but this was removed in https://github.com/rust-lang/rust/pull/135139.

This is a breaking change. The crater found no breakage, however.

This breaks things like:

```rust
const _: () = if false { panic!("a {}", "a") };
```

and

```rust
const F: std::fmt::Arguments<'static> = format_args!("a {}", "a");
```
2025-04-30 17:27:57 +02:00
..
2025-03-03 08:52:07 +01:00
2025-03-11 20:26:10 -07:00
2025-04-03 21:41:58 +00:00
2025-04-25 12:16:40 +00:00
2025-04-25 20:50:57 +09:00
2025-04-15 11:14:23 +02:00
2025-04-21 16:16:38 +09:00
2025-03-30 01:32:21 +03:00
2025-04-04 09:44:19 +02:00
2025-03-11 20:26:10 -07:00
2025-03-27 14:11:11 +01:00
2025-04-25 20:50:57 +09:00
2025-04-03 21:41:58 +00:00
2025-04-03 21:41:58 +00:00
2025-04-04 16:32:18 +02:00