Commit Graph

19780 Commits

Author SHA1 Message Date
Jieyou Xu
eb3a8e5b81 Make attribute safety validation logic more obvious 2025-05-04 21:44:50 +08:00
bors
62c5f58f57 Auto merge of #140616 - petrochenkov:noannempty, r=jieyouxu
compiletest: Do not require annotations on empty labels and suggestions

Unlike other empty diagnostics, empty labels (only underlining spans) and empty suggestions (suggestions to remove something) are quite usual and do not require any special attention and annotations.

This effectively reverts a part of https://github.com/rust-lang/rust/pull/139485.

r? `@jieyouxu`
2025-05-04 09:38:17 +00:00
David Tolnay
6cca4ca82b Implement asymmetrical precedence for closures and jumps 2025-05-03 23:27:29 -07:00
bors
622ac04376 Auto merge of #140633 - Zalathar:rollup-iay94wa, r=Zalathar
Rollup of 7 pull requests

Successful merges:

 - #139675 (Add the AVX10 target features)
 - #140286 (Check if format argument is identifier to avoid error err-emit)
 - #140456 (Fix test simd/extract-insert-dyn on s390x)
 - #140551 (Move some tests out of tests/ui)
 - #140588 (Adjust some ui tests re. target-dependent errors)
 - #140617 (Report the `unsafe_attr_outside_unsafe` lint at the closest node)
 - #140626 (allow `#[rustfmt::skip]` in combination with `#[naked]`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-04 06:23:38 +00:00
Stuart Cook
1239f499e8 Rollup merge of #140626 - folkertdev:naked-rustfmt-skip, r=Amanieu
allow `#[rustfmt::skip]` in combination with `#[naked]`

fixes https://github.com/rust-lang/rust/issues/140623

We very deliberately use an allowlist to prevent weird interactions with `#[naked]`, hopefully we've now found all of the useful combinations.

cc `@Amanieu`
2025-05-04 13:21:10 +10:00
Stuart Cook
54821b9ed0 Rollup merge of #140617 - Urgau:unsafe_attr-lint-allow, r=jieyouxu
Report the `unsafe_attr_outside_unsafe` lint at the closest node

This PR have `AstValidation` track a linting node id and then uses it when reporting the `unsafe_attr_outside_unsafe` lint, so that instead of being bound at the crate-root, `#[allow]` of the lint works at any node.

Fixes rust-lang/rust#140602
r? `@jieyouxu`
2025-05-04 13:21:09 +10:00
Stuart Cook
de30d1b17c Rollup merge of #140588 - jieyouxu:opt-error, r=petrochenkov
Adjust some ui tests re. target-dependent errors

Alternatives to optional error annotations in #140586:

- Continue to ignore target-dependent additional errors in `tests/ui/panic-runtime/{two-panic-runtimes.rs,tests/ui/panic-runtime/want-abort-got-unwind.rs,tests/ui/panic-runtime/want-abort-got-unwind2.rs}` -- but explain why some targets have more errors than others.
- Use `-Cpanic=abort` for `tests/ui/cfg/cfg_false_no_std-2.rs`. In that test, the panic strategy does not matter w.r.t. test intention.
- Adjust FIXMEs in `tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-2.rs` to track it in #140620.

---

try-job: armhf-gnu
try-job: test-various
try-job: x86_64-msvc-1
try-job: i686-msvc-1
try-job: x86_64-mingw-1
try-job: aarch64-apple
try-job: x86_64-apple-1
2025-05-04 13:21:09 +10:00
Stuart Cook
bddb0152c7 Rollup merge of #140551 - mejrs:test4, r=jieyouxu
Move some tests out of tests/ui

r? `@jieyouxu`
2025-05-04 13:21:08 +10:00
Stuart Cook
020d908b64 Rollup merge of #140456 - fneddy:fix_s390x_codegen_simd_ext_ins_dyn, r=wesleywiser
Fix test simd/extract-insert-dyn on s390x

