Expose `Utf8Lossy` as `Utf8Chunks`
This PR changes the feature for `Utf8Lossy` from `str_internals` to `utf8_lossy` and improves the API. This is done to eventually expose the API as stable.
Proposal: rust-lang/libs-team#54
Tracking Issue: #99543
Initial implementation of REUSE
This PR implements the first two steps of #99414 by:
* Adding some scaffolding for REUSE. The `.reuse/dep5` file now marks every file as the custom "TODO" license, which I'll remove in a future PR once Debian imports their metadata. The TODO license is needed so that `reuse lint` works.
* Runs `reuse lint` in CI, in the `mingw-check` builder. REUSE currently has a bug when parsing some files in the LLVM source code. This means REUSE will fail when running it in source tarballs of rustc, and that bug prevents us from passing the `--include-submodules` flag in CI. I opened https://github.com/fsfe/reuse-tool/pull/560 upstream with a fix, and as soon as it's merged/released I planned to bump the pinned version to include the fix we need.
r? `@Mark-Simulacrum`
See comment added for details on the test builder restriction. This is primarily
intended for macOS CI, but is likely to be a slight win on other builders too.
Rollup of 10 pull requests
Successful merges:
- #100186 (Mention `as_mut` alongside `as_ref` in borrowck error message)
- #100383 (Mitigate stale data reads on SGX platform)
- #100507 (suggest `once_cell::Lazy` for non-const statics)
- #100617 (Suggest the right help message for as_ref)
- #100667 (Migrate "invalid variable declaration" errors to SessionDiagnostic)
- #100709 (Migrate typeck's `used` expected symbol diagnostic to `SessionDiagnostic`)
- #100723 (Add the diagnostic translation lints to crates that don't emit them)
- #100729 (Avoid zeroing a 1kb stack buffer on every call to `std::sys::windows::fill_utf16_buf`)
- #100750 (improved diagnostic for function defined with `def`, `fun`, `func`, or `function` instead of `fn`)
- #100763 (triagebot: Autolabel `A-rustdoc-json`)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Avoid zeroing a 1kb stack buffer on every call to `std::sys::windows::fill_utf16_buf`
I've also tried to be slightly more careful about integer overflows, although in practice this is likely still not handled ideally.
r? `@ChrisDenton`
Add the diagnostic translation lints to crates that don't emit them
Some of these have a note saying that they should build on a stable compiler, does that mean they shouldn't get these lints? Or can we cfg them out on those?
Migrate "invalid variable declaration" errors to SessionDiagnostic
After seeing the great blog post on Inside Rust, I decided to try my hand at this. Just one diagnostic for now to get used to the workflow and to check if this is the way to do it or if there are any problems.
suggest `once_cell::Lazy` for non-const statics
Addresses https://github.com/rust-lang/rust/issues/100410
Some questions:
- removing the `if` seems to include too many cases (e.g. calls to non-const functions inside a `const fn`), but this code excludes the following case:
```rust
const FOO: Foo = non_const_fn();
```
Should we suggest `once_cell` in this case as well?
- The original issue mentions suggesting `AtomicI32` instead of `Mutex<i32>`, should this PR address that as well?
Mention `as_mut` alongside `as_ref` in borrowck error message
Kinda fixes#99426 but I guess that really might be better staying open to see if we could make it suggest `as_mut` in a structured way. Not sure how to change borrowck to know that info tho.
Rollup of 9 pull requests
Successful merges:
- #99576 (Do not allow `Drop` impl on foreign fundamental types)
- #100081 (never consider unsafe blocks unused if they would be required with deny(unsafe_op_in_unsafe_fn))
- #100208 (make NOP dyn casts not require anything about the vtable)
- #100494 (Cleanup rustdoc themes)
- #100522 (Only check the `DefId` for the recursion check in MIR inliner.)
- #100592 (Manually implement Debug for ImportKind.)
- #100598 (Don't fix builtin index when Where clause is found)
- #100721 (Add diagnostics lints to `rustc_type_ir` module)
- #100731 (rustdoc: count deref and non-deref as same set of used methods)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Lazily decode SourceFile from metadata
Currently, source files from foreign crates are decoded up-front from metadata.
Spans from those crates were matched with the corresponding source using binary search among those files.
This PR changes the strategy by matching spans to files during encoding. This allows to decode source files on-demand, instead of up-front. The on-disk format for spans becomes: `<tag> <position from start of file> <length> <file index> <crate (if foreign file)>`.
This verifies if the HEAD sha matches with the detected LLVM SHA, and if not,
permits usage of the detected LLVM. Otherwise, we fallback on regular
non-downloaded LLVM (currently still cached with sccache, though that's still
10+ minutes on macOS).
Don't fix builtin index when Where clause is found
Where clause shadows blanket impl for `Index` which causes normalization to not occur, which causes ICE to happen when we typeck.
r? `@compiler-errors`
Fixes#91633
Cleanup rustdoc themes
This PR continues our work to simplify the rustdoc themes by relying more on CSS variables. Interestingly enough, this time it allowed me to realize that we were having a lot of different colors for borders even though the difference is unnoticeable. I used this opportunity to unify them.
The live demo is [here](https://rustdoc.crud.net/imperio/cleanup-themes/std/index.html).
r? `@jsha`