2019-06-29 13:34:42 +00:00
|
|
|
#![allow(deprecated, unused)]
|
2017-09-29 02:24:31 +00:00
|
|
|
#![feature(core_intrinsics)]
|
|
|
|
|
|
|
|
extern crate core;
|
2019-06-29 13:34:42 +00:00
|
|
|
use std::intrinsics::init;
|
2017-09-29 02:24:31 +00:00
|
|
|
|
|
|
|
fn main() {
|
2018-12-09 22:26:16 +00:00
|
|
|
let x = 1;
|
|
|
|
unsafe {
|
2017-09-29 02:24:31 +00:00
|
|
|
ref_to_zeroed_std(&x);
|
|
|
|
ref_to_zeroed_core(&x);
|
|
|
|
ref_to_zeroed_intr(&x);
|
|
|
|
ref_to_uninit_std(&x);
|
|
|
|
ref_to_uninit_core(&x);
|
2017-09-30 01:01:02 +00:00
|
|
|
some_ref();
|
|
|
|
std_zeroed_no_ref();
|
|
|
|
core_zeroed_no_ref();
|
|
|
|
intr_init_no_ref();
|
2017-09-29 02:24:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe fn ref_to_zeroed_std<T: ?Sized>(t: &T) {
|
2018-12-09 22:26:16 +00:00
|
|
|
let ref_zero: &T = std::mem::zeroed(); // warning
|
2017-09-29 02:24:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsafe fn ref_to_zeroed_core<T: ?Sized>(t: &T) {
|
2018-12-09 22:26:16 +00:00
|
|
|
let ref_zero: &T = core::mem::zeroed(); // warning
|
2017-09-29 02:24:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsafe fn ref_to_zeroed_intr<T: ?Sized>(t: &T) {
|
2018-12-09 22:26:16 +00:00
|
|
|
let ref_zero: &T = std::intrinsics::init(); // warning
|
2017-09-29 02:24:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsafe fn ref_to_uninit_std<T: ?Sized>(t: &T) {
|
2018-12-09 22:26:16 +00:00
|
|
|
let ref_uninit: &T = std::mem::uninitialized(); // warning
|
2017-09-29 02:24:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsafe fn ref_to_uninit_core<T: ?Sized>(t: &T) {
|
2018-12-09 22:26:16 +00:00
|
|
|
let ref_uninit: &T = core::mem::uninitialized(); // warning
|
2017-09-29 02:24:31 +00:00
|
|
|
}
|
|
|
|
|
2017-09-30 01:01:02 +00:00
|
|
|
fn some_ref() {
|
2018-12-09 22:26:16 +00:00
|
|
|
let some_ref = &1;
|
2017-09-30 01:01:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsafe fn std_zeroed_no_ref() {
|
2018-12-09 22:26:16 +00:00
|
|
|
let mem_zero: usize = std::mem::zeroed(); // no warning
|
2017-09-30 01:01:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsafe fn core_zeroed_no_ref() {
|
2018-12-09 22:26:16 +00:00
|
|
|
let mem_zero: usize = core::mem::zeroed(); // no warning
|
2017-09-30 01:01:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsafe fn intr_init_no_ref() {
|
|
|
|
let mem_zero: usize = std::intrinsics::init(); // no warning
|
|
|
|
}
|