Derives `Copy` for `ffi::FromBytesUntilNulError`
[`ffi::FromBytesWithNulError` derives `Copy` since Rust 1.93](https://github.com/rust-lang/rust/commit/2f5a3d4b06a0a9e8749c2e361758ec517df0c96a) while `ffi::FromBytesUntilNulError` doesn't.
This Pr fixes that by deriving `Copy` for `ffi::FromBytesUntilNulError`.
I encountered this issue while I was working in a const context.
Note: I couldn't find any documentation about what kind of PR is allowed. As this one is very small, I guess it is ok to submit it directly without opening an issue first?
Remove `UncheckedIterator`
The only remaining usage of `UncheckedIterator` was in `array::{try_,}from_trusted_iterator`. So, replace `array::repeat` and array's `Clone` impl with a manual `from_fn` call rather than going through unnecessary abstractions, and remove the `UncheckedIterator` trait.
Allow `global_asm!` in statement positions
This PR makes it possible to put `global_asm!` in statement positions. This is particularly useful for proc-macros, where you otherwise have to wrap them in `mod foo { global_asm!(...); }`.
I'm happy to open an ACP first (or a design meeting?).
I would also assume this needs sign-off from the lang-team?
Previously discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/216763-project-inline-asm/topic/Item.20position.20global_asm/with/581784943).
r? @Amanieu
Implement `OsStr::split_at`
See rust-lang/rust#156199
This allows splitting only on valid UTF-8 boundaries, regardless of the platform, which avoids cross-platform landmines.
change `other uses of const` to `raw pointers` in const keyword docs
this section only talks about how `const` is used in raw pointers and doesn't give any other uses, so in my opinion it would be a bit clearer if the section was named `raw pointers` or something similar.
Fix typo in `format_into` docs: signed -> unsigned
The documentation for the `format_into` methods on unsigned integers
still said "in signed decimal format". Change them to say "unsigned".
Change division to multiplication in floating-point midpoint
Multiplication is faster than division on most (all?) platforms. While the optimizer will handle this, there is really no point in relying on that. Using multiplication directly will not have any drawbacks and are numerically identical (in this case since 1.0 / 2.0 == 0.5)
Consider the examples at https://godbolt.org/z/oMvb9vobG where it is clear that the non-optimized version uses division, while the optimized version uses multiplication.
library: Fix std compilation for espidf target in unix::process
Fixes a regression on the riscv32imac-esp-espidf target caused by commit 7bf5fe7bf8 (linked issue rust-lang/rust#156537) . The unix_kill_process_group feature attempts to use libc::SIGKILL, which is not supported on the espidf target.
Discussed in `esp-idf-sys` issue: https://github.com/esp-rs/esp-idf-sys/issues/419
Preserve spans when hiding do_not_recommend impls
Fixesrust-lang/rust#156475 by restoring the root span only when the current refined span has wandered outside the parent obligation.
remove/update various cfg(miri)
I went over all `cfg(miri)` in `library/`. Most of the things I noticed have become separate PRs; these here are the few remaining scattered little fixes in various places.
Fix cross-compiling `macos-deployment-target-warning` test
`cc()` gets target flags, which won't match with the host triple used by `bare_rustc()`.
Follow-up to https://github.com/rust-lang/rust/pull/155716, with both of these, `./x test --target arm64e-apple-darwin tests` now succeeds.
r? compiler
Include vendored sources in the rust-src component
In the future this can be used by build-std, but until then it is still useful for allowing rust-analyzer to work offline.
This increases the unpacked size by 24MB (from 116MB to 140MB) and the compressed size by only 2MB (from 18MB to 20MB)
Disable rust-analyzer tests on LLVM 21
The rust-analyzer tests have been frequently failing with a SIGSEGV on CI in the LLVM 21 runners. In my investigation, this seems to be fixed with LLVM 22. It was suggested that we should just disable these tests.
There wasn't a particularly convenient way to detect if this is running with LLVM 21, so I decided to just check the CI_JOB_NAME which contains the image name which in our case includes the string "llvm-21".
Fixes https://github.com/rust-lang/rust/issues/156460
rename unexpected_try_recover function
While reading the code, the doc comment and the name of the function `unexpected_try_recover` confused me. The doc said it tries to recover if it is a closing delimiter but I see no recovering code and the function always return an error.
So I change the name of the function to `unexpected_err` and change the return value to `Diag<'a>`. I also update the doc comment.
Avoid rustfix suggestions for macro-expanded unused imports
Avoid emitting rustfix suggestions for unused imports when the removal span is not directly editable.
Closesrust-lang/rust#147855
explicit tail calls: ignore some tests on unsupported LLVM targets
Fixes https://github.com/rust-lang/rust/issues/148748
Add ignore derivatives to two tests that cause the most platforms to fail, there are two reasons:
All tests involving `musttail` should fail on these platforms due to poor support overall by LLVM, but since they have low usage and supposedly already have many tests failing we limit ignores to the two "worst" tests.
```
//@ ignore-aix
//@ ignore-csky
//@ ignore-mips
//@ ignore-mips64
//@ ignore-powerpc
//@ ignore-powerpc64
//@ ignore-thumb
```
aix/powerpc issue: https://github.com/llvm/llvm-project/issues/187119
thumb issue: https://github.com/llvm/llvm-project/issues/73167
mips has been fixed but it is in a different LLVM version than what is pinned by Rust: https://github.com/llvm/llvm-project/issues/57795
These were caused by argument/returns that do not fit in registers (e.g., indirect), they had a fix but were reverted due to lifetime issues:
```
//@ ignore-riscv64
//@ ignore-loongarch32
//@ ignore-loongarch64
```
RISC-V had a fix which got reverted: https://github.com/llvm/llvm-project/pull/191508
LoongArch fix also got reverted: https://github.com/llvm/llvm-project/pull/191525
Also add missing compiletest directive names for `ignore-csky`, `ignore-mips`, and `ignore-mips64`.
r? folkertdev
Test EII UI tests with prefer-dynamic
Tracking issue: rust-lang/rust#125418
Remove `no-prefer-dynamic` from the EII UI tests now that rust-lang/rust#153648 fixed exporting EII declaration aliases from dylibs.
Fixesrust-lang/rust#151271.
Tested with:
```sh
python3 x.py test tests/ui/eii --force-rerun
```
ci: Update FreeBSD version to FreeBSD 14
FreeBSD 12 & 13 are now EOL. The decision to move to FreeBSD 13 was not implemented due to the issues with the toolchain. Now that FreeBSD 14 is the most recent supported version, we should use it for builds in CI.
Split `LintExpectationId`s
This PR makes clearer where stable and unstable `LintExpectationIds` can occur, plus a few other small cleanups. Details in individual commits.
r? @GuillaumeGomez
compiler: suggest `.collect()` when `String` is expected and `Iterator` is found
This commit adds a diagnostic suggestion to help users who forget to call `.collect()` when they have an iterator and the function or variable expects a `String`.
The logic checks if the expected type is `std::string::String` and if the found type implements the `Iterator` trait, if so the compiler provides a suggestion to add `.collect()`
Includes also a UI test to verify if the suggestion appears correctly
Remove redundant information in `rustc_abi::Variants`
Follow-up to rust-lang/rust#151040; partially addresses rust-lang/rust#113988.
Replaces the nested `LayoutData` in `Variants::Multiple` by a new, smaller `VariantLayout` struct, and adjust `LayoutData::for_variant`and the layout algorithm in consequence.
This PR is best reviewed commit-by-commit.
This is the only remaining place that uses `UncheckedIterator`. So,
replace `array::repeat` and array's `Clone` impl with a manual `from_fn`
call rather than going through unnecessary abstractions.
Removal of `UncheckedIterator` will be done in a later commit.