Commit Graph

18385 Commits

Author SHA1 Message Date
Matthias Krüger
836db3ccae Rollup merge of #135808 - tiif:conv_display, r=workingjubilee
Implement Display for ``rustc_target::callconv::Conv``

Follow up of https://github.com/rust-lang/rust/pull/133103#discussion_r1885552854
2025-05-17 15:45:19 +02:00
mejrs
9ffd0bf75a do away with _Self and TraitName and check generic params for rustc_on_unimplemented 2025-05-17 15:15:53 +02:00
lcnr
667504b176 check coroutines with TypingMode::Borrowck to avoid cyclic reasoning
MIR borrowck taints its output if an obligation fails. This could then cause
`check_coroutine_obligations` to silence its error, causing us to not emit
and actual error and ICE.
2025-05-17 12:28:21 +00:00
Michael Goulet
9578b59eac Only select true errors in impossible_predicates 2025-05-17 12:09:15 +00:00
bors
a43b8d1d2b Auto merge of #141113 - matthiaskrgr:rollup-k7izuh8, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #140208 (Make well-formedness predicates no longer coinductive)
 - #140957 (Add `#[must_use]` to Array::map)
 - #141031 (Async drop fix for dropee from another crate (#140858))
 - #141036 (ci: split the dist-ohos job)
 - #141051 (Remove some unnecessary erases)
 - #141056 (Lowercase git url for rust-lang/enzyme.git)
 - #141059 (HIR: explain in comment why `ExprKind::If` "then" is an `Expr`)
 - #141070 (Do not emit help when shorthand from macro when suggest `?` or `expect`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-17 10:13:08 +00:00
Matthias Krüger
14f3ef997f Rollup merge of #141070 - xizheyin:issue-140659, r=chenyukang
Do not emit help when shorthand from macro when suggest `?` or `expect`

Fixes #140659

I didn't fully minimize the original bug, but I found a similar test case, and they have perhaps the same root cause. For the bug mentioned in #140659 , I also tested it locally and passed it.

