This internal crate explicitly separates itself from the `rustc`
workspace, but it is needed for `./x test clippy` to work, including its
dependencies when building from a vendored `rustc-src` tarball.
Enforce in bootstrap that dist and install must have stage at least 1
This is a continuation of my efforts to fix staging in bootstrap after the stage0 redesign. This PR gets rid of all `compiler_for` usages in the `dist` steps 🎉 The only remaining usages are in the `test` steps, which are my next goal, and which will be the final boss.. both because they are quite tricky, and because most of the the rest of the steps have been already fixed.
The changes are relatively straightforward, `x dist` defaults to stage 2, so in that case we want to use a stage 1 build compiler for everything (except stdlib, but we usually use it even there because of uplifting).
What I didn't fix yet are the docs steps, because they are *very* implicit right now, and fixing them deserves its own PR.
The first commit reverts the tests that I accidentally removed in https://github.com/rust-lang/rust/pull/145340🤦♂️ I did it in this PR to avoid further git conflicts..
Best reviewed commit-by-commit.
r? `@jieyouxu`
try-job: dist-i686-linux
try-job: dist-armhf-linux
try-job: dist-x86_64-linux
try-job: dist-x86_64-msvc
try-job: dist-apple-various
try-job: dist-x86_64-apple
try-job: x86_64-msvc-2
Update `bitflags` to 2.9.3.
The `bitflags!` macro in the latest release has slightly streamlined codegen. See https://github.com/bitflags/bitflags/pull/458 for details.
r? `@yaahc`
cg_llvm: Replace the `llvm::Bool` typedef with a proper newtype
This should be nicer and more type-safe than the old typedef for `c_int`/`i32`.
Using `#[repr(transparent)]` should ensure that it's still ABI-compatible.
Account for impossible bounds making seemingly unsatisfyable dyn-to-dyn casts
Fixes https://github.com/rust-lang/rust/issues/141806
When we have an impossible where clause like `dyn Trait<u8>: Sized`, this may make a dyn-to-dyn cast like `dyn Trait<()> -> dyn trait<u8>` to successfully type check as if it were a wide-to-thin ptr cast (discarding metadata):
16ad385579/compiler/rustc_hir_typeck/src/cast.rs (L862-L865)
In borrowck, we are expecting that the only meaningful dyn-to-dyn cast to be a metadata-preserving wide-to-wide ptr cast, which requires that the principals of the dyn pointers are equal. Borrowck additionally assumes that these principals have already been proven equal *modulo regions*, and we thus ICE since `Trait<u8>` and `Trait<()>` do not unify:
16ad385579/compiler/rustc_borrowck/src/type_check/mod.rs (L1481-L1524)
This PR fixes this ICE by checking whether the RHS of the cast is considered to be Sized in the environment of the MIR typeck, and if so then skipping over this dyn->dyn principal compatibility check.
r? `@lcnr` perhaps?
Dial down detail of B-tree description
fixes#134088, though it is a shame to lose some of this wonderful detail.
r? `@workingjubilee`
EDIT: newest versions keep old detail, but move it down a bit.
Remove chunk size from each chunk in `ChunkedBitSet`.
Almost all chunks in a `ChunkedBitSet` have the same constant `CHUNK_SIZE`, except the last in a bitset which takes the remainder `domain_size % CHUNK_SIZE`.
r? `@ghost` for perf
Make sure to treat only param where clauses as inherent
See the description in the test file.
This PR fixes a bug introduced by rust-lang/rust#141333, where we considered non-`Param` where clauses to be "inherent" for the purpose of method probing, which leads to both changes in method ambiguity (see test) and also import usage linting (and thus fixes https://github.com/rust-lang/rust/issues/145185).
r? `@lcnr`
Use unnamed lifetime spans as primary spans for `MISMATCHED_LIFETIME_SYNTAXES`
Fixes https://github.com/rust-lang/rust/issues/145772
This PR changes the primary span(s) of the `MISMATCHED_LIFETIME_SYNTAXES` to point to the *unnamed* lifetime spans in both the inputs and *outputs* of the function signature. As reported in rust-lang/rust#145772, this should make it so that IDEs highlight the spans of the actionable part of this lint, rather than just the (possibly named) input spans like they do today.
This could be tweaked further perhaps, for example for `fn foo(_: T<'_>) -> T`, we don't need to highlight the elided lifetime if the actionable part is to change only the return type to `T<'_>`, but I think it's improvement on what's here today, so I think that should be follow-up since I think the logic might get a bit hairy.
cc ```@shepmaster```
Add lint against integer to pointer transmutes
# `integer_to_ptr_transmutes`
*warn-by-default*
The `integer_to_ptr_transmutes` lint detects integer to pointer transmutes where the resulting pointers are undefined behavior to dereference.
### Example
```rust
fn foo(a: usize) -> *const u8 {
unsafe {
std::mem::transmute::<usize, *const u8>(a)
}
}
```
```
warning: transmuting an integer to a pointer creates a pointer without provenance
--> a.rs:1:9
|
158 | std::mem::transmute::<usize, *const u8>(a)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this is dangerous because dereferencing the resulting pointer is undefined behavior
= note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance
= help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut`
= help: for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers>
= help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance>
= note: `#[warn(integer_to_ptr_transmutes)]` on by default
help: use `std::ptr::with_exposed_provenance` instead to use a previously exposed provenance
|
158 - std::mem::transmute::<usize, *const u8>(a)
158 + std::ptr::with_exposed_provenance::<u8>(a)
|
```
### Explanation
Any attempt to use the resulting pointers are undefined behavior as the resulting pointers won't have any provenance.
Alternatively, `std::ptr::with_exposed_provenance` should be used, as they do not carry the provenance requirement or if the wanting to create pointers without provenance `std::ptr::without_provenance_mut` should be used.
See [std::mem::transmute] in the reference for more details.
[std::mem::transmute]: https://doc.rust-lang.org/std/mem/fn.transmute.html
--------
People are getting tripped up on this, see https://github.com/rust-lang/rust/issues/128409 and https://github.com/rust-lang/rust/issues/141220. There are >90 cases like these on [GitHub search](https://github.com/search?q=lang%3Arust+%2Ftransmute%3A%3A%3Cu%5B0-9%5D*.*%2C+%5C*const%2F&type=code).
Fixes https://github.com/rust-lang/rust-clippy/issues/13140
Fixes https://github.com/rust-lang/rust/issues/141220
Fixes https://github.com/rust-lang/rust/issues/145523
`@rustbot` labels +I-lang-nominated +T-lang
cc `@traviscross`
r? compiler