Commit graph

257129 commits

Author SHA1 Message Date
Zalathar 2fa78f3a2a coverage: Replace the old span refiner with a single function
As more and more of the span refiner's functionality has been pulled out into
separate early passes, it has finally reached the point where we can remove the
rest of the old `SpansRefiner` code, and replace it with a single
modestly-sized function.
2024-06-12 22:59:24 +10:00
Zalathar 0bfdb8d33d coverage: Add tests/coverage/loop-break.rs
This is a modified copy of `tests/mir-opt/coverage/instrument_coverage.rs`.
2024-06-12 22:48:11 +10:00
Zalathar dc6def3042 coverage: Add tests/coverage/assert-ne.rs
This test extracts a fragment of `issue-84561.rs` that has historically proven
troublesome when trying to modify how spans are extracted from MIR.
2024-06-12 22:38:16 +10:00
bors 02c7a5921e Auto merge of #113169 - oli-obk:tait_must_be_constrained_if_in_sig, r=lcnr
Tait must be constrained if in sig

r? `@compiler-errors`

kind of reverts https://github.com/rust-lang/rust/pull/62423, but that PR only removed cycles in cases that we want to forbid now anyway.

see https://rust-lang.zulipchat.com/#narrow/stream/315482-t-compiler.2Fetc.2Fopaque-types/topic/lcnr.20oli.20meeting/near/370712246 for related discussion and motivating example

a TAIT showing up in a signature doesn't just mean it can register a hidden type, but that it must.

