forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#113677 - bryangarza:unevaluated-const-ice_iss…
…ue-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 rust-lang#110892
- Loading branch information
Showing
4 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |