]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/const_raw_ptr_ops.rs
Report const eval error inside the query
[rust.git] / src / test / ui / consts / const-eval / const_raw_ptr_ops.rs
1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![feature(const_raw_ptr_to_usize_cast, const_compare_raw_pointers, const_raw_ptr_deref)]
12
13 fn main() {}
14
15 // unconst and bad, will thus error in miri
16 const X: bool = &1 as *const i32 == &2 as *const i32; //~ ERROR any use of this value will cause
17 // unconst and fine
18 const X2: bool = 42 as *const i32 == 43 as *const i32;
19 // unconst and fine
20 const Y: usize = 42usize as *const i32 as usize + 1;
21 // unconst and bad, will thus error in miri
22 const Y2: usize = &1 as *const i32 as usize + 1; //~ ERROR any use of this value will cause
23 // unconst and fine
24 const Z: i32 = unsafe { *(&1 as *const i32) };
25 // unconst and bad, will thus error in miri
26 const Z2: i32 = unsafe { *(42 as *const i32) }; //~ ERROR any use of this value will cause
27 const Z3: i32 = unsafe { *(44 as *const i32) }; //~ ERROR any use of this value will cause