summary refs log tree commit diff
path: root/src/test/ui/issues/issue-17718-const-borrow.rs
blob: 8a31bd0c66af6675e17ba4111c212ee74f88a261 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use std::cell::UnsafeCell;

const A: UnsafeCell<usize> = UnsafeCell::new(1);
const B: &'static UnsafeCell<usize> = &A;
//~^ ERROR: cannot borrow a constant which may contain interior mutability

struct C { a: UnsafeCell<usize> }
const D: C = C { a: UnsafeCell::new(1) };
const E: &'static UnsafeCell<usize> = &D.a;
//~^ ERROR: cannot borrow a constant which may contain interior mutability
const F: &'static C = &D;
//~^ ERROR: cannot borrow a constant which may contain interior mutability

fn main() {}