diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-04-27 14:32:47 +0200 |
|---|---|---|
| committer | Matthias Krüger <matthias.krueger@famsik.de> | 2024-04-28 10:23:10 +0200 |
| commit | 012f9e26acbdab1c34b8ba40ccb44788a822d1d8 (patch) | |
| tree | 8c550100fe5df90f45e9ef8816b67a648efd90bf | |
| parent | c32e2fe1796feb6c8c0cd3f0008bc4c3efc9106f (diff) | |
| download | rust-012f9e26acbdab1c34b8ba40ccb44788a822d1d8.tar.gz rust-012f9e26acbdab1c34b8ba40ccb44788a822d1d8.zip | |
add test for Inconsistent rustc_transmute::is_transmutable(...) result, got Yes
Fixes https://github.com/rust-lang/rust/issues/110969
| -rw-r--r-- | tests/ui/const-generics/adt_const_params/transmutable-ice-110969.rs | 32 | ||||
| -rw-r--r-- | tests/ui/const-generics/adt_const_params/transmutable-ice-110969.stderr | 39 |
2 files changed, 71 insertions, 0 deletions
diff --git a/tests/ui/const-generics/adt_const_params/transmutable-ice-110969.rs b/tests/ui/const-generics/adt_const_params/transmutable-ice-110969.rs new file mode 100644 index 00000000000..68b8b489816 --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/transmutable-ice-110969.rs @@ -0,0 +1,32 @@ +// ICE Inconsistent rustc_transmute::is_transmutable(...) result, got Yes +// issue: rust-lang/rust#110969 +#![feature(adt_const_params, generic_const_exprs, transmutability)] +#![allow(incomplete_features, unstable_features)] + +mod assert { + use std::mem::BikeshedIntrinsicFrom; + + pub fn is_transmutable<Src, Dst, Context, const ASSUME: std::mem::Assume>() + where + Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME>, + //~^ ERROR trait takes at most 2 generic arguments but 3 generic arguments were supplied + { + } +} + +fn via_associated_const() { + struct Context; + #[repr(C)] + struct Src; + #[repr(C)] + struct Dst; + + trait Trait { + const FALSE: bool = assert::is_transmutable::<Src, Dst, Context, {}>(); + //~^ ERROR mismatched types + //~| ERROR `Src` cannot be safely transmuted into `Dst` + //~| ERROR mismatched types + } +} + +pub fn main() {} diff --git a/tests/ui/const-generics/adt_const_params/transmutable-ice-110969.stderr b/tests/ui/const-generics/adt_const_params/transmutable-ice-110969.stderr new file mode 100644 index 00000000000..1dbacaee3c2 --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/transmutable-ice-110969.stderr @@ -0,0 +1,39 @@ +error[E0107]: trait takes at most 2 generic arguments but 3 generic arguments were supplied + --> $DIR/transmutable-ice-110969.rs:11:14 + | +LL | Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME>, + | ^^^^^^^^^^^^^^^^^^^^^ ------ help: remove this generic argument + | | + | expected at most 2 generic arguments + +error[E0308]: mismatched types + --> $DIR/transmutable-ice-110969.rs:25:74 + | +LL | const FALSE: bool = assert::is_transmutable::<Src, Dst, Context, {}>(); + | ^^ expected `Assume`, found `()` + +error[E0277]: `Src` cannot be safely transmuted into `Dst` + --> $DIR/transmutable-ice-110969.rs:25:60 + | +LL | const FALSE: bool = assert::is_transmutable::<Src, Dst, Context, {}>(); + | ^^^ `Dst` may carry safety invariants + | +note: required by a bound in `is_transmutable` + --> $DIR/transmutable-ice-110969.rs:11:14 + | +LL | pub fn is_transmutable<Src, Dst, Context, const ASSUME: std::mem::Assume>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0308]: mismatched types + --> $DIR/transmutable-ice-110969.rs:25:29 + | +LL | const FALSE: bool = assert::is_transmutable::<Src, Dst, Context, {}>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()` + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0107, E0277, E0308. +For more information about an error, try `rustc --explain E0107`. |
