Commit graph

92 commits

Author SHA1 Message Date
Jubilee Young
18a707fc8e Revert "Fix an ICE in the vtable iteration for a trait reference"
The ICE fix appears to be unsound, causing a miscompilation involving
`dyn Trait` and `async {}` which induces segfaults in safe Rust code.
As the patch only hid an ICE, it does not seem worth the risk.

This reverts commit 8afd63610b, reversing
changes made to 19122c03c7.
2026-02-16 17:52:06 -08:00
Ralf Jung
5e65109f21 add write_box_via_move intrinsic and use it for vec!
This allows us to get rid of box_new entirely
2026-02-16 17:27:40 +01:00
Jacob Adam
6af91c56d1
Move tests from tests/crashes to tests/ui now that they don't ICE 2026-02-07 14:09:01 +01:00
Adwin White
b235cc22ac fix accidental type variable resolution in array coercion 2026-01-29 11:28:05 +08:00
bors
97b131c900 Auto merge of #148602 - BoxyUwU:coercion_cleanup_uncontroversial, r=lcnr
misc coercion cleanups and handle safety correctly

r? lcnr

### "remove normalize call"

Fixes rust-lang/rust#132765

If the normalization fails we would sometimes get a `TypeError` containing inference variables created inside of the probe used by coercion. These would then get leaked out causing ICEs in diagnostics logic

### "leak check and lub for closure<->closure coerce-lubs of same defids"

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/233
```rust
fn peculiar() -> impl Fn(u8) -> u8 {
    return |x| x + 1
}
```
the `|x| x + 1` expr has a type of `Closure(?31t)` which we wind up inferring the RPIT to. The `CoerceMany` `ret_coercion` for the whole `peculiar` typeck has an expected type of `RPIT` (unnormalized). When we type check the `return |x| x + 1` expr we go from the never type to `Closure(?31t)` which then participates in the `ret_coercion` giving us a `coerce-lub(RPIT, Closure(?31t))`.

Normalizing `RPIT` gives us some `Closure(?50t)` where `?31t` and `?50t` have been unified with `?31t` as the root var. `resolve_vars_if_possible` doesn't resolve infer vars to their roots so these wind up with different structural identities so the fast path doesn't apply and we fall back to coercing to a `fn` ptr. cc rust-lang/rust#147193 which also fixes this

New solver probably just gets more inference variables here because canonicalization + generally different approach to normalization of opaques. Idk :3

### FCP worthy stuffy

there are some other FCP worthy things but they're in my FCP comment which also contains some analysis of the breaking nature of the previously listed changes in this PR: https://github.com/rust-lang/rust/pull/148602#issuecomment-3503497467
2025-12-05 11:46:41 +00:00
Boxy Uwu
2f95ecfdd6 reviews 2025-12-03 16:36:32 +00:00
Boxy Uwu
76bd21ad66 account for safe target features in fndef<->closure and fndef<->fndef coerce-lubs 2025-12-03 14:55:41 +00:00
Boxy Uwu
2676c9363c Properly handle closure<->closure and fndef<->fndef coerce-lubs
- leak checking the lub for fndef<->fndef coerce-lubs
- start lubbing closure<->closure coerce-lubs and leak check it
2025-12-03 14:53:54 +00:00
Boxy Uwu
9a1b2e8846 remove normalize call 2025-12-03 14:53:54 +00:00
Boxy Uwu
6f632ef243 non-behaviour changing cleanups 2025-12-03 14:53:54 +00:00
Matthias Krüger
a2aa4f08da
Rollup merge of #149541 - WaffleLapkin:never-test, r=lcnr
Various never type test improvements

I want to make sure that the never type ui tests are actually sensible, and to do so I'm trying to clean them up. This mainly adds comments explaining test purposes and removes outdated stuff.

I imagine best reviewed commit-by-commit, I tried to write useful descriptions and group things into small commits.

cc `@lcnr` (I removed `fallback`/`nofallback` terminology in b5f82d4716d0d978b89034c902f88e2d449da636)
2025-12-03 13:05:15 +01:00
xonx4l
4b000cfacd Merge E0412 into E0425 2025-12-02 18:25:13 +00:00
Waffle Lapkin
e6d2b2add7
refactor Box<! -> dyn Error> regression test 2025-12-02 11:07:42 +01:00
Waffle Lapkin
3432ff9a1d
remove test for T -> ! coercion
We used to allow `T -> !` coercions (yes!! not `! -> T`) in unreachable
code. This was later removed during 2018 stabilization attempt, see:
- https://github.com/rust-lang/rust/issues/40800
- https://github.com/rust-lang/rust/pull/47630/commits/59688e119e1b9c2506fa9173728ae88eb196bf5e
- https://github.com/rust-lang/rust/issues/46325

