rust/src
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
..
bootstrap x.py test --test-args flag description enhancement 2020-10-23 20:06:37 +01:00
build_helper cleanup: Remove duplicate library names from Cargo.tomls 2020-08-30 22:57:54 +03:00
ci Rollup merge of #78309 2020-10-24 11:17:02 +02:00
doc Rollup merge of #78250 - camelid:document-inline-const, r=spastorino 2020-10-24 14:12:08 +02:00
etc BTreeMap: improve gdb introspection of BTreeMap with ZST keys or values 2020-10-14 13:03:23 +02:00
librustdoc Always store Rustdoc theme when it's changed 2020-10-23 18:58:42 +02:00
llvm-project@655a1467c9 Update LLVM for LLD COFF TLS alignment fix. 2020-10-17 01:34:08 -07:00
test Rollup merge of #78119 - fusion-engineering-forks:panic-use-as-str, r=Amanieu 2020-10-24 22:39:53 +02:00
tools Rollup merge of #78169 - ehuss:update-cargo, r=ehuss 2020-10-23 18:26:35 +09:00
README.md Update README.md 2020-08-30 13:40:11 -05:00
stage0.txt Rollup merge of #77877 - scottmcm:fewer-try-trait-method-references, r=shepmaster 2020-10-19 18:20:20 +02:00
version Bump version to 1.49.0 2020-10-02 08:39:40 -04:00

This directory contains the source code of the rust project, including:

  • The test suite
  • The bootstrapping build system
  • Various submodules for tools, like rustdoc, rls, etc.

For more information on how various parts of the compiler work, see the rustc dev guide.