rust/library
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
..
alloc Auto merge of #140188 - nnethercote:streamline-format-macro, r=cuviper 2025-04-30 04:04:21 +00:00
alloctests Suggest {to,from}_ne_bytes for transmutations between arrays and integers, etc 2025-04-24 13:14:36 +07:00
backtrace@9d2c34e7e6 Update backtrace 2025-02-13 14:32:50 -08:00
core Rollup merge of #139624 - m-ou-se:unconst-format-args, r=jhpratt 2025-04-30 17:27:57 +02:00
coretests Rollup merge of #134446 - tgross35:stabilize-cell_update, r=jhpratt 2025-04-24 08:12:56 +02:00
panic_abort Migrate panic_abort to Rust 2024 2025-03-11 09:46:34 -07:00
panic_unwind update cfgs 2025-04-09 12:29:59 +01:00
portable-simd Merge commit 'c14f2fc3eb' into sync-from-portable-simd-2025-03-19 2025-03-19 00:58:47 -04:00
proc_macro Stabilize proc_macro::Span::{start, end, line, column}. 2025-04-15 17:29:04 +02:00
profiler_builtins Fix profiler_builtins build script to handle full path to profiler lib 2025-04-11 16:57:38 +02:00
rtstartup Revert changes for rtstartup 2025-03-10 21:23:31 +08:00
rustc-std-workspace-alloc Migrated the rustc-std-workspace crates to Rust 2024 2025-03-11 09:46:35 -07:00
rustc-std-workspace-core Migrated the rustc-std-workspace crates to Rust 2024 2025-03-11 09:46:35 -07:00
rustc-std-workspace-std Migrated the rustc-std-workspace crates to Rust 2024 2025-03-11 09:46:35 -07:00
std Rollup merge of #140323 - tgross35:cfg-unstable-float, r=Urgau 2025-04-28 23:29:17 +00:00
stdarch@1245618ccf stdarch 2025-04-24 13:14:43 +07:00
sysroot Migrate the sysroot crate to Rust 2024 2025-03-11 09:46:35 -07:00
test Remove backticks from ShouldPanic::YesWithMessage's TrFailedMsg 2025-04-28 21:40:29 +02:00
unwind unwind: bump unwinding dependency to 0.2.6 2025-04-29 09:46:32 +08:00
windows_targets Migrate windows-targets to Rust 2024 2025-03-11 09:46:35 -07:00
Cargo.lock Rollup merge of #140422 - betrusted-io:bump-unwinding-to-0.2.6, r=workingjubilee 2025-04-29 12:28:24 -04:00
Cargo.toml Add opt-level = "s" for more std symbolication crates 2025-04-01 20:50:19 +00:00