diff options
| author | bors <bors@rust-lang.org> | 2023-07-18 09:07:32 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-07-18 09:07:32 +0000 |
| commit | c44324a4fe8e96f9d6473255df6c3a481caca76f (patch) | |
| tree | 349f78508e61de1ac25315cfefa3f8af318d5738 /tests | |
| parent | 0f16bd341eaf3ad47134c6d855a764e0099fbc93 (diff) | |
| parent | ef50e204f35ba2952f7ffd0e7560b136f1ace0aa (diff) | |
| download | rust-c44324a4fe8e96f9d6473255df6c3a481caca76f.tar.gz rust-c44324a4fe8e96f9d6473255df6c3a481caca76f.zip | |
Auto merge of #113677 - bryangarza:unevaluated-const-ice_issue-110892, r=davidtwco
Safe Transmute: Fix ICE (due to UnevaluatedConst) This patch updates the code that looks at the `Assume` type when evaluating if transmutation is possible. An ICE was being triggered in the case that the `Assume` parameter contained an unevaluated const (in this test case, due to a function with missing parameter names). Fixes #110892
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/transmutability/issue-110892.rs | 40 | ||||
| -rw-r--r-- | tests/ui/transmutability/issue-110892.stderr | 36 |
2 files changed, 76 insertions, 0 deletions
diff --git a/tests/ui/transmutability/issue-110892.rs b/tests/ui/transmutability/issue-110892.rs new file mode 100644 index 00000000000..ce926b39996 --- /dev/null +++ b/tests/ui/transmutability/issue-110892.rs @@ -0,0 +1,40 @@ +// check-fail +#![feature(generic_const_exprs, transmutability)] +#![allow(incomplete_features)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + + pub fn is_transmutable< + Src, + Dst, + Context, + const ASSUME_ALIGNMENT: bool, + const ASSUME_LIFETIMES: bool, + const ASSUME_SAFETY: bool, + const ASSUME_VALIDITY: bool, + >() + where + Dst: BikeshedIntrinsicFrom< + Src, + Context, + { from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) } + >, + {} + + // This should not cause an ICE + const fn from_options( + , //~ ERROR expected parameter name, found `,` + , //~ ERROR expected parameter name, found `,` + , //~ ERROR expected parameter name, found `,` + , //~ ERROR expected parameter name, found `,` + ) -> Assume {} //~ ERROR mismatched types +} + +fn main() { + struct Context; + #[repr(C)] struct Src; + #[repr(C)] struct Dst; + + assert::is_transmutable::<Src, Dst, Context, false, false, { true }, false>(); +} diff --git a/tests/ui/transmutability/issue-110892.stderr b/tests/ui/transmutability/issue-110892.stderr new file mode 100644 index 00000000000..13654307aee --- /dev/null +++ b/tests/ui/transmutability/issue-110892.stderr @@ -0,0 +1,36 @@ +error: expected parameter name, found `,` + --> $DIR/issue-110892.rs:27:9 + | +LL | , + | ^ expected parameter name + +error: expected parameter name, found `,` + --> $DIR/issue-110892.rs:28:9 + | +LL | , + | ^ expected parameter name + +error: expected parameter name, found `,` + --> $DIR/issue-110892.rs:29:9 + | +LL | , + | ^ expected parameter name + +error: expected parameter name, found `,` + --> $DIR/issue-110892.rs:30:9 + | +LL | , + | ^ expected parameter name + +error[E0308]: mismatched types + --> $DIR/issue-110892.rs:31:10 + | +LL | const fn from_options( + | ------------ implicitly returns `()` as its body has no tail or `return` expression +... +LL | ) -> Assume {} + | ^^^^^^ expected `Assume`, found `()` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0308`. |
