1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
11 #![feature(core_intrinsics)]
14 use std::intrinsics::{init, uninit};
19 ref_to_zeroed_std(&x);
20 ref_to_zeroed_core(&x);
21 ref_to_zeroed_intr(&x);
22 ref_to_uninit_std(&x);
23 ref_to_uninit_core(&x);
24 ref_to_uninit_intr(&x);
32 unsafe fn ref_to_zeroed_std<T: ?Sized>(t: &T) {
33 let ref_zero: &T = std::mem::zeroed(); // warning
36 unsafe fn ref_to_zeroed_core<T: ?Sized>(t: &T) {
37 let ref_zero: &T = core::mem::zeroed(); // warning
40 unsafe fn ref_to_zeroed_intr<T: ?Sized>(t: &T) {
41 let ref_zero: &T = std::intrinsics::init(); // warning
44 unsafe fn ref_to_uninit_std<T: ?Sized>(t: &T) {
45 let ref_uninit: &T = std::mem::uninitialized(); // warning
48 unsafe fn ref_to_uninit_core<T: ?Sized>(t: &T) {
49 let ref_uninit: &T = core::mem::uninitialized(); // warning
52 unsafe fn ref_to_uninit_intr<T: ?Sized>(t: &T) {
53 let ref_uninit: &T = std::intrinsics::uninit(); // warning
60 unsafe fn std_zeroed_no_ref() {
61 let mem_zero: usize = std::mem::zeroed(); // no warning
64 unsafe fn core_zeroed_no_ref() {
65 let mem_zero: usize = core::mem::zeroed(); // no warning
68 unsafe fn intr_init_no_ref() {
69 let mem_zero: usize = std::intrinsics::init(); // no warning