compiler: Fix a couple issues around cargo feature unification
cc https://github.com/rust-lang/rust/issues/148266. this doesn't fix all the issues (`rustc_public` and `rustc_transmute` still emit warnings when tested individually), but it fixes all the simple ones.
To fix rustc_public I will probably need help from ````@AlexanderPortland```` or ````@makai410```` to make sure I am not accidentally cfg-ing out items that are meant to be public. To fix `rustc_transmute`, I will need to know (from ````@jswrenn```` ?) in what context the `rustc` cargo feature is disapled. To reproduce the issues, you can run `x test rustc_{transmute,public}` locally.
---
The first issue I fixed was a warning in `rustc_index`:
```
Testing stage2 {rustc_parse_format} (aarch64-apple-darwin)
Compiling rustc_index v0.0.0 (/Users/ci/project/compiler/rustc_index)
error: extern crate `smallvec` is unused in crate `rustc_index`
--> compiler/rustc_index/src/lib.rs:2:1
|
2 | #![cfg_attr(all(feature = "nightly", test), feature(stmt_expr_attributes))]
| ^
|
= help: remove the dependency or add `use smallvec as _;` to the crate root
= note: `-D unused-crate-dependencies` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(unused_crate_dependencies)]`
error: could not compile `rustc_index` (lib) due to 1 previous error
```
The second was that `type_ir_macros` didn't fully specify its dependencies:
```
Testing stage1 {rustc_type_ir_macros} (aarch64-apple-darwin)
Compiling rustc_type_ir_macros v0.0.0 (/Users/jyn/src/ferrocene3/compiler/rustc_type_ir_macros)
error[E0432]: unresolved import `syn::visit_mut`
--> compiler/rustc_type_ir_macros/src/lib.rs:2:10
|
2 | use syn::visit_mut::VisitMut;
| ^^^^^^^^^ could not find `visit_mut` in `syn`
|
note: found an item that was configured out
--> /Users/jyn/.local/lib/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/syn-2.0.106/src/lib.rs:880:21
|
878 | #[cfg(feature = "visit-mut")]
| --------------------- the item is gated behind the `visit-mut` feature
879 | #[cfg_attr(docsrs, doc(cfg(feature = "visit-mut")))]
880 | pub use crate::gen::visit_mut;
| ^^^^^^^^^
error[E0433]: failed to resolve: could not find `visit_mut` in `syn`
--> compiler/rustc_type_ir_macros/src/lib.rs:206:18
|
206 | syn::visit_mut::visit_type_path_mut(self, i);
| ^^^^^^^^^ could not find `visit_mut` in `syn`
|
note: found an item that was configured out
--> /Users/jyn/.local/lib/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/syn-2.0.106/src/lib.rs:880:21
|
878 | #[cfg(feature = "visit-mut")]
| --------------------- the item is gated behind the `visit-mut` feature
879 | #[cfg_attr(docsrs, doc(cfg(feature = "visit-mut")))]
880 | pub use crate::gen::visit_mut;
| ^^^^^^^^^
```
The first was a warning:
```
Testing stage2 {rustc_parse_format} (aarch64-apple-darwin)
Compiling rustc_index v0.0.0 (/Users/ci/project/compiler/rustc_index)
error: extern crate `smallvec` is unused in crate `rustc_index`
--> compiler/rustc_index/src/lib.rs:2:1
|
2 | #![cfg_attr(all(feature = "nightly", test), feature(stmt_expr_attributes))]
| ^
|
= help: remove the dependency or add `use smallvec as _;` to the crate root
= note: `-D unused-crate-dependencies` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(unused_crate_dependencies)]`
error: could not compile `rustc_index` (lib) due to 1 previous error
```
The second was that `type_ir_macros` didn't fully specify its
dependencies:
```
Testing stage1 {rustc_type_ir_macros} (aarch64-apple-darwin)
Compiling rustc_type_ir_macros v0.0.0 (/Users/jyn/src/ferrocene3/compiler/rustc_type_ir_macros)
error[E0432]: unresolved import `syn::visit_mut`
--> compiler/rustc_type_ir_macros/src/lib.rs:2:10
|
2 | use syn::visit_mut::VisitMut;
| ^^^^^^^^^ could not find `visit_mut` in `syn`
|
note: found an item that was configured out
--> /Users/jyn/.local/lib/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/syn-2.0.106/src/lib.rs:880:21
|
878 | #[cfg(feature = "visit-mut")]
| --------------------- the item is gated behind the `visit-mut` feature
879 | #[cfg_attr(docsrs, doc(cfg(feature = "visit-mut")))]
880 | pub use crate::gen::visit_mut;
| ^^^^^^^^^
error[E0433]: failed to resolve: could not find `visit_mut` in `syn`
--> compiler/rustc_type_ir_macros/src/lib.rs:206:18
|
206 | syn::visit_mut::visit_type_path_mut(self, i);
| ^^^^^^^^^ could not find `visit_mut` in `syn`
|
note: found an item that was configured out
--> /Users/jyn/.local/lib/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/syn-2.0.106/src/lib.rs:880:21
|
878 | #[cfg(feature = "visit-mut")]
| --------------------- the item is gated behind the `visit-mut` feature
879 | #[cfg_attr(docsrs, doc(cfg(feature = "visit-mut")))]
880 | pub use crate::gen::visit_mut;
| ^^^^^^^^^
```
Use `bit_set::Word` in a couple more places.
It's a synonym for `u64` and there are a couple of places where we use `u64` where we should use `Word`, which this commit fixes.
I found this when I tried changing `Word` to `u128` (which made performance worse).
r? `````@Zalathar`````
It's a synonym for `u64` and there are a couple of places where we use
`u64` where we should use `Word`, which this commit fixes.
I found this when I tried changing `Word` to `u128` (which made
performance worse).
Stabilize `new_zeroed_alloc`
The corresponding `new_uninit` and `new_uninit_slice` functions were stabilized in rust-lang/rust#129401, but the zeroed counterparts were left for later out of a [desire](https://github.com/rust-lang/rust/issues/63291#issuecomment-2161039756) to stabilize only the minimal set. These functions are straightforward mirrors of the uninit functions and well-established. Since no blockers or design questions have surfaced in the past year, I think it's time to stabilize them.
Tracking issue: rust-lang/rust#129396
Allow bounds checks when enumerating `IndexSlice` to be elided
Without this hint, each loop iteration has to separately bounds check the index. See https://godbolt.org/z/zrfPY4Ten for an example.
This is technically a behaviour change, but only in cases where the compiler is going to crash anyways.
Revert <https://github.com/rust-lang/rust/pull/138084> to buy time to
consider options that avoids breaking downstream usages of cargo on
distributed `rustc-src` artifacts, where such cargo invocations fail due
to inability to inherit `lints` from workspace root manifest's
`workspace.lints` (this is only valid for the source rust-lang/rust
workspace, but not really the distributed `rustc-src` artifacts).
This breakage was reported in
<https://github.com/rust-lang/rust/issues/138304>.
This reverts commit 48caf81484b50dca5a5cebb614899a3df81ca898, reversing
changes made to c6662879b27f5161e95f39395e3c9513a7b97028.
By naming them in `[workspace.lints.rust]` in the top-level
`Cargo.toml`, and then making all `compiler/` crates inherit them with
`[lints] workspace = true`. (I omitted `rustc_codegen_{cranelift,gcc}`,
because they're a bit different.)
The advantages of this over the current approach:
- It uses a standard Cargo feature, rather than special handling in
bootstrap. So, easier to understand, and less likely to get
accidentally broken in the future.
- It works for proc macro crates.
It's a shame it doesn't work for rustc-specific lints, as the comments
explain.
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the
prelude instead of importing or qualifying them.
These functions were added to all preludes in Rust 1.80.
Allow `IndexSlice` to be indexed by ranges.
This comes with some annoyances as the index type can no longer inferred from indexing expressions. The biggest offender for this is `IndexVec::from_fn_n(|idx| ..., n)` where the index type won't be inferred from the call site or any index expressions inside the closure.
My main use case for this is mapping a `Place` to `Range<Idx>` for value tracking where the range represents all the values the place contains.