This is the [design the types team decided upon](https://hackmd.io/QOsEaEJtQK-XDS_xN4UyQA#Proposal-preferred) for the following reasons

* avoids a hypothetical situation where getting smarter in trait solving could cause new cycle errors or new inference errors to show up, where today something is treated as opaque.
* avoids having the situation where a (minor?) change to a function body causes an error, because its TAIT usage suddenly isn't "opaque enough" anymore.
* avoids having to explain why in some cases you need to put a Tait into a tiny module together with its defining usages. Now you basically gotta always do this, the moment a Tait is in a signature that isn't in the defining scope.
* avoids false-cycle errors
* anything diverging from this pattern needs to either
    * move the TAIT declaration and defining function into their own helper sub module
    * use the attributes we'll provide in the future to explicitly opt in or out of being in the defining scope

fixes #117861

reverts #125362 cc `@Nilstrieb` `@joboet`
2024-06-12 09:00:37 +00:00
Oli Scherer 85f2ecab57 Add a fn main() {} to a doctest to prevent the test from being wrapped in a fn main() {} body 2024-06-12 08:53:59 +00:00
Oli Scherer 0bc2001879 Require any function with a tait in its signature to actually constrain a hidden type 2024-06-12 08:53:59 +00:00
Oli Scherer 39e7bf6826 Revert "Rollup merge of #125362 - joboet:tait_hack, r=Nilstrieb"
This reverts commit 1e4bde1cb9, reversing
changes made to 4ee97fc3db.
2024-06-12 08:47:49 +00:00
bors bdb1b7f5d9 Auto merge of #126290 - weihanglo:update-cargo, r=weihanglo
Update cargo

14 commits in b1feb75d062444e2cee8b3d2aaa95309d65e9ccd..4dcbca118ab7f9ffac4728004c983754bc6a04ff
2024-06-07 20:16:17 +0000 to 2024-06-11 16:27:02 +0000
- Add local registry overlays (rust-lang/cargo#13926)
- docs(change): Don't mention non-existent workspace.badges (rust-lang/cargo#14042)
- test: migrate binary_name to snapbox (rust-lang/cargo#14041)
- Bump to 0.82.0; update changelog (rust-lang/cargo#14040)
- tests: Migrate alt_registry to snapbox (rust-lang/cargo#14031)
- fix: proc-macro example from dep no longer affects feature resolution (rust-lang/cargo#13892)
- chore: Bump cargo-util-schemas to 0.5 (rust-lang/cargo#14038)
- chore(deps): update rust crate pulldown-cmark to 0.11.0 (rust-lang/cargo#14037)
- fix: remove `__CARGO_GITOXIDE_DISABLE_LIST_FILES` env var (rust-lang/cargo#14036)
- chore(deps): update rust crate itertools to 0.13.0 (rust-lang/cargo#13998)
- fix(toml): remove `lib.plugin` key support and make it warning (rust-lang/cargo#13902)
- chore(deps): update compatible (rust-lang/cargo#13995)
- fix: using `--release/debug` and `--profile` together becomes an error (rust-lang/cargo#13971)
- fix(toml): Convert warnings that `licence` and `readme` files do not exist into errors (rust-lang/cargo#13921)

r? ghost
2024-06-12 06:51:07 +00:00
bors 76c73827dc Auto merge of #126130 - compiler-errors:goal-relations, r=lcnr
Make `ObligationEmittingRelation`s emit `Goal` rather than `Obligation`

Helps avoid needing to uplift `Obligation` into the solver. We still can't get rid of `ObligationCause`, but we can keep it as an associated type for `InferCtxtLike` and just give it a `dummy` function.

There's some shuttling between `Goal` and `Obligation` that may be perf-sensitive... Let's see what rust-timer says.

r? lcnr
2024-06-12 03:35:31 +00:00
Weihang Lo 3203d169d3
Update cargo 2024-06-11 20:48:52 -04:00
bors 9a7bf4ae94 Auto merge of #123508 - WaffleLapkin:never-type-2024, r=compiler-errors
Edition 2024: Make `!` fall back to `!`

This PR changes never type fallback to be `!` (the never type itself) in the next, 2024, edition.

This makes the never type's behavior more intuitive (in 2024 edition) and is the first step of the path to stabilize it.

r? `@compiler-errors`
2024-06-12 00:28:22 +00:00
bors ebcb862bbb Auto merge of #126284 - jieyouxu:rollup-nq7bf9k, r=jieyouxu
Rollup of 6 pull requests

Successful merges:

 - #115974 (Split core's PanicInfo and std's PanicInfo)
 - #125659 (Remove usage of `isize` in example)
 - #125669 (CI: Update riscv64gc-linux job to Ubuntu 22.04, rename to riscv64gc-gnu)
 - #125684 (Account for existing bindings when suggesting `pin!()`)
 - #126055 (Expand list of trait implementers in E0277 when calling rustc with --verbose)
 - #126174 (Migrate `tests/run-make/prefer-dylib` to `rmake.rs`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-11 22:20:35 +00:00
许杰友 Jieyou Xu (Joe) e37c423f10
Rollup merge of #126174 - GuillaumeGomez:migrate-run-make-prefer-dylib, r=jieyouxu
Migrate `tests/run-make/prefer-dylib` to `rmake.rs`

Part of https://github.com/rust-lang/rust/issues/121876.

r? ```@jieyouxu```
2024-06-11 21:27:47 +01:00
许杰友 Jieyou Xu (Joe) 12358a7363
Rollup merge of #126055 - lengrongfu:master, r=pnkfelix
Expand list of trait implementers in E0277 when calling rustc with --verbose

Fixes: https://github.com/rust-lang/rust/issues/125984

- Build `rustc` use `./x build`.
- Test result
<img width="634" alt="image" src="https://github.com/rust-lang/rust/assets/15009201/89377059-2316-492b-a38a-fa33adfc9793">

- vim test.rs
```rust
trait Reconcile {
    fn reconcile(&self);
}

// Implementing the trait for some types
impl Reconcile for bool {
    fn reconcile(&self) {
        println!("Reconciling bool");
    }
}

impl Reconcile for i8 {
    fn reconcile(&self) {
        println!("Reconciling i8");
    }
}

impl Reconcile for i16 {
    fn reconcile(&self) {
        println!("Reconciling i16");
    }
}

impl Reconcile for i32 {
    fn reconcile(&self) {
        println!("Reconciling i32");
    }
}

impl Reconcile for i64 {
    fn reconcile(&self) {
        println!("Reconciling i64");
    }
}

impl Reconcile for u8 {
    fn reconcile(&self) {
        println!("Reconciling u8");
    }
}

impl Reconcile for u16 {
    fn reconcile(&self) {
        println!("Reconciling u16");
    }
}

impl Reconcile for u32 {
    fn reconcile(&self) {
        println!("Reconciling u32");
    }
}

impl Reconcile for i128 {
    fn reconcile(&self) {
        println!("Reconciling u32");
    }
}

impl Reconcile for u128 {
    fn reconcile(&self) {
        println!("Reconciling u32");
    }
}

fn process<T: Reconcile>(item: T) {
    item.reconcile();
}

fn main() {
    let value = String::from("This will cause an error");
    process(value); // This line will cause a compilation error
}
```
2024-06-11 21:27:47 +01:00
许杰友 Jieyou Xu (Joe) 260f789ae1
Rollup merge of #125684 - estebank:pin-to-binding-suggestion, r=pnkfelix
Account for existing bindings when suggesting `pin!()`

When we encounter a situation where we'd suggest `pin!()`, we now account for that expression existing as part of an assignment and provide an appropriate suggestion:

```
error[E0599]: no method named `poll` found for type parameter `F` in the current scope
  --> $DIR/pin-needed-to-poll-3.rs:19:28
   |
LL | impl<F> Future for FutureWrapper<F>
   |      - method `poll` not found for this type parameter
...
LL |         let res = self.fut.poll(cx);
   |                            ^^^^ method not found in `F`
   |
help: consider pinning the expression
   |
LL ~         let mut pinned = std::pin::pin!(self.fut);
LL ~         let res = pinned.as_mut().poll(cx);
   |
```

Fix #125661.
2024-06-11 21:27:46 +01:00
许杰友 Jieyou Xu (Joe) 91374faffb
Rollup merge of #125669 - ferrocene:hoverbear/ci-docker-riscv64gc-update, r=Kobzol
CI: Update riscv64gc-linux job to Ubuntu 22.04, rename to riscv64gc-gnu

Together with joshua.zivkovic@codethink.co.uk, we've been starting to explore improving the state of the `riscv64gc-unknown-linux-gnu` target. Additionally, I'm looking to add support for this platform in [Ferrocene](https://github.com/ferrocene/ferrocene) ([Related PR](https://github.com/ferrocene/ferrocene/pull/618)).

There currently exists a `src/ci/docker/host-x86_64/disabled/riscv64gc-linux` job for the CI, however it is currently experiencing errors.

<details>

<summary>Errors</summary>

```bash
$ DEPLOY=1 ./src/ci/docker/run.sh riscv64gc-linux
# ...
[RUSTC-TIMING] addr2line test:false 0.371
[RUSTC-TIMING] gimli test:false 3.159
[RUSTC-TIMING] object test:false 4.249
error: linking with `riscv64-linux-gnu-gcc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/bin:/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/bin:/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" VSLANG="1033" "riscv64-linux-gnu-gcc" "-Wl,--version-script=/tmp/rustcQaIpWi/list" "-Wl,--no-undefined-version" "/tmp/rustcQaIpWi/symbols.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/std-ff89a9732cd5d858.std.1b5d59225ff40bd2-cgu.0.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/std-ff89a9732cd5d858.dalhl7sfna1ffn4nhy6pyfa7f.rcgu.rmeta" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/std-ff89a9732cd5d858.ef0znsdf1ihn2bjkmclodhclp.rcgu.o" "-Wl,--as-needed" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/release/deps" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/build/compiler_builtins-9e9a40064e2f2bd3/out" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/riscv64gc-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/libpanic_unwind-d968371aba64a26c.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/libobject-da5b6473912e89d6.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/libmemchr-9cfa08d2baa3643e.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/libaddr2line-06e0d2153cecb6ce.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/libgimli-6fdf5551cec83840.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/librustc_demangle-8ada6466f763fa2e.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/libstd_detect-edc0d12d029c4c86.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/libhashbrown-9c782935934c8c14.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/librustc_std_workspace_alloc-b6984e43b381efa4.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/libminiz_oxide-37ee29bf49ccaa96.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/libadler-591133f6804fa0f4.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/libunwind-94d98075f42175f3.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/libcfg_if-e267a7b9dd7af3a7.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/liblibc-503571a038f8d9fd.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/liballoc-e36c72a5cf0ee45f.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/librustc_std_workspace_core-076c2b8501e25f03.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/libcore-c446fff80486d0bb.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/libcompiler_builtins-26dc6b5e31e1fdb9.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/riscv64gc-unknown-linux-gnu/lib" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/libstd-ff89a9732cd5d858.so" "-shared" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs" "-Wl,-z,origin" "-Wl,-rpath,$ORIGIN/../lib"
# ...
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: failed to merge target specific data of file /checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/libcompiler_builtins-26dc6b5e31e1fdb9.rlib(compiler_builtins-26dc6b5e31e1fdb9.compiler_builtins.74504a151a6bdbbf-cgu.124.rcgu.o)
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: -march=rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0: unsupported ISA subset `z'
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: failed to merge target specific data of file /checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/riscv64gc-unknown-linux-gnu/release/deps/libcompiler_builtins-26dc6b5e31e1fdb9.rlib(compiler_builtins-26dc6b5e31e1fdb9.compiler_builtins.74504a151a6bdbbf-cgu.004.rcgu.o)
          collect2: error: ld returned 1 exit status

[RUSTC-TIMING] std test:false 15.138
error: could not compile `std` (lib) due to 1 previous error
Building bootstrap
Build completed unsuccessfully in 0:04:41
  local time: Tue May 28 16:25:09 UTC 2024
  network time: Tue, 28 May 2024 16:25:17 GMT
```

</details>

This PR fixes the breakage enough to get the tests running. It does so through bringing the `riscv64gc-unknown-linux-gnu` related test job in line with other related jobs, adopting many of the recent changes present in `src/ci/docker/host-x86_64/armhf-gnu` such as:

* Using Ubuntu 22.04
* Installing a more narrowly scoped package set
* Using `curl` instead of `debootstrap` to set up the root
* No longer patching `busybox`
* Removing the `cmake.sh` script related steps

## Justifying Renaming `riscv64gc-linux` to `riscv64gc-gnu`

The `src/ci/docker/host-x86_64/disabled/riscv64gc-linux` job runs the tests for `risv64gc-unknown-linux-gnu`, it is based off `src/ci/docker/host-x86_64/armhf-gnu`.

There are other jobs that follow a `$arch-gnu` naming scheme:

* `src/ci/docker/host-x86_64/armhf-gnu`
* `src/ci/docker/host-x86_64/x86_64-gnu`
* `src/ci/docker/host-aarch64/aarch64-gnu`

It follows that the name `src/ci/docker/host-x86_64/disabled/riscv64gc-linux` should be `src/ci/docker/host-x86_64/disabled/riscv64gc-gnu`, like the others.

## Testing

> [!NOTE]
> `riscv64gc-unknown-linux-gnu` is a [**Tier 2 with Host Tools** platform](https://doc.rust-lang.org/beta/rustc/platform-support.html), all tests may not necessarily pass! There is work in https://github.com/rust-lang/rust/pull/125220 which helps fix several related tests.

You can test out the renamed job:

```sh
DEPLOY=1 ./src/ci/docker/run.sh riscv64gc-gnu
```

`DEPLOY=1` helps reproduce the CI's environment and also avoids the chance of a `llvm-c/BitReader.h` error (detailed in https://github.com/rust-lang/rust/issues/85424 and https://github.com/rust-lang/rust/issues/56650).

<details>

<summary>Sample of output (expected test failure)</summary>

```bash
$ DEPLOY=1 ./src/ci/docker/run.sh riscv64gc-gnu
# ...
test [ui] tests/ui/where-clauses/where-clause-method-substituion-rpass.rs ... ok

failures:

---- [ui] tests/ui/debuginfo/debuginfo-emit-llvm-ir-and-split-debuginfo.rs stdout ----

error: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/debuginfo/debuginfo-emit-llvm-ir-and-split-debuginfo.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=riscv64gc-unknown-linux-gnu" "--check-cfg" "cfg(FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/debuginfo/debuginfo-emit-llvm-ir-and-split-debuginfo" "-A" "unused" "-A" "internal_features" "-Crpath" "-Lnative=/checkout/obj/build/riscv64gc-unknown-linux-gnu/native/rust-test-helpers" "-Clinker=riscv64-linux-gnu-gcc" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/debuginfo/debuginfo-emit-llvm-ir-and-split-debuginfo/auxiliary" "-g" "--emit=llvm-ir" "-Csplit-debuginfo=unpacked"
stdout: none
--- stderr -------------------------------
error: `-Csplit-debuginfo=unpacked` is unstable on this platform

error: aborting due to 1 previous error
------------------------------------------

failures:
    [ui] tests/ui/debuginfo/debuginfo-emit-llvm-ir-and-split-debuginfo.rs

test result: FAILED. 5 passed; 1 failed; 16897 ignored; 0 measured; 0 filtered out; finished in 410.99ms

Some tests failed in compiletest suite=ui mode=ui host=x86_64-unknown-linux-gnu target=riscv64gc-unknown-linux-gnu
  local time: Tue May 28 16:28:22 UTC 2024
  network time: Tue, 28 May 2024 16:28:30 GMT
```

</details>

try-job: riscv64gc-gnu
2024-06-11 21:27:46 +01:00
许杰友 Jieyou Xu (Joe) ecc0046fb6
Rollup merge of #125659 - tbu-:pr_rm_isize, r=pnkfelix
Remove usage of `isize` in example

`isize` is a rare integer type, replace it with a more common one.
2024-06-11 21:27:45 +01:00
许杰友 Jieyou Xu (Joe) d9deb38ec0
Rollup merge of #115974 - m-ou-se:panicinfo-and-panicinfo, r=Amanieu
Split core's PanicInfo and std's PanicInfo

`PanicInfo` is used in two ways:

1. As argument to the `#[panic_handler]` in `no_std` context.
2. As argument to the [panic hook](https://doc.rust-lang.org/stable/std/panic/fn.set_hook.html) in `std` context.

In situation 1, the `PanicInfo` always has a *message* (of type `fmt::Arguments`), but never a *payload* (of type `&dyn Any`).

In situation 2, the `PanicInfo` always has a *payload* (which is often a `String`), but not always a *message*.

Having these as the same type is annoying. It means we can't add `.message()` to the first one without also finding a way to properly support it on the second one. (Which is what https://github.com/rust-lang/rust/issues/66745 is blocked on.)

It also means that, because the implementation is in `core`, the implementation cannot make use of the `String` type (which doesn't exist in `core`): 0692db1a90/library/core/src/panic/panic_info.rs (L171-L172)

This also means that we cannot easily add a useful method like `PanicInfo::payload_as_str() -> Option<&str>` that works for both `&'static str` and `String` payloads.

I don't see any good reasons for these to be the same type, other than historical reasons.

---

This PR is makes 1 and 2 separate types. To try to avoid breaking existing code and reduce churn, the first one is still named `core::panic::PanicInfo`, and `std::panic::PanicInfo` is a new (deprecated) alias to `PanicHookInfo`. The crater run showed this as a viable option, since people write `core::` when defining a `#[panic_handler]` (because they're in `no_std`) and `std::` when writing a panic hook (since then they're definitely using `std`). On top of that, many definitions of a panic hook don't specify a type at all: they are written as a closure with an inferred argument type.

(Based on some thoughts I was having here: https://github.com/rust-lang/rust/pull/115561#issuecomment-1725830032)

---

For the release notes:

> We have renamed `std::panic::PanicInfo` to `std::panic::PanicHookInfo`. The old name will continue to work as an alias, but will result in a deprecation warning starting in Rust 1.82.0.
>
> `core::panic::PanicInfo` will remain unchanged, however, as this is now a *different type*.
>
> The reason is that these types have different roles: `std::panic::PanicHookInfo` is the argument to the [panic hook](https://doc.rust-lang.org/stable/std/panic/fn.set_hook.html) in std context (where panics can have an arbitrary payload), while `core::panic::PanicInfo` is the argument to the [`#[panic_handler]`](https://doc.rust-lang.org/nomicon/panic-handler.html) in no_std context (where panics always carry a formatted *message*). Separating these types allows us to add more useful methods to these types, such as `std::panic::PanicHookInfo::payload_as_str()` and `core::panic::PanicInfo::message()`.
2024-06-11 21:27:45 +01:00
bors d0227c6a19 Auto merge of #125174 - nnethercote:less-ast-pretty-printing, r=petrochenkov
Print `token::Interpolated` with token stream pretty printing.

This is a step towards removing `token::Interpolated` (#124141). It unavoidably changes the output of the `stringify!` macro, generally for the better.

r? `@petrochenkov`
2024-06-11 20:11:21 +00:00
Michael Goulet e4be97cfe7 Try not to make obligations in handle_opaque_type 2024-06-11 14:10:11 -04:00
Michael Goulet 4efb13b0c2 Rename some things 2024-06-11 13:52:51 -04:00
Michael Goulet 44a6f72a72 Make ObligationEmittingRelation deal with Goals only 2024-06-11 13:52:51 -04:00
Michael Goulet 4038010436 Get rid of PredicateObligations 2024-06-11 13:52:51 -04:00
bors 3ea5e236ec Auto merge of #125736 - Oneirical:run-make-file-management, r=jieyouxu
run-make-support: add wrapper for `fs` operations

Suggested by #125728.

The point of this wrapper is to stop silent fails caused by forgetting to `unwrap` `fs` functions. However, functions like `fs::read` which return something and get stored in a variable should cause a failure on their own if they are not unwrapped (as the `Result` will be stored in the variable, and something will be done on that `Result` that should have been done to its contents). Is it still pertinent to wrap `fs::read_to_string`, `fs::metadata` and so on?

Closes: https://github.com/rust-lang/rust/issues/125728

try-job: x86_64-msvc
try-job: i686-mingw
2024-06-11 15:50:25 +00:00
Oneirical c84afee898 Implement fs wrapper for run_make_support 2024-06-11 09:53:31 -04:00
Mara Bos a6e23b126b Formatting. 2024-06-11 15:47:00 +02:00
Mara Bos a345c3daf6 Bump deprecation of std's PanicInfo alias to 1.82.0. 2024-06-11 15:47:00 +02:00
Mara Bos de07c1a928 Add PanicHookInfo::payload_as_str(). 2024-06-11 15:47:00 +02:00
Mara Bos fb0990d1e1 Fix display of panic message in recursive panic. 2024-06-11 15:47:00 +02:00
Mara Bos 877a26f6c9 Mention core's PanicInfo in error.md. 2024-06-11 15:47:00 +02:00
Mara Bos 32bfe703e2 Add note on panic payload type. 2024-06-11 15:47:00 +02:00
Mara Bos ce0bc8bd58 Downcast panic payload to String too in example. 2024-06-11 15:47:00 +02:00
Mara Bos f5fe82fdca Move deprecation of std::panic::PanicInfo to 1.80.0. 2024-06-11 15:47:00 +02:00
Mara Bos 3854357ad2 Fix deprecation version. 2024-06-11 15:47:00 +02:00
Mara Bos 64e56db72a Rename std::panic::PanicInfo to PanicHookInfo. 2024-06-11 15:47:00 +02:00
Mara Bos b6180a9185 Formatting. 2024-06-11 15:47:00 +02:00
Mara Bos 6b2d7c4707 Fix invalid markdown/html. 2024-06-11 15:47:00 +02:00
Mara Bos bab26b02c7 Reorder body of begin_panic for consistency.
In the other functions, we put the struct and impl blocks first,
such that the return expression can be at the end of the body as usual.
2024-06-11 15:46:59 +02:00
Mara Bos 1642de33d3 Impl Display for PanicPayload to simplify things. 2024-06-11 15:46:59 +02:00
Mara Bos 22f7399b32 Use unnamed lifetimes for [..]Payload impl blocks. 2024-06-11 15:46:59 +02:00
Mara Bos 4e356f3184 Move downcasting panic payload to str to a function. 2024-06-11 15:46:59 +02:00
Mara Bos 0087d89983 Mark some PanicInfo methods as #[inline] for consistency. 2024-06-11 15:46:59 +02:00
Mara Bos 0642cb2994 Remove std::panic::PanicInfo::internal_constructor+set_payload.
We can just set the payload immediately in the constructor,
and the constructor does not need to be public.
2024-06-11 15:46:59 +02:00
Mara Bos 0266bbf6e4 Remove core::panic::PanicInfo::internal_constructor.
It no longer needs to be public.
2024-06-11 15:46:59 +02:00
Mara Bos 83dd214f06 Update doc comment about core::panicking. 2024-06-11 15:46:59 +02:00
Mara Bos 331b8a3edd Fix doc link. 2024-06-11 15:46:59 +02:00
Mara Bos 16dfc6ddc1 Add core::panic::PanicInfo::payload() for compatibility. 2024-06-11 15:46:59 +02:00
Mara Bos a519dc85f8 Document difference between core and std's PanicInfo. 2024-06-11 15:46:59 +02:00
Mara Bos e3e815370e Split core's PanicInfo and std's PanicInfo. 2024-06-11 15:46:59 +02:00
bors 0c960618b5 Auto merge of #126274 - jieyouxu:rollup-uj93sfm, r=jieyouxu
Rollup of 5 pull requests

Successful merges:

 - #126186 (Migrate `run-make/multiple-emits` to `rmake.rs`)
 - #126236 (Delegation: fix ICE on recursive delegation)
 - #126254 (Remove ignore-cross-compile directive from ui/macros/proc_macro)
 - #126258 (Do not define opaque types when selecting impls)
 - #126265 (interpret: ensure we check bool/char for validity when they are used in a cast)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-11 13:38:45 +00:00