diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-04-30 17:27:57 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-30 17:27:57 +0200 |
| commit | bc99a045cb0786b8a6f92abc5e80acd04dc74886 (patch) | |
| tree | 735fdd1b13bb9dcfd8d95c31685f919dca9706f3 /compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp | |
| parent | 555df301f820e97083207f47864a3321eeee425c (diff) | |
| parent | 56426db0b634fcd8d7e5842f39593651a594e602 (diff) | |
| download | rust-bc99a045cb0786b8a6f92abc5e80acd04dc74886.tar.gz rust-bc99a045cb0786b8a6f92abc5e80acd04dc74886.zip | |
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");
```
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