Jieyou has worked on this part before, maybe r? `@jieyouxu`
2025-05-17 10:33:12 +02:00
Matthias Krüger
04bc9d13ca Rollup merge of #141031 - azhogin:azhogin/async-drop-dependency-fix, r=oli-obk
Async drop fix for dropee from another crate (#140858)

Fixes https://github.com/rust-lang/rust/issues/140858.

For `AsyncDestructor` impl def id was wrongly kept as a LocalDefId, which causes crash when dropee is declared in another crate.

Also, potential problem found:
when user crate drops type with async drop in dependency crate, and user crate doesn't enable `feature(async_drop)`, then sync drop version will be used.

Is it a problem? Do we need some notification about such situations?
2025-05-17 10:33:09 +02:00
Matthias Krüger
8c14588fbb Rollup merge of #140208 - compiler-errors:wf-coinductive, r=lcnr
Make well-formedness predicates no longer coinductive

This PR makes well-formedness no longer coinductive. It was made coinductive in https://github.com/rust-lang/rust/pull/98542, but AFAICT this was only to fix UI tests since we stopped lowering `where Ty:` to an empty-region outlives predicate but to a WF predicate instead.

Arguably it should lower to something completely different, something like a "type mentioned no-op predicate", but well-formedness serves this purpose fine today, and since no code (according to crater) relies on this coinductive behavior, we'd like to avoid having to emulate it in the new solver.

Fixes #123456 (I didn't want to add a test since it seems low-value to have a ICE test for a fuzzer minimization that is basically garbage code.)

Fixes #109764 (not sure if this behavior is emulatable w/o coinductive WF?)

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/169

r? lcnr
2025-05-17 10:33:08 +02:00
bors
b0e925903a Auto merge of #141024 - jieyouxu:revert-arm64ec, r=wesleywiser
Revert "Fix linking statics on Arm64EC #140176"

This reverts PR #140176.
Unfortunately, this will reopen https://github.com/rust-lang/rust/issues/138541 (re-breaking the `arm64ec-pc-windows-msvc` target).

Unfortunately, multiple people are [reporting linker warnings related to `__rust_no_alloc_shim_is_unstable`](https://github.com/rust-lang/rust/pull/140176#issuecomment-2879715554) after this change in `x86_64-pc-windows-msvc` as well. The solution isn't quite clear yet, let's revert to avoid the linker warnings on the Tier 1 MSVC target for now[^timing], and try a reland with a determined solution for `__rust_no_alloc_shim_is_unstable`.

Judging from [people reporting that they are observing this also when bootstrapping w/ stage0 rustc](https://github.com/rust-lang/rust/pull/140176#issuecomment-2881867433), we may have to cut a new beta and then repoint stage0 against that newer beta?

cc `@dpaoliello` `@wesleywiser`

r? `@wesleywiser` (or compiler)

[^timing]: Note that it's still RustWeek this week, so most team members are N/A.
2025-05-17 07:00:46 +00:00
Jubilee Young
0c157b51d3 aarch64-linux: Default to FramePointer::NonLeaf
For aarch64-apple and aarch64-windows, platform docs state that code
must use frame pointers correctly. This is because the AAPCS64 mandates
that a platform specify its frame pointer conformance requirements:
- Apple: https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Respect-the-purpose-of-specific-CPU-registers
- Windows: https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#integer-registers
- AAPCS64: 4492d1570e/aapcs64/aapcs64.rst (the-frame-pointer)

Unwinding code either requires unwind tables or frame pointers, and
on aarch64 the expectation is that one can use frame pointers for this.
Most Linux targets represent a motley variety of possible distributions,
so it is unclear who to defer to on conformance, other than perhaps Arm.
In the absence of a specific edict for a given aarch64-linux target,
Rust will assume aarch64-linux targets use non-leaf frame pointers.
This reflects what compilers like clang do.
2025-05-17 06:42:46 +02:00
xizheyin
1c17324c7d Create tests/ui/typeck/suggestions/ and move some tests in tests/ui/typeck/ to it
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-17 01:01:58 +08:00
xizheyin
742c27bc52 Do not emit help when shorthand from macro when suggest ? or expect
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-17 01:01:54 +08:00
satler
067fe1ffb5 add regression test for rust-lang#101650 2025-05-17 01:30:07 +09:00
est31
258e880861 Remove #![feature(let_chains)] from library and src/librustdoc 2025-05-16 16:14:24 +02:00
xizheyin
43ff8855ac Add ui test macro-shorthand-issue-140659
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-16 17:03:55 +08:00
bors
c79bbfab78 Auto merge of #141066 - matthiaskrgr:rollup-e7tyrj5, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #140791 (std: explain prefer `TryInto` over `TryFrom` when specifying traits bounds on generic function)
 - #140834 (move (or remove) some impl Trait tests)
 - #140910 (Remove `stable` attribute from wasi fs (read_exact|write_all)_at)
 - #140984 (fix doc for UnixStream)
 - #140997 (Add negative test coverage for `-Clink-self-contained` and `-Zlinker-features`)
 - #141003 (Improve ternary operator recovery)
 - #141009 (Migrate to modern datetime API)
 - #141013 (Implement methods to set STARTUPINFO flags for Command API on Windows)
 - #141026 (rustc-dev-guide subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-16 05:45:37 +00:00
Matthias Krüger
e53b9f8fdd Rollup merge of #141003 - clubby789:ternary-improve, r=compiler-errors
Improve ternary operator recovery

This
- Improves the span of the error to not point at the next token
- Where possible, we use the span of the condition to further improve the span of the error to include the cond, and suggest a maybe-incorrect fix

Currently this works on free expressions, not let statements; some more refactoring would be needed to pass the span down, which I'm not sure is worth doing.

### Old
![image](https://github.com/user-attachments/assets/5688cefc-e4ef-4135-a5ba-340ce05ae6f3)

### New
![image](https://github.com/user-attachments/assets/154f5380-e0c8-42c7-9bf8-0adb3d0433fa)
2025-05-16 07:19:41 +02:00
Matthias Krüger
953905fd9e Rollup merge of #140997 - jieyouxu:link-flags-negative-tests, r=lqd
Add negative test coverage for `-Clink-self-contained` and `-Zlinker-features`

Noticed while reviewing stabilization #140525 that we don't have any negative test coverage for these flags. Feel free to cherry-pick these tests into the stabilization PR, or we can land these before separately.

r? `@lqd`
2025-05-16 07:19:40 +02:00
Matthias Krüger
e4929b530e Rollup merge of #140834 - lcnr:apit-folder, r=compiler-errors
move (or remove) some impl Trait tests

Probably not actually worth the effort, so I am stopping here 😅
2025-05-16 07:19:38 +02:00
bors
7e19eef048 Auto merge of #140557 - compiler-errors:remove-wf-hack, r=lcnr
Remove manual WF hack

We do not need this hack anymore since we fixed the candidate selection problems with `Sized` bounds. We prefer built-in sized bounds now since #138176, which fixes the only regression this hack was intended to fix.

While this theoretically is broken for some code, for example, when there a param-env bound that shadows an impl or built-in trait, we don't see it in practice and IMO it's not worth the burden of having to maintain this wart in `compare_method_predicate_entailment`.

The code that regresses is, for example:

```rust
trait Bar<'a> {}

trait Foo<'a, T> {
    fn method(&self)
    where
        Self: Bar<'a>;
}

struct W<'a, T>(&'a T)
where
    Self: Bar<'a>;

impl<'a, 'b, T> Bar<'a> for W<'b, T> {}

impl<'a, 'b, T> Foo<'a, T> for W<'b, T> {
    fn method(&self) {}
}
```

Specifically, I don't believe this is really going to be encountered in practice. For this to fail, there must be a where clause in the *trait method* that would shadow an impl or built-in (non-`Sized`) candidate in the trait, and this shadowing would need to be encountered when solving a nested WF goal from the impl self type.

See #108544 for the original regression. Crater run is clean!

r? lcnr
2025-05-16 02:34:32 +00:00
bors
6d1875f99b Auto merge of #141050 - matthiaskrgr:rollup-uyzqbmj, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #139749 (docs(library/core/src/pin): fix typo "necessarily" -> "necessary")
 - #140685 (Simplify `Vec::as_non_null` implementation and make it `const`)
 - #140712 (normalization: avoid incompletely constraining GAT args)
 - #140768 (Improve `dangerous_implicit_aurorefs` diagnostic output)
 - #140947 (Flush errors before deep normalize in `dropck_outlives`)
 - #140990 (VxWorks: updates from recent libc versions)
 - #141027 (remove `RustfmtState` to reduce `initial_rustfmt` complexity)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-15 23:30:38 +00:00
Matthias Krüger
d0ea342440 Rollup merge of #140947 - compiler-errors:pending-norm, r=lcnr
Flush errors before deep normalize in `dropck_outlives`

Deep normalization doesn't allow the ocx to have pending obligations, so process them before deeply normalizing.

Fixes https://github.com/rust-lang/rust/issues/140931
Fixes https://github.com/rust-lang/rust/issues/140462
2025-05-15 22:28:51 +02:00
Matthias Krüger
f5fb0d3ea0 Rollup merge of #140768 - Urgau:improv_autorefs-lint, r=fmease
Improve `dangerous_implicit_aurorefs` diagnostic output

This PR *greatly* improves the `dangerous_implicit_aurorefs` lint diagnostic output.

Kind of related to #140721.

r? ```@jieyouxu``` (maybe)
2025-05-15 22:28:51 +02:00
Matthias Krüger
1f84e114f1 Rollup merge of #140712 - lcnr:normalization-gat-args, r=compiler-errors
normalization: avoid incompletely constraining GAT args

We need to copy the behavior of #125214 in the new solver. This fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/202 which seems to be the cause of the regression in `deptypes`.

r? ```@compiler-errors```
2025-05-15 22:28:50 +02:00
bors
d97326eabf Auto merge of #136264 - GuillaumeGomez:optimize-integers-to-string, r=Amanieu
Optimize `ToString` implementation for integers

Part of https://github.com/rust-lang/rust/issues/135543.

Follow-up of https://github.com/rust-lang/rust/pull/133247 and https://github.com/rust-lang/rust/pull/128204.

The benchmark results are:

| name| 1.87.0-nightly (3ea711f17 2025-03-09) | With this PR | diff |
|-|-|-|-|
| bench_i16 | 32.06 ns/iter (+/- 0.12) | 17.62 ns/iter (+/- 0.03) | -45% |
| bench_i32 | 31.61 ns/iter (+/- 0.04) | 15.10 ns/iter (+/- 0.06) | -52% |
| bench_i64 | 31.71 ns/iter (+/- 0.07) | 15.02 ns/iter (+/- 0.20) | -52% |
| bench_i8 | 13.21 ns/iter (+/- 0.14) | 14.93 ns/iter (+/- 0.16) | +13% |
| bench_u16 | 31.20 ns/iter (+/- 0.06) | 16.14 ns/iter (+/- 0.11) | -48% |
| bench_u32 | 33.27 ns/iter (+/- 0.05) | 16.18 ns/iter (+/- 0.10) | -51% |
| bench_u64 | 31.44 ns/iter (+/- 0.06) | 16.62 ns/iter (+/- 0.21) | -47% |
| bench_u8 | 10.57 ns/iter (+/- 0.30) | 13.00 ns/iter (+/- 0.43) | +22% |

More information about it in [the original comment](https://github.com/rust-lang/rust/pull/136264#discussion_r1987542954).

r? `@workingjubilee`
2025-05-15 20:20:30 +00:00
Daniel Paoliello
6128fca0b0 [win][arm64] Remove 'Arm64 Hazard' undocumented MSVC option and instead disable problematic test 2025-05-15 11:33:28 -07:00
bors
c4e05e53d1 Auto merge of #136988 - compiler-errors:impossible_predicates, r=lcnr
Use the new solver in the `impossible_predicates`

The old solver is unsound for many reasons. One of which was weaponized by `@lcnr` in #140212, where the old solver was incompletely considering a dyn vtable method to be impossible and replacing its vtable entry with a null value. This null function could be called post-mono.

The new solver is expected to be less incomplete due to its correct handling of higher-ranked aliases in relate. This PR switches the `impossible_predicates` query to use the new solver, which patches this UB.

r? lcnr
2025-05-15 15:31:24 +00:00
bendn
de8e8641ae dont handle bool transmute 2025-05-15 20:20:39 +07:00
Andrew Zhogin
7b2dcf2989 Async drop fix for dropee from another crate (#140858) 2025-05-15 20:05:07 +07:00
Jieyou Xu
734a5b1aa7 Revert "Fix linking statics on Arm64EC #140176"
Unfortunately, multiple people are reporting linker warnings related to
`__rust_no_alloc_shim_is_unstable` after this change. The solution isn't
quite clear yet, let's revert to green for now, and try a reland with a
determined solution for `__rust_no_alloc_shim_is_unstable`.

This reverts commit c8b7f32434, reversing
changes made to 667247db71.
2025-05-15 16:54:27 +08:00
Jieyou Xu
a716f1a523 Add some negative test coverage for -Zlinker-features flag 2025-05-15 16:47:18 +08:00
Jieyou Xu
3e051afec7 Add some negative test coverage for malformed -Clink-self-contained flags 2025-05-15 16:47:17 +08:00
Urgau
9b3abe79d7 Use more subdiagnostics and reword the overloaded deref note 2025-05-14 23:53:40 +02:00
Urgau
ac1df15f86 Improve dangerous_implicit_aurorefs diagnostic output 2025-05-14 18:58:38 +02:00
Matthias Krüger
e39ab25bf4 Rollup merge of #140989 - xizheyin:issue-139631, r=compiler-errors
Suggest replace f with f: Box<f> when expr field is short hand

Fixes #139631

r? compiler
2025-05-14 18:43:40 +02:00
Matthias Krüger
dcb808e48b Rollup merge of #140827 - compiler-errors:gather-locals-twice, r=oli-obk
Do not ICE when reassigning in GatherLocalsVisitor on the bad path

Fixes https://github.com/rust-lang/rust/issues/140785
Fixes https://github.com/rust-lang/rust/issues/140730

See comment in code.

r? oli-obk
2025-05-14 18:43:37 +02:00
Jamie
1267333ef1 Improve ternary operator recovery 2025-05-14 13:32:59 +01:00
xizheyin
32be459909 Suggest replace f with f: Box<f> when expr field is short hand
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-14 15:14:32 +08:00
xizheyin
dca57c6714 Add ui test suggest-box-for-expr-field-issue-139631
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-14 15:08:17 +08:00
est31
7b45c59d40 Add match guard chains test for absence of compilation error
based on tests/ui/rfcs/rfc-2497-if-let-chains/temporary-early-drop.rs
2025-05-14 00:45:28 +02:00
est31
5c2677d017 Add match guard chains test, based on mir_let_chains_drop_order.rs 2025-05-13 16:22:52 +02:00
est31
dcd2736fcc Add match guard chains to drop-order-comparisons.rs 2025-05-13 16:22:48 +02:00
bors
3ae0b2e2ed Auto merge of #140927 - mejrs:test5, r=jieyouxu
chore: move more ui tests

r? `@jieyouxu`
2025-05-13 00:03:33 +00:00
Michael Goulet
df1da673f7 Flush errors before deep normalize in dropck_outlives 2025-05-12 21:04:38 +00:00
mejrs
60c32f61ae Move more tests/ui tests 2025-05-12 16:35:09 +02:00
Jorge Aparicio
2fdf3d9820 ui/async-drop-initial: factor in panic strategy in destructor size check
the size of `AsyncStruct`'s destructor depends on whether the configured
panic strategy is 'unwind' or 'abort' so factor that into the test using
conditional compilation

fixes rust-lang/rust#140939
2025-05-12 13:58:20 +02:00
bors
ac9ac0e0f3 Auto merge of #140925 - the8472:test-140207, r=compiler-errors
add regression test for 140207

Assembly test for #140207
2025-05-12 04:32:50 +00:00
bors
6812af9821 Auto merge of #140842 - tmiasko:print-mono-items, r=saethlin
Remove mono item collection strategy override from -Zprint-mono-items

Previously `-Zprint-mono-items` would override the mono item collection
strategy. When debugging one doesn't want to change the behaviour, so
this was counter productive. Additionally, the produced behaviour was
artificial and might never arise without using the option in the first
place (`-Zprint-mono-items=eager` without `-Clink-dead-code`).  Finally,
the option was incorrectly marked as `UNTRACKED`.

Resolve those issues, by turning `-Zprint-mono-items` into a boolean
flag that prints results of mono item collection without changing the
behaviour of mono item collection.

For codegen-units test incorporate `-Zprint-mono-items` flag directly
into compiletest tool.

Test changes are mechanical. `-Zprint-mono-items=lazy` was removed
without additional changes, and `-Zprint-mono-items=eager` was turned
into `-Clink-dead-code`.  Linking dead code disables internalization, so
tests have been updated accordingly.
2025-05-11 22:15:30 +00:00
HaeNoe
a504759afd feat: add codegen test
Ensure that code for generic `d_primal::<T>` is generated even if `primal::<T>`
is never used.

- incorporate feedback from @ZuseZ4
2025-05-11 17:54:57 +02:00
HaeNoe
e2b7278942 feat: add generated parameters to generated function
- update pretty printing tests
- only add generic parameters when function is actually generic (no empty turbofish)
2025-05-11 17:54:57 +02:00