rust/tests
Matthias Krüger e7504ac704
Rollup merge of #128934 - Nadrieril:fix-empty-non-exhaustive, r=compiler-errors
Non-exhaustive structs may be empty

This is a follow-up to a discrepancy noticed in https://github.com/rust-lang/rust/pull/122792: today, the following struct is considered inhabited (non-empty) outside its defining crate:
```rust
#[non_exhaustive]
pub struct UninhabitedStruct {
    pub never: !,
    // other fields
}
```

`#[non_exhaustive]` on a struct should mean that adding fields to it isn't a breaking change. There is no way that adding fields to this struct could make it non-empty since the `never` field must stay and is inconstructible. I suspect this was implemented this way due to confusion with `#[non_exhaustive]` enums, which indeed should be considered non-empty outside their defining crate.

I propose that we consider such a struct uninhabited (empty), just like it would be without the `#[non_exhaustive]` annotation.

Code that doesn't pass today and will pass after this:
```rust
// In a different crate
fn empty_match_on_empty_struct<T>(x: UninhabitedStruct) -> T {
    match x {}
}
```

This is not a breaking change.

r? ``@compiler-errors``
2024-09-03 19:13:24 +02:00
..
assembly Revert "Auto merge of #127537 - veluca93:struct_tf, r=BoxyUwU" 2024-09-01 16:35:53 +02:00
auxiliary
codegen Rollup merge of #129316 - dingxiangfei2009:riscv64-imac-scs, r=nnethercote 2024-08-29 16:21:47 +02:00
codegen-units Fix and enable disabled codegen-units tests 2024-08-10 14:03:27 -04:00
coverage Finish blessing coverage/mcdc tests after LLVM 19 upgrade 2024-08-01 13:36:50 +10:00
coverage-run-rustdoc
crashes Rollup merge of #129780 - cyrgani:master, r=compiler-errors 2024-09-01 03:58:05 +02:00
debuginfo Make option-like-enum.rs UB-free and portable 2024-08-27 19:12:14 -04:00
incremental Rollup merge of #127279 - bvanjoi:fix-112680, r=petrochenkov 2024-08-21 19:35:10 +02:00
mir-opt Rollup merge of #129493 - cjgillot:early-opaque-def, r=petrochenkov 2024-09-01 03:58:04 +02:00
pretty stabilize raw_ref_op 2024-08-18 19:46:53 +02:00
run-make Rollup merge of #129837 - aDotInTheVoid:test-better-json, r=jieyouxu 2024-09-02 04:19:30 +02:00
run-pass-valgrind
rustdoc Rollup merge of #129560 - GuillaumeGomez:impl-assoc-type-source-link, r=notriddle 2024-08-27 00:42:01 +02:00
rustdoc-gui Rollup merge of #127474 - tesuji:foldable-inline-derefs, r=t-rustdoc 2024-09-02 04:19:27 +02:00
rustdoc-js Add test for Self not being a generic in search index 2024-08-04 12:49:28 -07:00
rustdoc-js-std rustdoc: show exact case-sensitive matches first 2024-08-23 13:05:24 -04:00
rustdoc-json Rollup merge of #129123 - aDotInTheVoid:rustdoc-json-self, r=fmease 2024-08-31 10:08:52 +02:00
rustdoc-ui Adjust expected errors for a rustdoc test 2024-08-18 22:52:54 -05:00
ui Rollup merge of #128934 - Nadrieril:fix-empty-non-exhaustive, r=compiler-errors 2024-09-03 19:13:24 +02:00
ui-fulldeps Deny imports of rustc_type_ir::inherent outside of type ir + new trait solver 2024-09-01 12:16:18 -04:00
COMPILER_TESTS.md