-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Closed
Copy link
Labels
A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCLibs-TrackedLibs issues that are tracked on the team's project board.Libs issues that are tracked on the team's project board.T-langRelevant to the language teamRelevant to the language teamT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Milestone
Description
This is a tracking issue for RFC 3007 "Plan to make core and std's panic identical": rust-lang/rfcs#3007
Steps
- Add a lint for format strings incompatible with the edition change: Add lint for panic!("{}") #78088Add
std::panic::panic_any
: Add std::panic::panic_any. #74622Stabilizestd::panic::panic_any
: Tracking issue Tracking Issue forpanic_any
#78500, PR Stabilize std::panic::panic_any. #81194Add a lint for panicking on non-string-literals (and suggestpanic_any
): Add lint forpanic!(123)
which is not accepted in Rust 2021. #81645Updatepanic!()
documentation about non-string-literals: Part of Add lint forpanic!(123)
which is not accepted in Rust 2021. #81645Throw a&str
instead of aString
instd
when usingcore::panic!
: Throw core::panic!("message") as &str instead of String. #78119Fix hygiene intodo!()
,assert_eq!()
, etc. to always usecore::panic!()
: Qualifypanic!
ascore::panic!
in non-built-incore
macros #78343Fixassert!(expr, message)
to callcore
's panic mechanism directly: Part of Add lint for panic!("{}") #78088Fixassert!(expr)
to callcore
's panic mechanism directly in edition 2021: Expand assert!(expr, args..) to include $crate for hygiene on 2021. #80855Make{std, core}::panic!(..)
always useformat_args!(..)
in edition 2021: Implement Rust 2021 panic #80851- This needs Allow #[rustc_builtin_macro = "name"] #80850.
To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.Makestd::panic!(..)
an alias forcore::panic!(..)
in edition 2021:MakeIncluded in Implement Rust 2021 panic #80851.std::panic!()
identical tocore::panic!()
on Rust 2021 #80879This requires core::panic!() cannot be used everywhere std::panic!() can. #80846 to be fixed first
To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.Updatepanic_fmt
lint to mention edition 2021: Part of Add lint forpanic!(123)
which is not accepted in Rust 2021. #81645Fix 2021'sassert!(123, "{}")
expanding to the wrong edition ofpanic!()
: Fix bug with assert!() calling the wrong edition of panic!(). #81647Rename thepanic_fmt
lint tonon_fmt_panic
(see Add lint for panic!("{}") #78088 (comment)): Part of Add lint forpanic!(123)
which is not accepted in Rust 2021. #81645, beta backport in [beta] Renamepanic_fmt
lint tonon_fmt_panic
#81729To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Robbepop, samueltardieu and schneiderfelipeXanewok, DianaNites, GrayJack, safinsingh, shirshak55 and 1 moreDianaNites, GrayJack, imjasonmiller, safinsingh, shirshak55 and 3 more
Metadata
Metadata
Assignees
Labels
A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCLibs-TrackedLibs issues that are tracked on the team's project board.Libs issues that are tracked on the team's project board.T-langRelevant to the language teamRelevant to the language teamT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Projects
Relationships
Development
Select code repository
Activity
panic_any
#78500{ .. }
. #80848rodrimati1992 commentedon Jan 11, 2021
I'm a little confused about what's supported with these changes.
Do the changes here allow you to panic in
#![no_std]
crates with a non-literal&'static str
constant at compile-time?I made the
const_format
crate to allow me to do string formatting at compile-time before the standard library can do it, and need to be able to panic with a non-literal&'static str
to have my own static assertion macros.m-ou-se commentedon Jan 12, 2021
@rodrimati1992 Panicking at compile is unstable, both before and after these changes. The current unstable implementation of
const_panic
will not work right away with the new 2021 version ofpanic!()
, aspanic!(SOME_CONST)
is no longer accepted. The 2021 version of thepanic!()
macro will accept the exact same arguments as theprintln!()
macro. That is, the first argument must be a format string as string literal.Options for panicking at compile time with a non-literal string message in Rust 2021:
core::panicking::panic
instead of thepanic!()
macro (which is unstable, but so isconst_panic
) orconst_panic
to understand at leastpanic!("{}", SOME_CONSTANT)
, or15 remaining items
Rollup merge of rust-lang#81645 - m-ou-se:panic-lint, r=estebank,flip…
Rollup merge of rust-lang#81645 - m-ou-se:panic-lint, r=estebank,flip…
Rollup merge of rust-lang#81645 - m-ou-se:panic-lint, r=estebank,flip…
m-ou-se commentedon Feb 6, 2021
Done!
🎉
utils: fix rust 2021 warnings
djugei commentedon Jul 28, 2021
bit of a late comer, seeing that this rfc has already been accepted, but:
defining shared error messages now results in a warning, i.e.:
this can be easily resolved in user code by writing
but no actual formatting is needed, i just want to push a string literal to stderr. this especially means that i would like to avoid pulling in the format machinery if at all possible, because it has a noticeable impact on binary size.
m-ou-se commentedon Jul 28, 2021
@djugei #78356 would help with that. Ideally,
format_args!("{}", ERR_ALPHA)
results in the same trivialfmt::Arguments
asformat_args!("alpha error")
with a.as_str()
returningSome("alpha error")
to avoid any formatting.Depending on how far away we think that is, we could consider stabilizing
panic_str
in the meantime.djugei commentedon Jul 28, 2021
Ah, thanks i had not found panic_str (hidden under 2 layers of nightly), im ok with using nightly for now. Some const evaluation of format args could be cool though.