about summary refs log tree commit diff
path: root/library/core/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-05-03 03:52:37 +0000
committerbors <bors@rust-lang.org>2025-05-03 03:52:37 +0000
commit973ec11f61ba77123aafbb2799dd24f291250a2b (patch)
tree92c4f6ba0fce794421e07b35089c2161ed401bec /library/core/src
parent9d6fe3d1b2e24fad0574ef47915df47c72ba2ee3 (diff)
parent260fcc67f395d6961b8c1776c6c5cf64e8839517 (diff)
downloadrust-973ec11f61ba77123aafbb2799dd24f291250a2b.tar.gz
rust-973ec11f61ba77123aafbb2799dd24f291250a2b.zip
Auto merge of #140592 - cuviper:beta-next, r=cuviper
[beta] backports

- Don't allow flattened format_args in const. #139624
- set subsections_via_symbols for ld64 helper sections #139752
- Fix detection of `main` function if there are expressions around it #140220
- rustdoc: Fix doctest heuristic for main fn wrapping #140420
- extend the list of registered dylibs on `test::prepare_cargo_test` #140563

r? cuviper
Diffstat (limited to 'library/core/src')
-rw-r--r--library/core/src/fmt/rt.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/library/core/src/fmt/rt.rs b/library/core/src/fmt/rt.rs
index d27f7e6e0d8..eab48466599 100644
--- a/library/core/src/fmt/rt.rs
+++ b/library/core/src/fmt/rt.rs
@@ -205,8 +205,15 @@ impl Argument<'_> {
     /// let f = format_args!("{}", "a");
     /// println!("{f}");
     /// ```
+    ///
+    /// This function should _not_ be const, to make sure we don't accept
+    /// format_args!() and panic!() with arguments in const, even when not evaluated:
+    ///
+    /// ```compile_fail,E0015
+    /// const _: () = if false { panic!("a {}", "a") };
+    /// ```
     #[inline]
-    pub const fn none() -> [Self; 0] {
+    pub fn none() -> [Self; 0] {
         []
     }
 }