diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-05-24 09:23:40 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-24 09:23:40 +0200 |
| commit | 293977aeb831d0cb36d095ecec953b30378da440 (patch) | |
| tree | 72283104d819a553ca2a1bb99fa3d57231b38235 /tests | |
| parent | 63a53555a1d4fe1d18bf30ac252029bab14b9618 (diff) | |
| parent | 46606a3f81d67f16b738b3dff74aba5070c7890e (diff) | |
| download | rust-293977aeb831d0cb36d095ecec953b30378da440.tar.gz rust-293977aeb831d0cb36d095ecec953b30378da440.zip | |
Rollup merge of #141429 - compiler-errors:unsafe-binder-non-structural-match, r=spastorino
Dont walk into unsafe binders when emiting error for non-structural type match Fixes #141422. The other two binder-having types are also special cased here, unsurprisingly. r? oli-obk
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/unsafe-binders/non-strucutral-type-diag.rs | 17 | ||||
| -rw-r--r-- | tests/ui/unsafe-binders/non-strucutral-type-diag.stderr | 13 |
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/ui/unsafe-binders/non-strucutral-type-diag.rs b/tests/ui/unsafe-binders/non-strucutral-type-diag.rs new file mode 100644 index 00000000000..e021e9567e5 --- /dev/null +++ b/tests/ui/unsafe-binders/non-strucutral-type-diag.rs @@ -0,0 +1,17 @@ +// regression test for <https://github.com/rust-lang/rust/issues/141422>. + +#![feature(unsafe_binders)] +#![allow(incomplete_features)] + +#[derive(Copy, Clone)] +struct Adt<'a>(&'a ()); + +const C: Option<(unsafe<'a> Adt<'a>, Box<dyn Send>)> = None; + +fn main() { + match None { + C => {} + //~^ ERROR constant of non-structural type + _ => {} + } +} diff --git a/tests/ui/unsafe-binders/non-strucutral-type-diag.stderr b/tests/ui/unsafe-binders/non-strucutral-type-diag.stderr new file mode 100644 index 00000000000..ab23210b2e5 --- /dev/null +++ b/tests/ui/unsafe-binders/non-strucutral-type-diag.stderr @@ -0,0 +1,13 @@ +error: constant of non-structural type `Option<(unsafe<'a> Adt<'a>, Box<dyn Send>)>` in a pattern + --> $DIR/non-strucutral-type-diag.rs:13:9 + | +LL | const C: Option<(unsafe<'a> Adt<'a>, Box<dyn Send>)> = None; + | ---------------------------------------------------- constant defined here +... +LL | C => {} + | ^ constant of non-structural type + | + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + +error: aborting due to 1 previous error + |
