Add support to intrinsics fallback body
Before this fix, the call to `body()` would crash, since `has_body()` would return true, but we would try to retrieve the body of an intrinsic which is not allowed.
Instead, the `Instance::body()` function will now convert an Intrinsic into an Item before retrieving its body.
Note: I also changed how we monomorphize the instance body. Unfortunately, the call still ICE for some shims.
r? `@oli-obk`
Add `REDUNDANT_LIFETIMES` lint to detect lifetimes which are semantically redundant
There already is a `UNUSED_LIFETIMES` lint which is fired when we detect where clause bounds like `where 'a: 'static`, however, it doesn't use the full power of lexical region resolution to detect failures.
Right now `UNUSED_LIFETIMES` is an `Allow` lint, though presumably we could bump it to warn? I can (somewhat) easily implement a structured suggestion so this can be rustfix'd automatically, since we can just walk through the HIR body, replacing instances of the redundant lifetime.
Fixes#118376
r? lcnr
Show mode_t as octal in std::fs Debug impls
Example:
```rust
fn main() {
println!("{:?}", std::fs::metadata("Cargo.toml").unwrap().permissions());
}
```
- Before: `Permissions(FilePermissions { mode: 33204 })`
- ~~After: `Permissions(FilePermissions { mode: 0o100664 })`~~
- After: `Permissions(FilePermissions { mode: 0o100664 (-rw-rw-r--) })`
~~I thought about using the format from `ls -l` (`-rw-rw-r--`, `drwxrwxr-x`) but I am not sure how transferable the meaning of the higher bits between different unix systems, and anyway starting the value with a leading negative-sign seems objectionable.~~
Rollup of 7 pull requests
Successful merges:
- #121884 (Port exit-code run-make test to use rust)
- #122200 (Unconditionally show update nightly hint on ICE)
- #123568 (Clean up tests/ui by removing `does-nothing.rs`)
- #123609 (Don't use bytepos offsets when computing semicolon span for removal)
- #123612 (Set target-abi module flag for RISC-V targets)
- #123633 (Store all args in the unsupported Command implementation)
- #123668 (async closure coroutine by move body MirPass refactoring)
Failed merges:
- #123701 (Only assert for child/parent projection compatibility AFTER checking that theyre coming from the same place)
r? `@ghost`
`@rustbot` modify labels: rollup
async closure coroutine by move body MirPass refactoring
Unsure about the last commit, but I think the other changes help in simplifying the control flow
Store all args in the unsupported Command implementation
This allows printing them in the Debug impl as well as getting them again using the get_args() method. This allows programs that would normally spawn another process to more easily show which program they would have spawned if not for the fact that the target doesn't support spawning child processes without requiring intrusive changes to keep the args. For example rustc compiled to wasi will show the full linker invocation that would have been done.
Don't use bytepos offsets when computing semicolon span for removal
Causes problems when we recover confusable characters w/ a different byte width
Fixes#123607
Clean up tests/ui by removing `does-nothing.rs`
In [a previous PR](https://github.com/rust-lang/rust/pull/123297#issuecomment-2039887806), it was suggested that this test be removed:
> it's testing a basic diagnostic for an unknown variable (added over a decade ago for https://github.com/rust-lang/rust/issues/154) that is already covered by probably dozens or hundreds of other tests.
It was then suggested that [opening a new PR](https://github.com/rust-lang/rust/pull/123563#discussion_r1554654102) for this would be more organized.
I'm setting this as a draft, as:
1. The tests/ui directory is rather disorganized, a large quantity of tests are not even contained inside their own directories. This PR could turn into "clean up the UI tests directory", if I were to place everything into categories (for example, everything related to CLI flags could get placed in a cli directory).
2. This will have a merge conflict with #123563 should that get merged. I trust that _this time_, I won't run into [The Incident](https://github.com/rust-lang/rust/pull/123297#issuecomment-2041137569) while rebasing. Edit: Yay, I did it properly!
Unconditionally show update nightly hint on ICE
Instead of trying to guess if a update nightly hint should be shown (by checking for system time, querying version and channel info etc.), just show the update nightly hint for nightly compilers. This avoids breaking tests that match on ICE test outputs on nightly/dev channels.
> Another issue is that the outdated nightly hint triggers for ICE tests, causing a mismatch with the test expectation. There doesn't seem to be any env var to suppress this.
See <https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/stage0.20compiletest.20broken/near/425543681> for context.
Port exit-code run-make test to use rust
As part of https://github.com/rust-lang/rust/issues/121876
~~As draft because formatting will fail because `x fmt` isn't working for me for some reason, I'll debug that later, just opening this now for review, will mark as ready when formatting is fixed~~ (misleading message from x fmt)
cc `@jieyouxu`
Rollup of 8 pull requests
Successful merges:
- #123254 (Do not allocate for ZST ThinBox (attempt 2 using const_allocate))
- #123626 (Add MC/DC support to coverage test tools)
- #123638 (rustdoc: synthetic auto: filter out clauses from the implementor's ParamEnv)
- #123653 (Split `non_local_definitions` lint tests in separate test files)
- #123658 (Stop making any assumption about the projections applied to the upvars in the `ByMoveBody` pass)
- #123662 (Don't rely on upvars being assigned just because coroutine-closure kind is assigned)
- #123665 (Fix typo in `Future::poll()` docs)
- #123672 (compiletest: unset `RUSTC_LOG_COLOR`)
r? `@ghost`
`@rustbot` modify labels: rollup
compiletest: unset `RUSTC_LOG_COLOR`
If this leaks in from the environment then it can make tests fail when they deliberately trigger `WARN` or `ERROR` logging, currently this stops these tests from failing if you set `RUSTC_LOG_COLOR=always` in the parent environment:
- `tests/ui/coherence/occurs-check/associated-type.rs#next`
- `tests/ui/coherence/occurs-check/associated-type.rs#old`
- `tests/ui/higher-ranked/structually-relate-aliases.rs`
- `tests/ui/self/arbitrary-self-from-method-substs.rs#default`
- `tests/ui/traits/next-solver/issue-118950-root-region.rs`
Don't rely on upvars being assigned just because coroutine-closure kind is assigned
Previously, code relied on the implicit assumption that if a coroutine-closure's kind variable was constrained, then its upvars were also constrained. This is because we assign all of them at once at the end up upvar analysis.
However, there's another way that a coroutine-closure's kind can be constrained: from a signature hint in closure signature deduction. After #123350, we use these hints, which means the implicit assumption above no longer holds.
This PR adds the necessary checks so that we don't ICE.
r? oli-obk
Stop making any assumption about the projections applied to the upvars in the `ByMoveBody` pass
So it turns out that because of subtle optimizations like [`truncate_capture_for_optimization`](ab5bda1aa7/compiler/rustc_hir_typeck/src/upvar.rs (L2351)), we simply cannot make any assumptions about the shape of the projections applied to the upvar locals in a coroutine body.
So stop doing that -- the code is resilient to such projections, so the assertion really existed only to "protect against the unknown".
r? oli-obk
Fixes#123650
Split `non_local_definitions` lint tests in separate test files
This PR splits the giant `non_local_definitions` lint UI test in separate test files.
This change is extracted from #123594 (where it was requested https://github.com/rust-lang/rust/pull/123594#discussion_r1555261772), to ease the review of the other PR and to reduce the size of the other PR.
r? ``@compiler-errors``
rustdoc: synthetic auto: filter out clauses from the implementor's ParamEnv
... not just the elaborated clauses.
Fixes another regression introduced by me in #123340, oops!
Fixes https://github.com/rust-lang/rust/pull/123340#issuecomment-2034195786, cc ``@tamird.``
An earlier local iteration of branch `rustdoc-simplify-auto-trait-impl-synth` (PR #123340) contained a fix for issue #111101 before I decided to limit the scope. I must've introduced this bug when manually reverting that part of the code.
r? ``@GuillaumeGomez`` or rustdoc
Add MC/DC support to coverage test tools
Extracted and squashed from #123409 by `@ZhuUx.`
These updates to the coverage test tools can land ahead of the main changes, slightly reducing the size and complexity of that PR.
---
The `coverage-dump` changes aren't directly tested in this PR, but the tests in #123409 demonstrate that they do work on real MC/DC coverage output.
`@rustbot` label +A-code-coverage
Do not allocate for ZST ThinBox (attempt 2 using const_allocate)
There's PR https://github.com/rust-lang/rust/pull/123184 which avoids allocation for ZST ThinBox.
That PR has an issue with unsoundness with padding in `MaybeUninit` (see comments in that PR). Also that PR relies on `Freeze` trait.
This PR is much simpler implementation which does not have this problem, but it uses `const_allocate` feature.
`@oli-obk` suggested that `const_allocate` should not be used for that feature. But I like how easy it to do this feature with `const_allocate`. Maybe it's OK to use `const_allocate` while `ThinBox` is unstable? Or, well, we can abandon this PR.
r? `@oli-obk`