File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,25 @@ For more detailed information about error handling check out the [book] or the
6464If the main thread panics it will terminate all your threads and end your
6565program with code ` 101 ` .
6666
67+ # Editions
68+
69+ In Rust Editions prior to 2021, ` std::panic!(x) ` with a single
70+ argument is equivalent to
71+ [ ` std::panic::panic_any(x) ` ] ( ../std/panic/fn.panic_any.html ) .
72+ This is true even if the argument is a string literal.
73+
74+ For example, in Rust 2015 ` panic!("problem: {reason}") ` panics with a
75+ payload of literally ` "problem: {reason}" ` (a ` &'static str ` ), which
76+ is probably not what was intended. In current Rust this usage
77+ captures and formats a variable ` reason ` from the surrounding scope.
78+
79+ In Rust editions prior to 2021, ` core::panic!(x) ` requires that
80+ ` x ` be ` &str ` , but does not require it to be a literal. In Rust 2021,
81+ these cases must be written ` panic!("{}", x) ` .
82+
83+ In Rust 2021 and later, ` panic! ` always requires a format string and
84+ the applicable format arguments, and is the same in ` core ` and ` std ` .
85+
6786# Examples
6887
6988``` should_panic
You can’t perform that action at this time.
0 commit comments