diff options
| author | bors <bors@rust-lang.org> | 2021-07-29 07:12:07 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-07-29 07:12:07 +0000 |
| commit | 6e0a8bf7901a3fe2e073b1e702e80f58b76d5087 (patch) | |
| tree | bd9b79e97e2d2204a5a1c2e22b9459811cc59809 /library/std/src/lib.rs | |
| parent | 581b1664c92f78f3d15181c78a16480987256ecb (diff) | |
| parent | 312bf8e0b8122fd681adf28f65e88f8d15f7a34c (diff) | |
| download | rust-6e0a8bf7901a3fe2e073b1e702e80f58b76d5087.tar.gz rust-6e0a8bf7901a3fe2e073b1e702e80f58b76d5087.zip | |
Auto merge of #86998 - m-ou-se:const-panic-fmt-as-str, r=oli-obk
Make const panic!("..") work in Rust 2021.
During const eval, this replaces calls to core::panicking::panic_fmt and std::panicking::being_panic_fmt with a call to a new const fn: core::panicking::const_panic_fmt. That function uses fmt::Arguments::as_str() to get the str and calls panic_str with that instead.
panic!() invocations with formatting arguments are still not accepted, as the creation of such a fmt::Arguments cannot be done in constant functions right now.
r? `@RalfJung`
Diffstat (limited to 'library/std/src/lib.rs')
| -rw-r--r-- | library/std/src/lib.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 9cbaa06562a..21a1ee137ef 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -247,6 +247,7 @@ #![feature(const_fn_floating_point_arithmetic)] #![feature(const_fn_fn_ptr_basics)] #![cfg_attr(bootstrap, feature(const_fn_transmute))] +#![feature(const_format_args)] #![feature(const_io_structs)] #![feature(const_ip)] #![feature(const_ipv4)] @@ -555,9 +556,9 @@ pub use core::{ #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[allow(deprecated)] pub use core::{ - assert, assert_matches, cfg, column, compile_error, concat, concat_idents, env, file, - format_args, format_args_nl, include, include_bytes, include_str, line, llvm_asm, log_syntax, - module_path, option_env, stringify, trace_macros, + assert, assert_matches, cfg, column, compile_error, concat, concat_idents, const_format_args, + env, file, format_args, format_args_nl, include, include_bytes, include_str, line, llvm_asm, + log_syntax, module_path, option_env, stringify, trace_macros, }; #[stable(feature = "core_primitive", since = "1.43.0")] |
