Region inference: Use outlives-static constraints in constraint search
Revise the extra `r: 'static` constraints added upon universe issues to add an explanation, and use that explanation during constraint blame search. This greatly simplifies the region inference logic, which now does not need to reverse-engineer the event that caused a region to outlive `'static`.
This cosmetically changes the output of two UI tests. I blessed them i separate commits with separate motivations, but that can of course be squashed as desired. We probably want that.
The PR was extracted out of rust-lang/rust#130227 and consists of one-third of its functional payload.
r? lcnr
Rollup of 6 pull requests
Successful merges:
- rust-lang/rust#142215 (Use -Zmir-opt-level=0 in tests for MIR building)
- rust-lang/rust#143341 (Mention that casting to *const () is a way to roundtrip with from_raw_parts)
- rust-lang/rust#145078 (Fix wrong cache line size of riscv64)
- rust-lang/rust#145290 (Improve std::fs::read_dir docs)
- rust-lang/rust#145335 (Move WTF-8 code from std into core and alloc)
- rust-lang/rust#145904 (Move `riscv64-gc-unknown-linux-musl` from Tier 2 with Host tools to Tier 2)
r? `@ghost`
`@rustbot` modify labels: rollup
Move WTF-8 code from std into core and alloc
This is basically a small portion of rust-lang/rust#129411 with a smaller scope. It *does not*\* affect any public APIs; this code is still internal to the standard library. It just moves the WTF-8 code into `core` and `alloc` so it can be accessed by `no_std` crates like `backtrace`.
> \* The only public API this affects is by adding a `Debug` implementation to `std::os::windows::ffi::EncodeWide`, which was not present before. This is due to the fact that `core` requires `Debug` implementations for all types, but `std` does not (yet) require this. Even though this was ultimately changed to be a wrapper over the original type, not a re-export, I decided to keep the `Debug` implementation so it remains useful.
Like we do with ordinary strings, the tests are still located entirely in `alloc`, rather than splitting them into `core` and `alloc`.
----
Reviewer note: for ease of review, this is split into three commits:
1. Moving the original files into their new "locations"
2. Actually modifying the code to compile.
3. Removing aesthetic changes that were made so that the diff for commit 2 was readable.
You can review commits 1 and 3 to verify these claims, but commit 2 contains the majority of the changes you should care about.
----
API changes: `impl Debug for std::os::windows::ffi::EncodeWide`
Improve std::fs::read_dir docs
Call out early that the results returned can differ across calls / aren't deterministic. This was already mentioned at the bottom of examples, but I think it's worth calling out early, since this caused at least one person (me!) great confusion.
Use -Zmir-opt-level=0 in tests for MIR building
The mir-opt test suite currently defaults all tests in it to `-Zmir-opt-level=4`, so if a test is trying to test MIR _building_ not optimizations and it is in that directory, it _must_ override the default mir-opt-level.
Call out early that the results returned can differ across calls /
aren't deterministic. This was already mentioned at the bottom of
examples, but I think it's worth calling out early, since this caused at
least one person (me!) great confusion.
[ Added a comma to the docs, reflowed commit message - Trevor ]
Rollup of 9 pull requests
Successful merges:
- rust-lang/rust#144499 (ci: Begin running ui tests with `rust.debuginfo-level-tests=1`)
- rust-lang/rust#145790 (Improve dist for gnullvm hosts)
- rust-lang/rust#145792 (Use attribute name in message for "outer attr used as inner attr" errors)
- rust-lang/rust#145840 (rustc_codegen_ssa: More comprehensive RISC-V ELF flags)
- rust-lang/rust#145876 (Enable building/disting standard library in stage 0)
- rust-lang/rust#145887 (bootstrap: Don't panic if codegen-backends is set to empty)
- rust-lang/rust#145888 (platform-support: Fix LoongArch32 host column)
- rust-lang/rust#145892 (add a flag to codegen fn attrs for foreign items)
- rust-lang/rust#145901 (Fix typo in comment of library/alloc/src/raw_vec/mod.rs)
r? `@ghost`
`@rustbot` modify labels: rollup
Fix typo in comment of library/alloc/src/raw_vec/mod.rs
Turn "any heap allocators" into "any heap allocator".
Shoutout to [Let's Read OSS](https://github.com/stoeckmann/lets-read-oss).
Enable building/disting standard library in stage 0
After the stage0 redesign, building a stage0 library no longer is a thing, because the stage0 compiler normally cannot build libstd anymore. However, there are valid use-cases for having the ability to quickly cross-compile libstd for different targets, when the stage0 compiler is e.g. a stable released version, and you want to cross-compile libstd from the same sources of that compiler.
This PR allows that, as long as you set `build.local-rebuild = true`, which promises bootstrap that the stage0 compiler actually comes from in-tree sources, and can thus compile libstd.
The change needed to enable this is very minimal, so I think that it is worth it to allow this use-case to work.
Fixes: https://github.com/rust-lang/rust/issues/145587
Fixes: https://github.com/rust-lang/rust/issues/145859
Related issue: https://github.com/rust-lang/rust/issues/94781
r? `@jieyouxu`
rustc_codegen_ssa: More comprehensive RISC-V ELF flags
This change implements more conformant, more comprehensive RISC-V ELF flags handling when generating certain object files directly from rustc.
* Use `"zca"` instead of `"c"`
The "Zca" extension (a subset of "C") is the minimal configuration for compressed instructions to set `EF_RISCV_RVC` flag.
* Set TSO flag from `"ztso"`
The "Ztso" extension denotes that the program depends on the RVTSO (Total Store Ordering) memory consistency model, which is stronger than the standard RVWMO (Weak Memory Ordering) consistency model and on ELF targets, we need to set `EF_RISCV_TSO` flag.
Improve dist for gnullvm hosts
LLVM tools cross-compilation has been fixed by rust-lang/rust#145763 and LLVM downloading from CI no longer causes build error, so let's enable them both.
ci: Begin running ui tests with `rust.debuginfo-level-tests=1`
To reduce risk of regressing on generating debuginfo e.g. in the form of ICE:s. This will also ensure that future ui tests work with different debuginfo levels. See https://github.com/rust-lang/rust/issues/61117.
When I looked at run time for different CI jobs, **x86_64-gnu-debug** was far from the bottleneck, so it should be fine to make it perform more work.
A handful of tests are failing so we need to force debuginfo=0 on those for now.
We'll start small with debuginfo=1. We'll step up to debuginfo=2 once most (all?) tests can handle debuginfo=1. There are more failures with debuginfo=2 than with debuginfo=1.
cg_llvm: Assert that LLVM range-attribute values don't exceed 128 bits
The underlying implementation of `LLVMCreateConstantRangeAttribute` assumes that each of `LowerWords` and `UpperWords` points to enough u64 values to define an integer of the specified bit-length, and will encounter UB if that is not the case.
Our safe wrapper function always passes pointers to `[u64; 2]` arrays, regardless of the bit-length specified. That's fine in practice, because scalar primitives never exceed 128 bits, but it is technically a soundness hole in a safe function.
We can close the soundness hole by explicitly asserting `size_bits <= 128`. This is effectively just a stricter version of the existing check that the value must be small enough to fit in `c_uint`.
---
This is a narrower version of the fix in rust-lang/rust#145846.
formatting_options: Make all methods `const`
Related to rust-lang/rust#118117.
Having `const fn`s that take a `mut &` was unstable until Rust 1.83 (see rust-lang/rust#129195). Because of this, not all methods on `FormattingOptions` were implemented as `const`. As this has been stabilized now, there is no reason not to have all methods `const`.
Thanks to `@Ternvein` for bringing this to my attention (see [1]).
r? `@m-ou-se` (As you were the reviewer for the original implementation – feel free to reroll if you are busy or if you aren't interested)
[1]: https://github.com/rust-lang/rust/issues/118117#issuecomment-2687470635
bootstrap: vendor `clippy_test_deps` too
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.
Always build miri for the host in `x run miri`
Previously we were building Miri for the passed `--target`, which was wrong.
Fixes: https://github.com/rust-lang/rust/issues/145839
r? `@jieyouxu`
Losslessly optimize PNG files
Losslessly optimizes all of the PNG files in the repo. Done with:
```
oxipng -o max -a -s
oxipng -o max --zopfli -a -s
```