]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/consts/qualif-indirect-mutation-fail.rs
1 // compile-flags: --crate-type=lib
2 #![feature(const_mut_refs)]
3 #![feature(const_precise_live_drops)]
4 #![feature(const_swap)]
5 #![feature(raw_ref_op)]
7 // Mutable borrow of a field with drop impl.
9 let mut a
: (u32, Option
<String
>) = (0, None
); //~ ERROR destructors cannot be evaluated
13 // Mutable borrow of a type with drop impl.
15 let mut x
= None
; //~ ERROR destructors cannot be evaluated
16 let mut y
= Some(String
::new());
23 // Mutable borrow of a type with drop impl.
26 let mut y
= Some(String
::new());
31 let _z
= x
; //~ ERROR destructors cannot be evaluated
34 // Shared borrow of a type that might be !Freeze and Drop.
35 pub const fn g1
<T
>() {
36 let x
: Option
<T
> = None
; //~ ERROR destructors cannot be evaluated
40 // Shared borrow of a type that might be !Freeze and Drop.
41 pub const fn g2
<T
>() {
42 let x
: Option
<T
> = None
;
44 let _y
= x
; //~ ERROR destructors cannot be evaluated
47 // Mutable raw reference to a Drop type.
48 pub const fn address_of_mut() {
49 let mut x
: Option
<String
> = None
; //~ ERROR destructors cannot be evaluated
52 let mut y
: Option
<String
> = None
; //~ ERROR destructors cannot be evaluated
53 std
::ptr
::addr_of_mut
!(y
);
56 // Const raw reference to a Drop type. Conservatively assumed to allow mutation
57 // until resolution of https://github.com/rust-lang/rust/issues/56604.
58 pub const fn address_of_const() {
59 let x
: Option
<String
> = None
; //~ ERROR destructors cannot be evaluated
62 let y
: Option
<String
> = None
; //~ ERROR destructors cannot be evaluated
63 std
::ptr
::addr_of
!(y
);