@@ -14,6 +14,7 @@ However, it has [some subtle surprises](https://github.com/rust-lang/rfcs/blob/m
1414that we can't just change due to backwards compatibility.
1515
1616``` rust,ignore
17+ // Rust 2018
1718panic!("{}", 1); // Ok, panics with the message "1"
1819panic!("{}"); // Ok, panics with the message "{}"
1920```
@@ -22,6 +23,7 @@ The `panic!()` macro only uses string formatting when it's invoked with more tha
2223When invoked with a single argument, it doesn't even look at that argument.
2324
2425``` rust,ignore
26+ // Rust 2018
2527let a = "{";
2628println!(a); // Error: First argument must be a format string literal
2729panic!(a); // Ok: The panic macro doesn't care
@@ -43,6 +45,13 @@ Since `panic!()` will no longer accept arbitrary payloads,
4345[ ` panic_any() ` ] ( https://doc.rust-lang.org/stable/std/panic/fn.panic_any.html )
4446will be the only way to panic with something other than a formatted string.
4547
48+ ``` rust,ignore
49+ // Rust 2021
50+ panic!("{}", 1); // Ok, panics with the message "1"
51+ panic!("{}"); // Error, missing argument
52+ panic!(a); // Error, must be a string literal
53+ ```
54+
4655In addition, ` core::panic!() ` and ` std::panic!() ` will be identical in Rust 2021.
4756Currently, there are some historical differences between those two,
4857which can be noticable when switching ` #![no_std] ` on or off.
0 commit comments