libtest: use binary search for --exact test filtering
When `--exact` is passed in, use binary search for O(f log n) lookups instead of an O(n) linear scan, under the assumption that f << n (which is true for the most relevant cases).
This is important for Miri, where the interpreted execution makes the linear scan very expensive.
I measured this against a repo with 1000 empty tests, running `cargo +stage1 miri nextest run test_00` (100 tests) under hyperfine:
* Before (linear scan): 49.7s ± 0.6s
* After (binary search): 41.9s ± 0.2s (-15.7%)
I also tried a few other variations (particularly swapping matching tests to the front of the list + truncating the list), but the index + swap_remove approach proved to be the fastest.
Questions:
- [ ] To be conservative, I've assumed that test_main can potentially receive an unsorted list of tests. Is this assumption correct?
deprecate `std::char` constants and functions
similar to how constants in those modules for numeric types have been deprecated. The `std::char` module contains:
Three stable constants that this PR deprecates. These already link to their associated constant equivalents.
- `MAX`
- `REPLACEMENT_CHARACTER`
- `UNICODE_VERSION`
two unstable constants that this PR removes. The constants are already stablized as associated constants on `char`.
- `MAX_LEN_UTF8`
- `MAX_LEN_UTF16`
Four stable functions that this PR deprecates. These already link to their method equivalents.
- `fn decode_utf16`
- `fn from_digit`
- `fn from_u32`
- `fn from_u32_unchecked⚠`
discussion at [#t-libs > should `std::char::{MIN, MAX}` be deprecated?](https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/should.20.60std.3A.3Achar.3A.3A.7BMIN.2C.20MAX.7D.60.20be.20deprecated.3F/with/579444750).
r? libs-api
triagebot.toml: Sync `assign.owners` with `autolabel."T-compiler"`
In `autolabel."T-compiler"`, several `./tests/*` dirs are listed.
But many of them are missing from `assign.owners`. Add them all to `assign.owners` so reviewers are picked from the compiler group, and not from the small `assign.adhoc_groups.fallback` group.
Discovered in https://github.com/rust-lang/rust/pull/153941#issuecomment-4065145752.
CC fallback group @Mark-Simulacrum @jieyouxu who can maybe confirm that the old setup was not intentional? (Edit: I hope it was not intentional, because in that case I should have reached out to you personally beforehand.)
Add test for coalescing of diagnostic attribute duplicates
There is an existing [test](github.com/rust-lang/rust/blob/main/tests/ui/diagnostic_namespace/on_unimplemented/report_warning_on_duplicated_options.rs) that warnings for duplicates are emitted, but not for the messages themselves.
Replace the spdx-rs dependency with a minimal in-tree SPDX tag-value parser
The spdx-rs crate [is no longer maintained](https://github.com/doubleopen-project/spdx-rs/pulls) and is behind on its own dependency updates. It is currently used in [the collect-license-metadata tool](https://github.com/rust-lang/rust/tree/main/src/tools/collect-license-metadata), employing a single function therefrom: `spdx_rs::parsers::spdx_from_tag_value`, which parses the output of the `reuse` tool to extract file names, licences and copyright text.
This PR replaces the use of said function with a small minimal parser that handles just the subset of the SPDX tag-value format that is needed: `Tag: Value` line pairs and multi-line `<text>...</text>` blocks.
Coincidentally, this gets rid of the last transitive dependency on syn v1.
Add regression test for dead code elimination with drop + panic
Add a codegen test for rust-lang/rust#114532.
The bug was that dead code elimination failed when a `Drop` impl contained a `panic!` and a potentially-panicking external function was called after the value was created. This was fixed since 1.82 but no regression test was added.
The test verifies that `foo()` compiles to just a call to `unknown()` + `ret void`, with no panic or panicking call in the function body.
Closesrust-lang/rust#114532
Refactor FnDecl and FnSig non-type fields into a new wrapper type
#### Why this Refactor?
This PR is part of an initial cleanup for the [arg splat experiment](https://github.com/rust-lang/rust/issues/153629), but it's a useful refactor by itself.
It refactors the non-type fields of `FnDecl`, `FnSig`, and `FnHeader` into a new packed wrapper types, based on this comment in the `splat` experiment PR:
https://github.com/rust-lang/rust/pull/153697#discussion_r3004637413
It also refactors some common `FnSig` creation settings into their own methods. I did this instead of creating a struct with defaults.
#### Relationship to `splat` Experiment
I don't think we can use functional struct updates (`..default()`) to create `FnDecl` and `FnSig`, because we need the bit-packing for the `splat` experiment.
Bit-packing will avoid breaking "type is small" assertions for commonly used types when `splat` is added.
This PR packs these types:
- ExternAbi: enum + `unwind` variants (38) -> 6 bits
- ImplicitSelfKind: enum variants (5) -> 3 bits
- lifetime_elision_allowed, safety, c_variadic: bool -> 1 bit
#### Minor Changes
Fixes some typos, and applies rustfmt to clippy files that got skipped somehow.
std: Update dependency on `wasi` crate
This commit updates the crate dependency that the standard library has on the `wasi` crate. This is now updated to depending explicitly on the `wasip1` crate and the `wasip2` crate published on crates.io. These crates are managed in the [same location][repo] as the `wasi` crate and represent a different versioning scheme which doesn't require multi-version WASI support to require depending on the same crate at multiple versions. The code in libstd is updated to reference `wasip1` and `wasip2` directly as well.
[repo]: https://github.com/bytecodealliance/wasi-rs
Document why `layout.align() + layout.size()` doesn't overflow
This addition looks suspicious and is safety critical, but is saved by the weird `Layout` invariants.
std: fix HashMap RNG docs wording
Fixes a wording typo in the top-level HashMap docs.
Changed "random number coroutine" to "random number generator" in the seed entropy paragraph.
This section is security-relevant, and "generator" is the correct term in RNG context.
Testing:
- Not run locally (docs-only text change).
fix: add aliasing rules for Box
This is a new revised version for the PR [139857](https://github.com/rust-lang/rust/pull/139857), sorry for the delayed reply. I've rewritten the sentence to closely mirror the wording from `Vec::from_raw_parts`, which clearly states the transfer of ownership and its consequences. This should make the aliasing requirements much clearer.
I opted not to include a note about `mem::forget` by default to keep the documentation focused on the primary contract, similar to `Vec`.
net::tcp/udp: fix docs about how set_nonblocking is implemented
`fcntl` `FIONBIO` doesn't even make sense, it should be `fcntl` `F_SETFL`. However, for some reason we are using `ioctl` by default -- except on Solaris where this doesn't seem to work very well.
Honestly what I would have expected is that we just always use `FileDesc::set_nonblocking` also for network sockets, but for some reason we don't and there are no comments explaining this choice. Cc @nikarh (for "vita") @joboet
Rollup of 5 pull requests
Successful merges:
- rust-lang/rust#155308 (Make `OnDuplicate::Error` the default for attributes)
- rust-lang/rust#154432 (Set up API to make it possible to pass closures instead of `AttributeLint`)
- rust-lang/rust#154843 ( Fix conflicting deref move suggestion for LazyLock patterns)
- rust-lang/rust#155262 (bootstrap.py: fix duplicated "the")
- rust-lang/rust#155478 (Fixed broken documentation link for method lookup in rustc_hir_typeck…)
Fix conflicting deref move suggestion for LazyLock patterns
fixesrust-lang/rust#154826.
Rust was suggesting *V -> V for let (v,) = *V, which then triggered a follow-up error suggesting the opposite. This patch makes that case suggest borrowing (&*V) instead. Also handles destructuring assignment separately so we don’t emit a misleading &*... fix-it there.
Set up API to make it possible to pass closures instead of `AttributeLint`
Part of https://github.com/rust-lang/rust/issues/153099.
This PR sets up the base implementations needed to remove `AttributeLintKind` entirely and migrate two variants as examples.
r? @JonathanBrouwer
Make `OnDuplicate::Error` the default for attributes
This makes two changes, in separate commits for reviewability:
- Changes all unstable attributes that are currently `OnDuplicate::Warn` to error.
- Makes `OnDuplicate::Error` the default and removes the explicit `ON_DUPLICATE` for ones that currently already error
r? @jdonszelmann