rust/library
Jonas Schievink e3808edeee
Rollup merge of #78119 - fusion-engineering-forks:panic-use-as-str, r=Amanieu
Throw core::panic!("message") as &str instead of String.

This makes `core::panic!("message")` consistent with `std::panic!("message")`, which throws a `&str` and not a `String`.

This also makes any other panics from `core::panicking::panic` result in a `&str` rather than a `String`, which includes compiler-generated panics such as the panics generated for `mem::zeroed()`.

---

Demonstration:

```rust
use std::panic;
use std::any::Any;

fn main() {
    panic::set_hook(Box::new(|panic_info| check(panic_info.payload())));

    check(&*panic::catch_unwind(|| core::panic!("core")).unwrap_err());
    check(&*panic::catch_unwind(|| std::panic!("std")).unwrap_err());
}

fn check(msg: &(dyn Any + Send)) {
    if let Some(s) = msg.downcast_ref::<String>() {
        println!("Got a String: {:?}", s);
    } else if let Some(s) = msg.downcast_ref::<&str>() {
        println!("Got a &str: {:?}", s);
    }
}
```

Before:
```
Got a String: "core"
Got a String: "core"
Got a &str: "std"
Got a &str: "std"
```

After:
```
Got a &str: "core"
Got a &str: "core"
Got a &str: "std"
Got a &str: "std"
```
2020-10-24 22:39:53 +02:00
..
alloc Rollup merge of #77610 - hermitcore:dtors, r=m-ou-se 2020-10-24 22:39:44 +02:00
backtrace@a6dd47bd58 Bump backtrace-rs 2020-10-15 15:21:12 -04:00
core Rollup merge of #78069 - fusion-engineering-forks:core-const-panic-str, r=RalfJung 2020-10-24 22:39:49 +02:00
panic_abort
panic_unwind
proc_macro Bump to 1.48 bootstrap compiler 2020-10-07 19:51:36 -04:00
profiler_builtins
rtstartup
rustc-std-workspace-alloc
rustc-std-workspace-core
rustc-std-workspace-std
std Rollup merge of #78119 - fusion-engineering-forks:panic-use-as-str, r=Amanieu 2020-10-24 22:39:53 +02:00
stdarch@3c3664355e Update stdarch submodule 2020-10-01 13:06:22 -04:00
term
test Rollup merge of #77890 - gilescope:welformed-json-output-from-libtest, r=KodrAus 2020-10-23 18:26:20 +09:00
unwind Remove useless all in cfg 2020-10-09 13:24:05 +02:00