I've kept `tests/ui/coercion/coerce-to-bang-cast.rs`, as that is a
reasonable test for us *not* having `-> !` coercions.
2025-12-02 11:07:42 +01:00
bors
d645a4c9c5 Auto merge of #148871 - WaffleLapkin:never-simplifications, r=lcnr
Remove context dependant `!` fallback

... and minor cleanup.

r? lcnr
2025-11-28 09:16:14 +00:00
Waffle Lapkin
b48d701f71
remove feature(never_type_fallback) 2025-11-27 22:48:00 +01:00
Shoyu Vanilla
9f584ffad0 Mention issue 149379 and add tests for it 2025-11-28 00:24:59 +09:00
Max Dexheimer
ebf1c38aa6 Check for intrinsic to fn ptr casts in unified coercions
Ensures that when coercing multiple expressions to a
unified type, the same "intrinsic to fn ptr" check is applied as for
other coercions.
2025-11-21 00:01:21 +01:00
Waffle Lapkin
b13f49e419
add explanation comments to !-related tests
... outside `tests/ui/never_type/`
2025-11-14 00:04:58 +01:00
Matthias Krüger
5559313a14
Rollup merge of #146490 - Oneirical:uncountable-integer-12, r=jieyouxu
Rehome 26 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` [#5 of Batch #2]

Part of rust-lang/rust#133895

Methodology:

1. Refer to the previously written `tests/ui/SUMMARY.md`
2. Find an appropriate category for the test, using the original issue thread and the test contents.
3. Add the issue URL at the bottom (not at the top, as that would mess up stderr line numbers)
4. Rename the tests to make their purpose clearer

Inspired by the methodology that Kivooeo was using.

r? ```@jieyouxu```
2025-10-18 23:54:44 +02:00
Oneirical
926599a45c Add test batch 5 2025-10-12 00:33:20 -04:00
Ding Xiang Fei
b77de834c0
mark THIR use as candidate for constness check 2025-09-25 01:54:25 +08:00
Ding Xiang Fei
120162e30f
add test fixture for newly allowed const expr
Signed-off-by: Ding Xiang Fei <dingxiangfei2009@protonmail.ch>
Co-authored-by: Theemathas Chirananthavat <theemathas@gmail.com>
2025-09-25 01:54:24 +08:00
Ding Xiang Fei
a86f140727
do not materialise X in [X; 0] when X is unsizing a const 2025-09-25 01:54:23 +08:00
Cameron Steffen
d66fb4910f Suggest removing Box::new 2025-09-16 04:22:50 -04:00
Matthias Krüger
47f1df5ca3
Rollup merge of #145676 - Oneirical:uncountable-integer-9, r=jieyouxu
Rehome 30 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` [#2 of Batch #2]

Part of rust-lang/rust#133895

Methodology:

1. Refer to the previously written `tests/ui/SUMMARY.md`
2. Find an appropriate category for the test, using the original issue thread and the test contents.
3. Add the issue URL at the bottom (not at the top, as that would mess up stderr line numbers)
4. Rename the tests to make their purpose clearer

Inspired by the methodology that `@Kivooeo` was using.

r? `@jieyouxu`
2025-08-29 12:37:30 +02:00
Oneirical
2dc4638c46 Add test batch 2 2025-08-27 15:06:05 -04:00
Michael Goulet
c957c4e704 Account for impossible bounds making seemingly unsatisfyable dyn-to-dyn casts 2025-08-23 16:49:15 +00:00
Karol Zwolak
d14b83e378 bless tests with new lint messages 2025-08-19 21:27:10 +02:00
Oneirical
75e0263af9 Rehome tests/ui/issues/ tests [5/?] 2025-08-17 13:01:02 -04:00
Jacob Pratt
5bd4e832d3
Rollup merge of #144553 - Oneirical:uncountable-integer-4, r=jieyouxu
Rehome 32 `tests/ui/issues/` tests to other subdirectories under `tests/ui/`

rust-lang/rust#143902 divided into smaller, easier to review chunks.

Part of rust-lang/rust#133895

Methodology:

1. Refer to the previously written `tests/ui/SUMMARY.md`
2. Find an appropriate category for the test, using the original issue thread and the test contents.
3. Add the issue URL at the bottom (not at the top, as that would mess up stderr line numbers)
4. Rename the tests to make their purpose clearer

Inspired by the methodology that `@Kivooeo` was using.

r? `@jieyouxu`
2025-08-10 15:43:52 -04:00
Oneirical
aa543963c6 Rehome tests/ui/issues/ tests [4/?] 2025-08-10 11:54:15 -04:00
Kivooeo
b6e13e3591 comments 2025-08-05 19:34:46 +05:00
Kivooeo
62c92f30cf moved 35 tests to organized locations 2025-08-05 19:02:23 +05:00
Ralf Jung
37ad0776ac
Rollup merge of #144397 - Kivooeo:issue2, r=jieyouxu
`tests/ui/issues/`: The Issues Strike Back [2/N]

Some `tests/ui/issues/` housekeeping, to trim down number of tests directly under `tests/ui/issues/`. Part of https://github.com/rust-lang/rust/issues/133895.

r? ``@jieyouxu``
2025-08-01 09:59:03 +02:00
Kivooeo
a4a5bf5a71 comments 2025-07-31 21:25:49 +05:00
Kivooeo
e9959aa74e comments 2025-07-25 20:38:54 +05:00
Kivooeo
b28806da23 cleaned up some tests 2025-07-05 00:45:24 +05:00
Kivooeo
986f1c9b69 moved tests 2025-07-01 18:21:05 +05:00
Michael Goulet
1c9f7955d4 Check CoerceUnsized impl validity before coercing 2025-06-24 17:48:09 +00:00
Esteban Küber
24dcfaf71f Make cast suggestions verbose
```
error[E0604]: only `u8` can be cast as `char`, not `u32`
  --> $DIR/E0604.rs:2:5
   |
LL |     1u32 as char;
   |     ^^^^^^^^^^^^ invalid cast
   |
help: try `char::from_u32` instead
   |
LL -     1u32 as char;
LL +     char::from_u32(1u32);
   |
```

```
error[E0620]: cast to unsized type: `&[u8]` as `[char]`
  --> $DIR/cast-to-slice.rs:6:5
   |
LL |     arr as [char];
   |     ^^^^^^^^^^^^^
   |
help: try casting to a reference instead
   |
LL |     arr as &[char];
   |            +
```

```
error[E0620]: cast to unsized type: `Box<{integer}>` as `dyn Send`
  --> $DIR/cast-to-unsized-trait-object-suggestion.rs:3:5
   |
LL |     Box::new(1) as dyn Send;
   |     ^^^^^^^^^^^^^^^^^^^^^^^
   |
help: you can cast to a `Box` instead
   |
LL |     Box::new(1) as Box<dyn Send>;
   |                    ++++        +
```
2025-06-06 19:53:12 +00:00
Lukas Wirth
aba70e8f9d Add missing dyn keywords to tests that do not test for them
This ensures that these tests can be run on editions other than 2015
2025-06-02 11:02:50 +02:00
xizheyin
17352e6937
Note ref expr being cast when encounter NonScalar cast error
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-31 12:19:55 +08:00
Oli Scherer
0b6e493515 Merge typeck loop with static/const item eval loop 2025-05-09 15:31:27 +00:00
Vadim Petrochenkov
20faf8532b compiletest: Make diagnostic kind mandatory on line annotations 2025-04-30 10:44:24 +03:00
Kivooeo
c9deaf6aaa fix for issue 135412 2025-04-24 03:20:19 +05:00
Michael Goulet
3df7882272 Normalize ADT fields in find_tails_for_unsizing 2025-04-14 16:51:00 +00:00
Vadim Petrochenkov
b3f75353a2 UI tests: add missing diagnostic kinds where possible 2025-04-08 23:06:31 +03:00
Spencer
5e6b4592d2 cleaned and organized 3 tests in ./tests/ui/issues 2025-03-21 22:55:00 -06:00
Michael Goulet
96d966b07a Consolidate and rework CoercePointee and DispatchFromDyn errors 2025-02-24 19:34:54 +00:00