Rollup of 14 pull requests
Successful merges:
- #73963 (deny(unsafe_op_in_unsafe_fn) in libstd/path.rs)
- #75099 (lint/ty: move fns to avoid abstraction violation)
- #75502 (Use implicit (not explicit) rules for promotability by default in `const fn`)
- #75580 (Add test for checking duplicated branch or-patterns)
- #76310 (Add `[T; N]: TryFrom<Vec<T>>` (insta-stable))
- #76400 (Clean up vec benches bench_in_place style)
- #76434 (do not inline black_box when building for Miri)
- #76492 (Add associated constant `BITS` to all integer types)
- #76525 (Add as_str() to string::Drain.)
- #76636 (assert ScalarMaybeUninit size)
- #76749 (give *even better* suggestion when matching a const range)
- #76757 (don't convert types to the same type with try_into (clippy::useless_conversion))
- #76796 (Give a better error message when x.py uses the wrong stage for CI)
- #76798 (Build fixes for RISC-V 32-bit Linux support)
Failed merges:
r? `@ghost`
give *even better* suggestion when matching a const range
notice that the err already has "constant defined here"
so this is now *exceedingly clear*
extension to #76222
r? @estebank
assert ScalarMaybeUninit size
I noticed most low-level Miri types have such an assert but `ScalarMaybeUninit` does not, so let's add that. Good t see that the `Option`-like optimization kicks in and this is no bigger than `Scalar`. :)
r? @oli-obk
Add as_str() to string::Drain.
Vec's Drain recently [had its `.as_slice()` stabilized](https://github.com/rust-lang/rust/pull/72584), but String's Drain was still missing the analogous `.as_str()`. This adds that.
Also improves the Debug implementation, which now shows the remaining data instead of just `"Drain { .. }"`.
Add associated constant `BITS` to all integer types
Recently I've regularly come across this snippet (in a few different crates, including `core` and `std`):
```rust
std::mem::size_of<usize>() * 8
```
I think it's time for a `usize::BITS`.
do not inline black_box when building for Miri
We cannot do the assembly trick in Miri, but let's at least make sure MIR inlining does not circumvent the black_box.
Also use black_box instead of local optimization barriers in a few const tests.
Add test for checking duplicated branch or-patterns
This adds a regression test for checking `or-patterns` in MIR as shown in #75439.
This doesn't introduce a fix as I'm not sure where it would go(I suspect maybe here: src/librustc_mir_build/build/matches/mod.rs), and I'm not particularly able to fix it.
cc: @lzutao
lint/ty: move fns to avoid abstraction violation
This PR moves `transparent_newtype_field` and `is_zst` to `LateContext` where they are used, rather than being on the `VariantDef` and `TyS` types, hopefully addressing @eddyb's concern [from this comment](https://github.com/rust-lang/rust/pull/74340#discussion_r456534910).
deny(unsafe_op_in_unsafe_fn) in libstd/path.rs
The libstd/path.rs part of #73904 . Wraps the two calls to an unsafe fn Initializer::nop() in an unsafe block.
Wrap recursive predicate evaluation with `ensure_sufficient_stack`
I haven't been able to come up with a minimized test case for #76770,
but this fixes a stack overflow in rustc as well.
Upgrade libz-sys to 1.1.2
The current version has warnings that become errors on new versions of clang shipped in XCode:
```
warning: src/zlib/gzlib.c:214:15: error: implicitly declaring library function 'snprintf' with type 'int (char *, unsigned long, const char *, ...)' [-Werror,-Wimplicit-function-declaration]
warning: (void)snprintf(state->path, len + 1, "%s", (const char *)path);
warning: ^
warning: src/zlib/gzlib.c:214:15: note: include the header <stdio.h> or explicitly provide a declaration for 'snprintf'
warning: 1 error generated.
warning: src/zlib/gzwrite.c:428:11: error: implicitly declaring library function 'vsnprintf' with type 'int (char *, unsigned long, const char *, __builtin_va_list)' [-Werror,-Wimplicit-function-declaration
warning: len = vsnprintf(next, state->size, format, va);
warning: ^
warning: src/zlib/gzwrite.c:428:11: note: include the header <stdio.h> or explicitly provide a declaration for 'vsnprintf'
warning: 1 error generated.
```
r? `@Mark-Simulacrum`
/cc `@joshtriplett`
Distribute rustc sources as part of `rustc-dev`
They can be used to provide IDE features when working on rustc plugins/backends/etc without having to locate a separate Rust checkout.
r? `@Mark-Simulacrum`
Dogfood new_uninit and maybe_uninit_slice in rustc_arena
Dogfoods a few cool `MaybeUninit` related features in the compiler's rustc_arena crate.
Split off from #76821
r? `@oli-obk`
Add host triples to target lists
This PR is primarily intended to fix https://github.com/rust-lang/rustup/issues/2494, which is the second commit. That bug was introduced by #76415, and incompletely fixed by #76639. (#76639 added host triples, which gave us compilers, but missed that we also need documentation and other target-only things). However, it also removes duplicate macOS CI builders.
r? `@pietroalbini`
compare generic constants using `AbstractConst`s
This is a MVP of rust-lang/compiler-team#340. The changes in this PR should only be relevant if `feature(const_evaluatable_checked)` is enabled.
~~currently based on top of #76559, so blocked on that.~~
r? `@oli-obk` cc `@varkor` `@eddyb`
Issue 72408 nested closures exponential
This fixes#72408.
Nested closures were resulting in exponential compilation time.
This PR is enhancing asymptotic complexity, but also increasing the constant, so I would love to see perf run results.
[mir-opt] Disable the `ConsideredEqual` logic in SimplifyBranchSame opt
The logic is currently broken and we need to disable it to fix a beta
regression (see #76803)
r? `@oli-obk`