Add a proc-macro to derive HashStable in librustc dependencies
A second proc-macro is added to derive HashStable for crates librustc depends on.
This proc-macro HashStable_Generic (to bikeshed) allows to decouple code and some librustc's boilerplate.
Not everything is migrated, because `Span` and `TokenKind` require to be placed inside librustc.
Types using them stay there too.
Split out of #66279
r? @Zoxc
Move process_configure_mod to rustc_parse
This removes the hack in favor of perhaps a less principled, but less painful, approach.
This also supports my work to decouple `Session` from librustc, as `ParseSess` currently has `Attribute` as "part" of it but after this PR will no longer do so.
Delay an `is_local_ever_initialized` call.
This commit moves the call after a `return` that almost always runs. It
speeds up the `unicode_normalization` benchmark by about 2%.
r? @spastorino
Support multiple revisions in `compiletest`
The `//[X]~` syntax filters errors for tests that are run across multiple cfgs with `// revisions:`. This commit extends that syntax to accept `//[X,Y]~`, which will match multiple cfgs to the same error annotation. This is functionally the same as writing two comments, `//[X]~` and `//[Y]~`, but can fit on a single line.
While refactoring `compiletest` to support this, I also uncovered a small bug that was causing an incremental test to always pass, despite no errors being emitted.
r? @Centril
[mir-opt] asking `?`s in a more optimized fashion
This PR works towards https://github.com/rust-lang/rust/issues/66234 by providing two optimization passes meant to run in sequence:
- `SimplifyArmIdentity` which transforms something like:
```rust
_LOCAL_TMP = ((_LOCAL_1 as Variant ).FIELD: TY );
((_LOCAL_0 as Variant).FIELD: TY) = move _LOCAL_TMP;
discriminant(_LOCAL_0) = VAR_IDX;
```
into:
```rust
_LOCAL_0 = move _LOCAL_1
```
- `SimplifyBranchSame` which transforms `SwitchInt`s to identical basic blocks into a `goto` to the first reachable target.
Together, these are meant to simplify the following into just `res`:
```rust
match res {
Ok(x) => Ok(x),
Err(x) => Err(x),
}
```
It should be noted however that the desugaring of `?` includes a function call and so the first pass in this PR relies on inlining to substitute that function call for identity on `x`. Inlining requires `mir-opt-level=2` so this might not have any effect in perf-bot but let's find out.
r? @oli-obk -- This is WIP, but I'd appreciate feedback. :)
This test does not actually emit any warnings, since
`#![allow(warnings)]` was specified. `compiletest` was erroneously
ignoring `//~` tests and looking only for `//[X]~` ones. As a result of
the changes in the previous commit, we now look for `//~` comments in
incremental tests and expect them to appear in *all* revisions.
The `//[X]~` syntax filters errors for tests that are run across
multiple cfgs with `// revisions:`. This commit extends that syntax to
accept `//[X,Y]~`, which will match multiple cfgs to the same error
annotation. This is functionally the same as writing two comments,
`//[X]~` and `//[Y]~`, but can fit on a single line.
Aggregation of drive-by cosmetic changes for trait-upcasting PR
Cherry-picked from #60900.
As requested by @Centril (and @nikomatsakis, I believe).
r? @Centril
This optimization depends on inlining for the identity
conversions introduced by the lowering of the `?`.
To take advantage of `SimplifyArmIdentity`, `-Z mir-opt-level=2`
is required because that triggers the inlining MIR optimization.
Rollup of 5 pull requests
Successful merges:
- #65355 (Stabilize `!` in Rust 1.41.0)
- #65730 (Suggest to add lifetime constraint at explicit ouput of functions)
- #66468 (Cleanup Miri SIMD intrinsics)
- #66515 (Reduce size of `hir::Expr` by boxing more of `hir::InlineAsm`)
- #66602 (Revert "Update Source Code Pro and include italics")
Failed merges:
r? @ghost
Ignore run-make reproducible-build-2 on Mac
Ignore run-make reproducible-build-2 on Mac (we already ignore it on Windows).
Until we can dedicate resources to fixing this properly, I think we are best off just ignoring this test on platforms/contexts where it does not matter as much.
cc #66568
rustc_metadata: Privatize more things
Continuation of https://github.com/rust-lang/rust/pull/66056.
The most notable change here is that `CrateMetadata` is moved from `cstore.rs` to `decoder.rs`.
Most of uses of `CrateMetadata` fields are in the decoder and uses of `root: CrateRoot` and other fields are so intertwined with each other that it would be hard to move a part of them into `cstore.rs` to privatize `CrateMetadata` fields, so we are going the other way round.
`cstore.rs` can probably be dismantled now, but I'll leave this to some other day.
Similarly, remaining `CrateMetadata` fields can be privatized by introducing some getter/setter methods, but not today.
r? @eddyb
rustdoc: fixes#64305: disable search field instead of hidding it
The result seems to be ok but I wasn't entirely sure how to get there. I tried to stay generic a bit but maybe it's not required at all.
@GuillaumeGomez
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Making ICEs and test them in incremental
This adds:
- A way to make the compiler ICE
- A way to check for ICE in `cfail` tests with `should-ice`
- A regression test for issue #65401
I am not sure the attribute added `should-ice` is the best for this job
Until we can dedicate resources to fixing this properly, I think we are
best off just ignoring this test on platforms/contexts where it does not
matter as much.
[RISCV] Disable Atomics on all Non-A RISC-V targets
In a `TargetOptions` configuration, `max_atomic_width: None` causes `max_atomic_width()` to return `Some(target_pointer_width)`. So, contrary to assumptions, `max_atomic_width: None` means you do have atomic support!
RISC-V's rv32i and rv32imc do not have architectural support for atomic memory accesses of any size, because they do not include the `A` architecture extension. This means the values in the target definition should be `Some(0)`.
This bug has been observed via a build failure with oreboot/oreboot#191, where LLVM was still generating libcalls for atomic operations. According to rust-lang/compiler-builtins, "Rust only exposes atomic types on platforms that support them, and therefore does not need to fall back to software implementations." - so this PR tries to bring rustc inline with this decision.
This commit also removes the outdated bug link, which references a now irrelevant GCC bug.
I will likely also have to revisit the `min_atomic_width` of all the RISC-V targets so they are correct and match what the hardware is capable of (which is more restricted than one might imagine).
r? @alexcrichton
Generate DWARF address ranges for faster lookups
This adds a new option `-Zgenerate-arange-section`, enabled by default,
corresponding to LLVM's `-generate-arange-section`. This creates a
`.debug_aranges` section with DWARF address ranges, which some tools
depend on to optimize address lookups (elfutils [22288], [25173]).
This only has effect when debuginfo is enabled, and the additional data
is small compared to the other debug sections. For example, libstd.so
with full debuginfo is about 11MB, with just 61kB in aranges.
[22288]: https://sourceware.org/bugzilla/show_bug.cgi?id=22288
[25173]: https://sourceware.org/bugzilla/show_bug.cgi?id=25173Closes#45246.
r? @michaelwoerister
Fix#53820
This fixes ICE #53820 by being more clever when matching large arrays with slice patterns.
In particular, it avoids treating large arrays like large tuples, and instead reuses the `VarLenSlice` constructor behaviour to only consider as little values as needed.
As a side-effect, such matches also get improved diagnostics, by reporting `[true, ..]` missing instead of `[true, _, _, _, _, _, _, _]`.
rustc_plugin: Remove the compatibility shim
The compatibility crate was introduced in https://github.com/rust-lang/rust/pull/62727 to migrate Cargo and some other tools, but now it's no longer necessary.
Update Source Code Pro and include italics
Fixes#65502.
A few notes:
* As stated in #65502, this does increase the download size.
* Since this PR changes the font set, I think docs.rs would have to be updated if this PR is merged.
* The fonts have a double extension (.ttf.woff); this is to keep the names consistent with the upstream font release which does that to distinguish these from the .otf.woff files ([Source Code Pro otf renders poorly on older Windows system apps](https://github.com/adobe-fonts/source-code-pro/issues/25#issuecomment-9019600)).