Fix the test for s390x by enabling s390x vector extension via `target_feature(enable = "vector")`(#127506). As this is is still gated by `#![feature(s390x_target_feature)]` we need that attribute also.
2025-05-04 13:21:08 +10:00
Stuart Cook
9c949b0373 Rollup merge of #140286 - xizheyin:issue-139104, r=lcnr
Check if format argument is identifier to avoid error err-emit

Fixes #139104

When `argument` is not an identifier, it should not be considered a field access. I checked this and if not emit an invalid format string error. I think we could do with a little finer error handling, I'll open an issue to track this down later.

The first commit submits the ui test, the second commits the code and the changes to the test output.

r? compiler
2025-05-04 13:21:07 +10:00
Stuart Cook
ed7590f1a0 Rollup merge of #139675 - sayantn:avx10, r=Amanieu
Add the AVX10 target features

Parent #138843

Adds the `avx10_target_feature` feature gate, and `avx10.1` and `avx10.2` target features.

It is confirmed that Intel is dropping AVX10/256 (see [this comment](https://github.com/rust-lang/rust/issues/111137#issuecomment-2795442288)), so this should be safe to implement now.

The LLVM fix for llvm/llvm-project#135394 was merged, and has been backported to LLVM20, and the patch has also been propagated to rustc in #140502

`@rustbot` label O-x86_64 O-x86_32 A-target-feature A-SIMD
2025-05-04 13:21:07 +10:00
bors
1bea580f36 Auto merge of #140549 - BoxyUwU:proper_const_norm, r=lcnr
Set groundwork for proper const normalization

r? lcnr

Updates a lot of our normalization/alias infrastructure to be setup to handle mgca aliases and normalization once const items are represented more like aliases than bodies. Inherent associated consts are still super busted, I didn't update the assertions that IACs the right arg setup because that winds up being somewhat involved to do *before* proper support for normalizing const aliases is implemented.

I dont *intend* for this to have any effect on stable. We continue normalizing via ctfe on stable and the codepaths in `project` for consts should only be reachable with mgca or ace.
2025-05-04 03:12:41 +00:00
Skgland
4ba683ee52 add a test for issue rust-lang/rust#81317 2025-05-03 22:36:17 +02:00
Vadim Petrochenkov
879b12e2ce compiletest: Do not require annotations on empty labels and suggestions 2025-05-03 22:49:23 +03:00
Folkert de Vries
9aee0aa453 allow #[rustfmt::skip] in combination with #[naked] 2025-05-03 19:15:19 +02:00
mejrs
9a574b0871 Move some tests out of tests/ui 2025-05-03 17:22:52 +02:00
Jieyou Xu
48b72c52f3 tests: add FIXME issue for debuginfo-type-name-layout-ice-94961-2.rs 2025-05-03 22:48:46 +08:00
Jieyou Xu
3ea420a697 tests: justify why want-abort-got-unwind{,2}.rs ignore additional errors 2025-05-03 22:44:36 +08:00
Jieyou Xu
cb73af3e2d tests: explain why two-panic-runtimes.rs ignores target-dependent errors 2025-05-03 22:44:36 +08:00
Jieyou Xu
a6cac47500 tests: fix a panic strategy in cfg_false_no_std-2.rs
To avoid having target-dependent "unwinding panics are not supported
without std" errors, without regressing test intention.
2025-05-03 22:44:36 +08:00
xizheyin
873ca5fa04 Just suggest positional arg and adjust issue0139104 ui test
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-03 22:39:43 +08:00
Urgau
f4e1ec111c Report the unsafe_attr_outside_unsafe lint at the closest node 2025-05-03 16:10:25 +02:00
yuk1ty
265b10fe2e Correct warning message in restricted visibility 2025-05-03 20:10:56 +09:00
Matthias Krüger
7b9fd9bf9e Rollup merge of #140576 - m-ou-se:fragile-tests, r=compiler-errors
Remove fragile equal-pointers-unequal tests.

Same as https://github.com/rust-lang/rust/pull/139176

---

These tests were added in #127003

These tests stop working when I change implementation details of format_args!(). These tests shouldn't rely on such implementation details.

Do these tests test anything that isn't already covered by other tests? If so, they should be expressed in a less fragile way that doesn't rely on internal details of format_args!().

cc `@GrigorenkoPV,` author of these tests.
2025-05-03 12:44:35 +02:00
Matthias Krüger
d8b0347a4b Rollup merge of #140395 - RalfJung:target-feature-tests, r=petrochenkov
organize and extend forbidden target feature tests

In particular this adds some loongarch tests for https://github.com/rust-lang/rust/pull/135015, Cc `@heiher`

Seems like the tests change so much git does not detect the renames; a commit-by-commit review should help.

try-job: `x86_64-gnu-llvm-20-*`
2025-05-03 12:44:35 +02:00
Matthias Krüger
a1a23debd6 Rollup merge of #138712 - petrochenkov:impasst, r=fmease
resolve: Support imports of associated types and glob imports from traits

Follow up to https://github.com/rust-lang/rust/pull/134754, part of https://github.com/rust-lang/rust/issues/134691.
This PR also closes https://github.com/rust-lang/rust/issues/138711 now.

Prohibiting `use Trait::AssocType;` at name resolution stage doesn't make sense, the name itself is perfectly resolveable.
It's a type checker's problem that the necessary generic args are not passed when the imported `AssocType` is used, so an error should be reported there.

And since we can import associated trait items now, glob imports from traits can also be allowed.
2025-05-03 12:44:34 +02:00
Eduard Stefes
61488e5070 Fix test simd/extract-insert-dyn on s390x
Fix the test for s390x by enabling s390x vector extension via
`target_feature(enable = "vector")`(#127506). As this is is still
gated by `#![feature(s390x_target_feature)]` we need that attribute
also.
2025-05-03 10:15:32 +02:00
Matthias Krüger
185f9e0870 Rollup merge of #140606 - nnethercote:hir-pp, r=dtolnay
Improve hir pretty printing

It's currently pretty bad, so a few small improvements can make a big difference.

r? `@dtolnay`
2025-05-03 08:45:05 +02:00
Matthias Krüger
5f9330c0b5 Rollup merge of #140568 - moxian:reg-140545, r=compiler-errors
Add regression test for #140545

Closes #140545

I am not very knowledgable about the typesystem internals, so I couldn't come up with a good name for the test. But I'm happy to move it to a more appropriate place if there is one (`tests/ui/impl-trait/non-defining-uses` maybe?)

r? types (or reroll as appropriate if this is not actually a T-types issue; i'm clueless)
2025-05-03 08:45:04 +02:00
Matthias Krüger
6cf4fd32bb Rollup merge of #140548 - BoxyUwU:gci_patterns_user_ty_annotation, r=compiler-errors
Emit user type annotations for free consts in pattern position

This previously wasnt done because free consts couldn't have any generic parameters that need to be preserved for borrowck. This is no longer the case with `feature(generic_const_items)`

r? fmease
2025-05-03 08:45:03 +02:00
Matthias Krüger
ca67f4da76 Rollup merge of #140505 - petrochenkov:expquote, r=bjorn3
linker: Quote symbol names in .def files

To support weird symbol names, including dots in particular.

cc [#134767](https://github.com/rust-lang/rust/pull/134767#issuecomment-2839397610)
2025-05-03 08:45:02 +02:00
Nicholas Nethercote
9af08429f1 Avoid an indent for labelled loops. 2025-05-03 12:46:51 +10:00
Nicholas Nethercote
809e5b5ed1 Fix some hir pretty-printing over-indenting. 2025-05-03 12:46:51 +10:00
Nicholas Nethercote
e1a177bbba Improve hir pretty-printing of attributes. 2025-05-03 12:46:48 +10:00
Nicholas Nethercote
760cf8d3af Fix hir pretty-printing of global_asm!.
One of the boxes isn't closed, and this causes everything after it to be
over-indented.
2025-05-03 09:14:27 +10:00
mejrs
4671081bdb Refactor rustc_on_unimplemented's filter parser 2025-05-02 22:08:35 +02:00
moxian
dcee18b3b8 Add a regression test
for #140545
2025-05-02 11:46:31 -07:00
lcnr
ffa7d1ee5d borrowck nested items in dead code 2025-05-02 18:45:28 +00:00
Matthias Krüger
6f7f3cec4f Rollup merge of #140574 - reddevilmidzy:add-test, r=compiler-errors
Add regression test for 133065

closes: #133065
2025-05-02 19:38:01 +02:00
Matthias Krüger
15f21f43b3 Rollup merge of #140550 - Amanieu:stabilize_select_unpredictable, r=workingjubilee
Stabilize `select_unpredictable`

FCP completed in tracking issue #133962.
2025-05-02 19:37:59 +02:00
Matthias Krüger
c796ef00f8 Rollup merge of #140521 - RalfJung:oob-error, r=saethlin
interpret: better error message for out-of-bounds pointer arithmetic and accesses

Fixes https://github.com/rust-lang/rust/issues/93881
r? `@saethlin`
2025-05-02 19:37:58 +02:00
Matthias Krüger
296733d5ac Rollup merge of #140519 - compiler-errors:name-based-comparison, r=oli-obk
Use select in projection lookup in `report_projection_error`

Using `for_each_relevant_impl` doesn't actually select the correct impl; we can use `select` here to actually get the correct impl with certainty. Follow-up to https://github.com/rust-lang/rust/pull/140278.

r? oli-obk
2025-05-02 19:37:57 +02:00
Jana Dönszelmann
3cc172074a collateral damage in derive tests, improves errors by not refering to implementation details 2025-05-02 18:09:31 +02:00
Jana Dönszelmann
867b4c9e48 Test that names of variables in external macros are not shown on a borrow error 2025-05-02 18:09:25 +02:00
xizheyin
72a9219e82 check all crate-type to find staticlib
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-02 22:57:14 +08:00
xizheyin
c59b70841c Emit warning while outputs is not exe and prints linkage info
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-02 22:08:58 +08:00
bors
7c96085b64 Auto merge of #140581 - Zalathar:rollup-ig2jb9v, r=Zalathar
Rollup of 12 pull requests

Successful merges:

 - #134034 (handle paren in macro expand for let-init-else expr)
 - #137474 (pretty-print: Print shebang at the top of the output)
 - #138872 (rustc_target: RISC-V `Zfinx` is incompatible with `{ILP32,LP64}[FD]` ABIs)
 - #139046 (Improve `Lifetime::suggestion`)
 - #139206 (std: use the address of `errno` to identify threads in `unique_thread_exit`)
 - #139608 (Clarify `async` block behaviour)
 - #139847 (Delegate to inner `vec::IntoIter` from `env::ArgsOs`)
 - #140159 (Avoid redundant WTF-8 checks in `PathBuf`)
 - #140197 (Document breaking out of a named code block)
 - #140389 (Remove `avx512dq` and `avx512vl` implication for `avx512fp16`)
 - #140430 (Improve test coverage of HIR pretty printing.)
 - #140507 (rustc_target: RISC-V: feature addition batch 3)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-02 13:54:16 +00:00
Vadim Petrochenkov
842858f765 linker: Quote symbol names in .def files
To support weird symbol names, including dots in particular.
2025-05-02 16:25:00 +03:00
Vadim Petrochenkov
3eee3dad5c resolve: Support imports of associated types and glob imports from traits 2025-05-02 15:59:38 +03:00
Stuart Cook
19c9b763ba Rollup merge of #140507 - a4lg:riscv-feature-addition-batch-3, r=Amanieu
rustc_target: RISC-V: feature addition batch 3

This is the last batch (3 of 3) for RISC-V feature enhancements intended for the version 1.88 cycle.

The author's primary criteria are:

1.  The extension is ratified and unprivileged one.
2.  The extension is in the RVA23U64 profile (to be a baseline of the application-class RISC-V software ecosystem in the near future), either mandatory or optional.
3.  Either:
    1.  To be discoverable through a `riscv_hwprobe` system call on (currently unreleased) Linux 6.15 (as of rc4) or
    2.  Helps memory/atomics-related operations more efficient and/or more robust.

This is based on the specifications:

*   [The latest ratified ISA Manuals (version 20240411)](https://lf-riscv.atlassian.net/wiki/spaces/HOME/pages/16154769/RISC-V+Technical+Specifications)
*   [RVA23/RVB23 profiles](https://github.com/riscv/riscv-profiles/releases/tag/rva23-rvb23-ratified)
*   [RISC-V BF16 extensions](https://github.com/riscv/riscv-bfloat16/releases/tag/v183a3dac863d7c18187a739eb52b0c8f0d16854d)

LLVM Definitions:

*   [`Zicbop`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L82-87)
*   [`Zicbom`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L75-L80)
*   [`Zic64b`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L71-L73)
*   [`Ziccamoa`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L97-L99)
*   [`Ziccif`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L101-L103)
*   [`Zicclsm`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L105-L107)
*   [`Ziccrse`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L109-L111)
*   [`Zfbfmin`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L320-L325)
*   [`Zvfbfmin`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L697-L702)
*   [`Zvfbfwma`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L704-L710)

The `Zicbop` extension (mandatory in RVA23U64) adds prefetch hints to prepare for subsequent memory operations (will be executed as no-op if the hardware does not support this extension).

The `Zicbom` extension (mandatory in RVA23U64) adds cache block-management instructions.  The author did not include this in the batch 2 (because of limited use cases compared to the `Zicboz` extension) but added because it will be discoverable from Linux (as of version 6.15-rc4).  Along with `Zicbop`, Rust now supports all CMO extensions.

The `Zic64b` extension (mandatory in RVA23U64) constraints the cache block to be naturally-aligned and exactly 64 bytes.  Along with CMO instructions, it can improve efficiency handling with memory (e.g. efficient memory zeroing using `Zicboz` + `Zic64b`).

The `Zicc*` extensions (mandatory in RVA23U64) add constraints to the main memory properties.  They are normally satisfied in the application environment with regular OSes but profiles like RVA23U64 ensures such properties are satisfied (through those *constraint* extensions).

The `Zfbf*` and `Zvfbf*` extensions (optional in RVA23U64) add instructions to handle BF16 (BFloat16) data.  Although stabilization of FP-related extensions are relatively far due to ABI-related issues, they are included in this batch because they will be discoverable from Linux (as of version 6.15-rc4).

The author also adds the extension implication: `Za64rs` → `Za128rs` (superset) which the author missed to include in #140139.
2025-05-02 22:17:03 +10:00