Support non-defining uses in HIR typeck
This changes the impl of `NormalizesTo` for opaque types to be structural during HIR typeck. The previous impl equated region variables of the opaque type key with existing entries which can result in spurious leak check errors and also results in mismatches with MIR borrowck, theoretically causing ICE.
The approach is very similar to rust-lang/rust#145244 in MIR typeck:
- we collect all uses of opaque types during HIR typeck
- before writeback, we search for *defining uses*
- the opaque type key has fully universal generic args modulo regions
- the hidden type has no infer vars
- we use these defining uses to compute the concrete type for the opaque and map it to the definition site
- we use this concrete type to check the type of all uses of opaques during HIR typeck. This also constrains infer vars in non-defining uses
Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/135, fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/49.
r? `@BoxyUwU`
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`