linker-messages is warn-by-default again
cc rust-lang/rust#136096
I ended up keeping it a lint and adding an option for lints to ignore `-Dwarnings` (there was already a lint that did that actually, it was just hard-coded in rustc_middle instead of in rustc_lint_defs like I'd expect). This allows people to actually see the warnings without them failing the build in CI.
Adds a couple UI tests for polonius
I went through all the open issues labeled `fixed-by-polonius` and from that created two UI tests based on issues that seemed a little novel.
One for rust-lang/rust#92038 and another for rust-lang/rust#70044.
Both tests fail under NLL but pass with polonius (legacy and alpha).
Fix order-dependent visibility diagnostics
Fixesrust-lang/rust#40066.
Fixes https://github.com/rust-lang/rust/issues/109657.
Delay visibility path diagnostics until module collection has finished, so paths to later non-ancestor modules report E0742 instead of an unresolved path error.
Do not run jump-threading for GPUs
GPU targets have convergent operations that must not be duplicated or
moved in or out of control-flow.
An example convergent operation is a barrier/syncthreads.
The only MIR pass affected by this is jump-threading, it can duplicate
calls. Disable jump-hreading for GPU targets to prevent generating
incorrect code.
This affects the amdgpu and nvptx targets.
Fixesrust-lang/rust#137086, see this issue for details.
Tracking issue: rust-lang/rust#135024
cc @RDambrosio016 @kjetilkjeka for nvptx
cc @ZuseZ4
It used to ICE when hitting an `assert_ne!(location.block, successor.block` due
to hitting a self-dominating bb
Fixed by checking *strict* domination instead of normal one
tests/run-make/print-cfg: add Android target_env case
Regression test for rust-lang/rust#90834rust-lang/rust#77729 + rust-lang/rust#78929 accidentally gave Android targets `target_env="gnu"`
through `android_base` inheriting from `linux_gnu_base`. rust-lang/rust#90834 moved it
back to plain `linux_base` but didn't add a test, so a future target-spec
refactor could bring it back unnoticed. This adds an Android case to
`tests/run-make/print-cfg` covering exactly that.
r? @petrochenkov
c-variadic: document `Clone` and `Drop` instances and require `VaArgSafe: Copy`
tracking issue: https://github.com/rust-lang/rust/issues/44930
Fixing some things that came up in the stabilization PR
r? tgross35
cc @kpreid
Suggest public re-exports when a private module makes an import path inaccessible
This is an attempt at solving rust-lang/rust#13065.
When a `use` path fails because it passes through a private module (E0603), and a public re-export of the target item exists elsewhere, the compiler will now suggest importing through that re-export instead.
For example, given:
```rust
mod outer {
pub use self::inner::MyStruct;
mod inner {
pub struct MyStruct;
}
}
use outer::inner::MyStruct; // error: module `inner` is private
```
the compiler will now suggest use `outer::MyStruct`; - the publicly accessible path - rather than just pointing at the private module definition and leaving the user to figure out the alternative.
When possible, relative paths are suggested, including those using `super` (currently capped at a maximum of one `super` path item).
The newly added test is parametrised by editions because of the change in behaviour around `crate::`-prefixed imports in edition 2018. Perhaps that’s an overkill – I’ll be happy to remove the variations for editions 2021 and 2024.
Closesrust-lang/rust#13065.
rustdoc: preserve parent doc cfg for `macro_export` macros
The detached-item context is discovered before `propagate_doc_cfg`, it is carried on the clean item and consumed by the pass.
Closesrust-lang/rust#100916
Fix: On wasm targets, call `panic_in_cleanup` if panic occurs in cleanup
Relies on https://github.com/rust-lang/llvm-project/pull/194.
Reland of https://github.com/rust-lang/rust/pull/151771.
Previously this was not correctly implemented. Each funclet may need its own terminate block, so this changes the `terminate_block` into a `terminate_blocks` `IndexVec` which can have a terminate_block for each funclet. We key on the first basic block of the funclet -- in particular, this is the start block for the old case of the top level terminate function.
Rather than using a catchswitch/catchpad pair, I used a cleanuppad. The reason for the pair is to avoid catching foreign exceptions on MSVC. On wasm, it seems that the catchswitch/catchpad pair is optimized back into a single cleanuppad and a catch_all instruction is emitted which will catch foreign exceptions. Because the new logic is only used on wasm, it seemed better to take the simpler approach seeing as they do the same thing.
- [ ] Add test for https://github.com/rust-lang/rust/issues/153948
Android targets must not inherit `target_env="gnu"` from the Linux GNU
base. Cover this in the existing print-cfg run-make test so a future
target-spec refactor cannot silently re-introduce it.
Fix `doc_cfg` feature for extern items
Part of rust-lang/rust#150268.
It only solves the extern items issue, but not the others listed in the issue. I will need to think about how to fix them nicely.
r? @Urgau
Avoid misleading return-type note for foreign `Fn` callees
Fixesrust-lang/rust#155727.
The issue occurred because the code that emitted the `Fn`/`FnMut` suggestion only avoided the return-type fallback when it could point at a local callee argument. The local case from rust-lang/rust#125325 was fixed in rust-lang/rust#126226, but nested cross-crate cases could still suggest changing the enclosing function's return type even though the relevant `Fn` requirement came from the callee argument.
This is also the broader diagnostic shape discussed in rust-lang/rust#119985.
This PR checks the instantiated callee predicates for an exact `Fn` bound
on the closure argument, and extends `wrong-closure-arg-suggestion-125325` with cross-crate function and method cases for that path.
`dlltool`: Set the working directory to workaround `--temp-prefix` bug
dlltool's `--temp-prefix` argument incorrectly splits paths that contain spaces. To workaround this, we pass a relative path to `--temp-prefix` and set the working directory.
fixesrust-lang/rust#155591
Suggest `[const] Trait` bounds in more places
Right now we have some special logic in the const checker for emitting `[const] Trait` suggestions, but I'm trying to handle that similarly to how it is handled for normal `Trait` clauses. This is just a small step in how it will look on the UX side, which should make my follow-up PRs affect tests less and just be a refactoring
c-variadic: more precise compatibility check in const-eval
tracking issue: https://github.com/rust-lang/rust/issues/44930
This came up in the stabilization report discussion https://github.com/rust-lang/rust/pull/155697#discussion_r3139778447.
As a reminder, this is what C says (in section 7.16.1.1 of the [C23 standard](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf#page=302).
> If type is not compatible with the type of the actual next argument (as promoted according to the default argument promotions), the behavior is undefined, except for the following cases:
>
> - both types are pointers to qualified or unqualified versions of compatible types;
> - one type is compatible with a signed integer type, the other type is compatible with the
> corresponding unsigned integer type, and the value is representable in both types;
> - one type is pointer to qualified or unqualified void and the other is a pointer to a qualified or
> unqualified character type;
> - or, the type of the next argument is `nullptr_t` and type is a pointer type that has the same representation and alignment requirements as a pointer to a character type
I think the last rule is not relevant for us, we don't really have an equivalent of `nullptr_t` as far as I know.
r? RalfJung
cc @tgross35
When archive format is wrong produce an error instead of ICE
Fixrust-lang/rust#145624. Fixrust-lang/rust#147094. Fixrust-lang/rust#148217.
There are now two-step solutions to replace the original ICE:
Step 1: BSD format archive on a GNU/Linux target should emit a format mismatch warning.
Step 2: Corrupt archive with member offset exceeding file boundary should produce an error, not an ICE.
r? @bjorn3
simd_reduce_min/max: remove float support
LLVM currently doesn't have an intrinsic with the right semantics here (see https://github.com/llvm/llvm-project/issues/185827). The only remaining user of this intrinsic with float types is portable-simd and it's easier to implement a fallback there than here, so I opted for making the intrinsic int-only. I kept around the float support in cranelift and Miri because there it already has the desired semantics (matching scalar min/max).
Fixes https://github.com/rust-lang/rust/issues/153395
~~Blocked on https://github.com/rust-lang/portable-simd/pull/515~~
tests: mark simple UI tests as check-pass
This changes 14 simple UI tests from build-pass to check-pass.
These tests cover type checking, trait bounds, closure inference, deprecation diagnostics, dyn compatibility, and variance. They do not need codegen or linking, so check-pass keeps the intended coverage while removing old FIXME(62277) markers.
NVPTX: Drop support for old architectures and old ISAs
This is the implementation of [this MCP](https://github.com/rust-lang/compiler-team/issues/965#issuecomment-3837320262)
I believe it was said that no FCP was needed, but if that is incorrect then the FCP is anyway scheduled to finish in 2 days so it can in any case be merged then.