Skip to content

Commit 386e822

Browse files
committed
Use generic NonZero.
1 parent 4fee811 commit 386e822

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/tools/miri/tests/fail/enum-set-discriminant-niche-variant-wrong.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![feature(custom_mir)]
33

44
use std::intrinsics::mir::*;
5-
use std::num::NonZeroI32;
5+
use std::num::NonZero;
66

77
// We define our own option type so that we can control the variant indices.
88
#[allow(unused)]
@@ -13,7 +13,7 @@ enum Option<T> {
1313
use Option::*;
1414

1515
#[custom_mir(dialect = "runtime", phase = "optimized")]
16-
fn set_discriminant(ptr: &mut Option<NonZeroI32>) {
16+
fn set_discriminant(ptr: &mut Option<NonZero<i32>>) {
1717
mir! {
1818
{
1919
// We set the discriminant to `Some`, which is a NOP since this is the niched variant.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use std::num::*;
1+
use std::num::NonZero;
22

33
#[repr(C)]
4-
struct S1(NonZeroI32);
4+
struct S1(NonZero<i32>);
55

66
#[repr(C)]
77
struct S2(i32);
@@ -11,6 +11,6 @@ fn callee(_s: S2) {}
1111
fn main() {
1212
let fnptr: fn(S2) = callee;
1313
let fnptr: fn(S1) = unsafe { std::mem::transmute(fnptr) };
14-
fnptr(S1(NonZeroI32::new(1).unwrap()));
14+
fnptr(S1(NonZero::new(1).unwrap()));
1515
//~^ ERROR: calling a function with argument of type S2 passing data of type S1
1616
}

0 commit comments

Comments
 (0)