fix: Make `--color always` always print color with `--explain`
Fixesrust-lang/rust#151643.
This changes the behaviour of `handle_explain` in `rustc_driver_impl` to always output color when the `--color always` flag is set.
r? @tgross35
compiletest: Don't assume `aux-crate` becomes a `*.so` with `no-prefer-dynamic`
Since it does not make sense to do so. If someone prefers no dynamic stuff, the last thing they want to look for is an .so file. Also add a regression test. Without the fix, the test fails with:
error: test compilation failed although it shouldn't!
--- stderr -------------------------------
error: extern location for no_prefer_dynamic_lib does not exist: .../auxiliary/libno_prefer_dynamic_lib.so
--> .../no-prefer-dynamic-means-no-so.rs:9:5
|
LL | no_prefer_dynamic_lib::return_42();
| ^^^^^^^^^^^^^^^^^^^^^
### Needed by:
- https://github.com/rust-lang/rust/pull/150591 because of https://github.com/rust-lang/rust/issues/151271. But IMHO this PR makes sense on its own.
### Must wait for:
- [x] https://github.com/rust-lang/rust/pull/151695
Since it does not make sense to do so. If someone prefers no dynamic
stuff, the last thing they want to look for is an `.so` file. Also add a
regression test. Without the fix, the test fails with:
error: test compilation failed although it shouldn't!
--- stderr -------------------------------
error: extern location for no_prefer_dynamic_lib does not exist: .../auxiliary/libno_prefer_dynamic_lib.so
--> .../no-prefer-dynamic-means-no-so.rs:9:5
|
LL | no_prefer_dynamic_lib::return_42();
| ^^^^^^^^^^^^^^^^^^^^^
Fix missing unused_variables lint when using a match guard
Within a binding pattern match guard, only real reads of a bound local impact its liveness analysis - not the fake read that is injected.
Fixesrust-lang/rust#151983
r? compiler
Add codegen test for SLP vectorization
close: rust-lang/rust#142519
This PR adds a codegen regression test for rust-lang/rust#142519. A regression in LLVM to fail to auto-vectorize, leading to significant performance loss.
The SLP vectorizer correctly groups the 4-byte operations into <4 x i8> vectors.
The loop state is maintained in SIMD registers (phi <4 x i8>).
The test remains robust across architectures (AArch64 vs x86_64) by allowing flexible store types (i32 or <4 x i8>).
Move bigint helper tracking issues
Closesrust-lang/rust#85532.
This splits the remainder of the `bigint_helper_methods` tracking issue into three issues:
* `signed_bigint_helpers`: rust-lang/rust#151989
* `widening_mul`: rust-lang/rust#152016
* `const_unsigned_bigint_helpers`: rust-lang/rust#152015
Note that the existing stable methods were merged under the `unsigned_bigint_helpers` feature as part of rust-lang/rust#144494.
Codegen tests for Arm Cortex-R82
This PR adds checks to the `aarch64v8r-unknown-none` target to verify that if the Cortex-R82 CPU is enabled (with `-Ctarget-cpu=cortex-r82`), that the appropriate additional AArch64 features are enabled.
This is important because Cortex-R82 is (currently) the only processor implementing Armv8-R AArch64 and it implements a number of Armv8 features over and above the baseline for the architecture. Many of these features are of interest to safety-critical firmware development (for example `FEAT_RASv1p1`, which adds support for the *RAS Common Fault Injection Model Extension*) and so we anticipate them being enabled when building such firmware.
We are offering these tests upstream in-lieu of a full Cortex-R82 specific target because we understand the Project has a preference for architecture-baseline targets over CPU-specific targets.
~~This PR builds on and requires https://github.com/rust-lang/rust/pull/150863, but we've pulled them out as a separate PR.~~ That PR has been merged.
## Ownership
This PR was developed by Ferrous Systems on behalf of Arm. Arm is the owner of these changes.
compiletest: Support `--extern` modifiers with `proc-macro` directive
So that the `src/tools/compiletest/src/directives/auxiliary/tests.rs` test does not have to (ab)use the `aux-crate` directive for this purpose.
This is very edge-casey so I don't think we should document this in rustc-dev-guide. Mentioning it will confuse more than it helps. If someone needs to do this they will look at the code and easily find the functionality.
This is a bit hacky since `--extern priv:pm.rs` is not valid, but we can make our directives work however we want. And I think this is a fine pragmatic approach. Doing it "the right way" would be a lot of work for not much gain. Plus, that work can be done incrementally in small steps in the future if wanted.
r? @Zalathar
---
Follow-up to:
- https://github.com/rust-lang/rust/pull/151353
- https://github.com/rust-lang/rust/pull/151670
### Unblocks:
- https://github.com/rust-lang/rust/pull/151691, because without this fix that test fails (see https://github.com/rust-lang/rust/pull/151691#issuecomment-3800315302)
Include assoc const projections in CFI trait object
Fixesrust-lang/rust#151878
After https://github.com/rust-lang/rust/pull/150843, projections of trait objects should include assoc consts, but the cfi `trait_object_ty` still include only assoc types. So that we got the ICE `expected 1 projection but got 0`.
Add regression test for issue #138225
Adds a regression test for rust-lang#138225.
The compiler used to ICE with `ReferencesError` when compiling code with:
- An undefined type in a struct field
- An async function returning a static reference to that struct
- Optimizations enabled (`-C opt-level=1` or higher)
The bug has been fixed and now correctly reports `E0425: cannot find type`.
Test file: `tests/ui/async-await/ice-static-in-async-fn-issue-138225.rs`
Closesrust-lang/rust#138225
Feature-gate `mut ref` patterns in struct pattern field shorthand
Tracking issue for `mut_ref` (and other parts of Match Ergonomics 2024): https://github.com/rust-lang/rust/issues/123076https://github.com/rust-lang/rust/pull/123080 introduced `mut ref`[^1] patterns (for by-reference bindings where the binding itself is mutable), feature-gated behind the `mut_ref` feature, except for in struct pattern shorthand, where the feature gating was missing. Thus, `mut ref` patterns in struct pattern shorthand has been unintentionally stable for ~18 months (since 1.79.0 ([compiler explorer](https://rust.godbolt.org/z/4WTrvhboT))).
This PR adds feature-gating for `mut ref` patterns in struct pattern shorthand. Since this is reverting an accidental stabilization, this probably needs a crater run and a T-lang FCP?
Some alternative possibilities:
* Do nothing (let the inconsistency exist until `feature(mut_ref)` is stabilized)
* Document the existing behavior
* Do a FCW instead of fully feature-gating
* Stabilize `feature(mut_ref)`
CC https://github.com/rust-lang/rust/pull/123080#issuecomment-3746793632
CC @Nadrieril
[^1]: everything in this description also applies analogously to `mut ref mut` patterns.
GVN: Elide more intermediate transmutes
We already skipped intermediate steps like `u32` or `i32` that support any (initialized) value.
This extends that to also allow skipping intermediate steps whose values are a superset of either the source or destination type. Most importantly, that means that `usize` → `NonZeroUsize` → `ptr::Alignment` and `ptr::Alignment` → `NonZeroUsize` → `usize` can skip the middle because `NonZeroUsize` is a superset of `Alignment`.
Then `Alignment::as_usize` is updated to take advantage of that and let us remove some more locals in a few places.
r? cjgillot
Fix ICE when parsing frontmatter without newline
Fixesrust-lang/rust#151882
we can not add a normal test case for it:
- no newline at the end of file, we can bypass this with change test file name with `ignore-tidy`
- multiple errors in stderr, this conflicts with the previous bypass, seems we can not add multiple error annotations in one line
anyway, I added a `run-make` test for it.