Skip query machinery when promoting disk-cached values
At the end of an incremental session, exec_cache_promotions walks the green nodes and, for queries that were never used this session, loads their value from the previous session's disk cache into memory so it gets written into the new cache. This load currently goes through the full query execution path and shows up in profiles of incremental builds with few or no changes, which is the motivation for this PR.
Instead, this PR only loads the value directly and puts it in the in-memory cache. Perf improvement: -1.3% mean instructions, mostly in incr-unchanged, -0.36% in incr-patched, no regressions, see https://github.com/rust-lang/rust/pull/158059#issuecomment-4827621427.
Behavior change: A missing disk value is now a bug instead of a silent recompute.
compiletest: do not talk about JSON when the user never sees any
The user is not reading or writing any JSON here so it's quite confusing to talk about the "JSON output". JSON is just how rustc emits the errors so compiletest can parse them, but that's an implementation detail that we should not leak.
r? @petrochenkov
Update thinvec to 0.2.19
It contains `may_dangle` Drop impl under a feature flag. This allows us to use it in a lot more places, notable in types that hold `&'tcx` references. This would previously fail in borrowck in arena code.
We have to enable its "unstable" feature for this. That also enables `TrustedLen` impl, which is behind unstable flag, too. I left the flag disabled, because it regressed next-solver benchmarks, but that will be fixed in PR that needs this flag (see the comment: https://github.com/rust-lang/rust/pull/159974#issuecomment-5091132427)
fix: defer const normalize in coherence mode
I'm not confident that this fix is the best and desired in the long term point of view, but I'm confident that this does not do anything unsound.
Fixesrust-lang/rust#157937, by deferring normalization of associated const, except for anon, in coherence mode.
This fix prevents reporting impls, including associated const, are not overlapping.
On many bindings with move error, limit the number of `Span`s
When a "can't move out of" error would point at too many places, limit the number of spans so that we don't spam the terminal.
```
error[E0507]: cannot move out of `f` as enum variant `Foo1` which is behind a shared reference
--> $DIR/borrowck-move-error-many-places.rs:15:11
|
LL | match *f {
| ^^
LL | Foo::Foo1(num1,
| ---- data moved here
LL | num2) => (),
| ---- ...and here
LL | Foo::Foo2(num) => (),
| --- ...and here
LL | Foo::Foo3(num) => (),
| --- ...and here
LL | Foo::Foo4(num) => (),
| --- ...and here
|
= note: ...and 4 other places
= note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the dereference here
|
LL - match *f {
LL + match f {
|
```
Enforce that we don't generate code for comptime fns
... by ICEing if you try to compute a symbol for them. There are various other ways we can assert it, but they were all a bit icky or already unreachable.
r? @fmease (since you asked about it in https://github.com/rust-lang/rust/pull/159727#discussion_r3636421134)
applying `/Brepro` in bootstrap on MSVC and adding a run-make test.
as per the discussion, this PR applies `/Brepro` only for bootstrap when building `rustc` on `MSVC`, rather than enabling it for all Rust binaries.
it also adds a `run-make` test that compiles a small `PE executable`, parses its `IMAGE_DEBUG_DIRECTORY` using the `object` crate, and verifies that `TimeDateStamp` values remain identical across repeated `/Brepro` builds.
r?@Urgau
Rollup of 14 pull requests
Successful merges:
- rust-lang/rust#158417 (Avoid ICE when cfg_eval recovers no item from derive input)
- rust-lang/rust#159085 (Fix decoding attributes of `SyntheticCoroutineBody`)
- rust-lang/rust#159554 (feat: Update method signature of int_from_ascii)
- rust-lang/rust#159637 (Some place analysis tweaks)
- rust-lang/rust#159649 (Normalize region obligations before regionck)
- rust-lang/rust#159961 (sanitize_standard_fds: Miri supports poll now)
- rust-lang/rust#159967 (rustc_target: callconv: mips64: Return structs with single f128 in FPRs)
- rust-lang/rust#159253 (Add suggestions for using `#[export_name]` instead of `#[link_name]` on static)
- rust-lang/rust#159804 (Expand docs for fs::metadata and fs::symlink_metadata)
- rust-lang/rust#159821 (Update expect message using the recommended style in binary_heap module)
- rust-lang/rust#159840 (Fix opaque type ICE in late lints under the next-generation trait solver)
- rust-lang/rust#159956 (Fix observable intermediate state in `thread::add_spawn_hook`)
- rust-lang/rust#159991 (std: make send_process_group_signal unsupported on VxWorks)
- rust-lang/rust#159996 (Detect when a macro without exclamation mark uses square brackets)
Detect when a macro without exclamation mark uses square brackets
```
error: expected one of `.`, `?`, `]`, or an operator, found `,`
--> $DIR/do-not-suggest-semicolon-between-macro-without-exclamation-mark-and-array.rs:2:19
|
LL | let _x = vec[1, 2, 3];
| ^ expected one of `.`, `?`, `]`, or an operator
|
help: you might have meant to call a macro
|
LL | let _x = vec![1, 2, 3];
| +
```
Fixrust-lang/rust#101490.
std: make send_process_group_signal unsupported on VxWorks
`x86_64-wrs-vxworks` doesn't build std: `cargo new` plus `-Zbuild-std` stops
with E0425 on `libc::killpg`, which rust-lang/rust#156539 introduced.
libc has never declared `killpg` for vxworks, and declaring it wouldn't help.
On wrsdk-vxworks7-qemu-1.17.0 there's no `killpg` in the headers, the sysroot
archives or the prebuilt kernel, and `getpgrp`/`setpgid` are no-ops in libunix:
`getpgrp` returns a constant 0, `setpgid` stores nothing. That rules out
`kill(-pgrp, sig)` too. `Command::process_group` is already ignored on this
target, since `get_pgroup` is only read by the fork/posix_spawn path while
vxworks spawns through `rtpSpawn`.
Closesrust-lang/rust#159969.
Fix observable intermediate state in `thread::add_spawn_hook`
Fixesrust-lang/rust#159923.
Ensures the intermediate state of there being no hooks in `add_spawn_hooks` is not observable by allocating the new head node before taking the current hook list.
Also added a note to the docs of `add_spawn_hook` that hooks are not guaranteed to run and cannot be relied upon for soundness, as there are multiple ways to prevent all/some hooks from running.
Fix opaque type ICE in late lints under the next-generation trait solver
fixesrust-lang/rust-clippy#17411
Under the next trait solver, late lints trigger an ICE due to having non-empty opaque storage when dropping `InferCtxt`.
Rather than forcing all current and future late lints to manually use `ignoring_regions`, use `PostBorrowck` in `LateContext`.
cc @adwinwhite
Expand docs for fs::metadata and fs::symlink_metadata
Several changes:
## Link `symlink_metadata` from `metadata`
Someone reading `metadata` likely wants easy/quick access to `symlink_metadata` as well. Since this explicitly documents that it does follow symlinks, it made sense to leave a note stating how to perform the same action without that behavior.
## Add symbolic link note to errors
It's intuitive that you cannot return the `Metadata` of a resolved file if the file could not be resolved. But it's not always obvious. Since we're stating "the path does not exist" (also an obvious case). It will help to have this gentle reminder.
## Explicit behavior of directories and files in `symlink_metadata`
Reading the documentation, it was unclear whether `symlink_metadata` would also work on files and directories. I guessed it would, but it's nice to call it out. The wording also gave me an opportunity to cross-link to `metadata` so someone can easily jump back and forth between them.
Add suggestions for using `#[export_name]` instead of `#[link_name]` on static
Fixesrust-lang/rust#159247.
This adds a suggestion for using `#[unsafe(export_name = "...")]` when `#[link_name = "..."]` is applied to a static.
It also handles the existing `#[unsafe(link_name = "...")]` form by replacing only the attribute name.
Tested with:
- `./x test tests/ui/attributes/link-name-on-static.rs`
- `./x test tests/ui/attributes/unsafe-link-name-on-static.rs`
rustc_target: callconv: mips64: Return structs with single f128 in FPRs
The MIPS n64 ABI returns structs that meet the following requirements:
- Up to 128 bits large
- Only one or two fields, all of which are floating point
- Offset of the first field is zero
in floating point registers. This was already accounted for, but the edge case of a struct with a single `f128` field was not handled correctly and would always be returned in integer registers.
If we tell the backend to use a `f128` register here, LLVM will return the value in two of the 64-bit FPRs, `$f0` and `$f2`. That is equivalent to how Clang, GCC and also Rustc today would return a `long double` / `f128`.
However, both Clang and GCC return a struct with a single long double field in `$f0` and `$f1`. In order to achieve the same result in Rustc, we need to set the `InReg` attribute on the return value.
With this, we now match Clang and GCC.
Clang: https://godbolt.org/z/za8qv9P4n
GCC: https://godbolt.org/z/9qcdGsce6
Rustc currently: https://godbolt.org/z/8sP5G4ash
LLVM IR comparisons: https://godbolt.org/z/ojaTTY9hW
---
I'm not sure if it is acceptable to use `Reg::f128` since MIPS has no 128-bit floating point registers unless MSA is present. LLVM lowers it correctly to use two FPRs, not sure if this would cause issues with GCC.
`f16` probably also needs some changes here, but I'll do that as a follow-up.
---
r? @folkertdev
and Folkert also told me to cc @tgross35 :)
sanitize_standard_fds: Miri supports poll now
However, so far it doesn't support it on the standard FDs (0..=2). So let's support those in poll and then remove a Miri special case in std.
Normalize region obligations before regionck
We now normalize `TypeOutlives` predicates when evaluating them in the next solver.
So we don't need to normalize in regionck anymore.
r? @ShoyuVanilla
cc @lcnr
feat: Update method signature of int_from_ascii
* Tracking issue: rust-lang/rust#134821
Following [discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/327149-t-libs-api.2Fapi-changes/topic/How.20to.20proceed.20with.20int_from_ascii/with/611508226) it appears the preference is to change the API for this feature as follows:
```rust
// core::num
impl X {
pub const fn from_ascii_bytes<T>(src: T) -> Result<X, ParseIntError>
where
T: [const] AsRef<[u8]> + [const] core::marker::Destruct;
pub const fn from_ascii_bytes_radix<T>(src: T, radix: u32) -> Result<X, ParseIntError>
where
T: [const] AsRef<[u8]> + [const] core::marker::Destruct;
}
```
and similarly for `NonZero<X>`.
Reasons behind the change:
* Future-proof the naming convention for future string-like types
* Support the upcoming `ByteStr`/`ByteString` types: rust-lang/rust#134915
This pull request applies this change. The const-ness of these functions is now feature gated behind rust-lang/rust#143773
Fix decoding attributes of `SyntheticCoroutineBody`
Fixes https://github.com/rust-lang/rust/issues/156905 by returning an empty list of attributes for `SyntheticCoroutineBody` when its attributes are decoded
Avoid ICE when cfg_eval recovers no item from derive input
Fixesrust-lang/rust#148891
`cfg_eval` reparses derive input when it contains `#[cfg]` or `#[cfg_attr]` so it can capture cfg positions in the token stream. That reparse can emit syntax errors and return `Ok(None)` when parser recovery cannot reconstruct an item.
This pr changes the reparse path to return `Option<Annotatable>` and fall back to the original annotatable when recovery produces no node.
Fix `bool` calling convention for aarch64, etc.
We have been making a broad assumption about the way `bool` should be handled that *may* be correct for Rust calling Rust but is wildly incorrect for cross-language FFI calls. The ABI of `bool` is generally poorly-specified in any C psABI, and often deliberately allows for deviation after the first 8 bits.
This has surfaced as a bug that can corrupt Rust programs on aarch64, but it is a potential latent bug when it comes to every ABI. The simplest solution is to simply stop applying the special case when generating `bool`'s ArgAttributes. This yields control to the later ABI implementations, which may then sign or zero extend the `bool` (or not) according to their needs.
When a "can't move out of" error would point at too many places, limit the number of spans so that we don't span the terminal.
```
error[E0507]: cannot move out of `f` as enum variant `Foo1` which is behind a shared reference
--> $DIR/borrowck-move-error-many-places.rs:15:11
|
LL | match *f {
| ^^
LL | Foo::Foo1(num1,
| ---- data moved here
LL | num2) => (),
| ---- ...and here
LL | Foo::Foo2(num) => (),
| --- ...and here
LL | Foo::Foo3(num) => (),
| --- ...and here
LL | Foo::Foo4(num) => (),
| --- ...and here
|
= note: ...and 4 other places
= note: move occurs because these variables have types that don't implement the `Copy` trait
help: consider removing the dereference here
|
LL - match *f {
LL + match f {
|
```
VxWorks has no process groups: the SDK defines no `killpg`, and
`getpgrp`/`setpgid` are no-ops in libunix, so `kill(-pgrp, sig)` is no
substitute either. libc cannot usefully declare `killpg` for this
target, so calling it leaves the target unable to build std. Panic
instead, matching what fuchsia does for the same method.
```
error: expected one of `.`, `?`, `]`, or an operator, found `,`
--> $DIR/do-not-suggest-semicolon-between-macro-without-exclamation-mark-and-array.rs:2:19
|
LL | let _x = vec[1, 2, 3];
| ^ expected one of `.`, `?`, `]`, or an operator
|
help: you might have meant to call a macro
|
LL | let _x = vec![1, 2, 3];
| +
```