const-eval interner: from-scratch rewrite using mutability information from provenance rather than types
This commit is contained in:
parent
a58ec8ff03
commit
2f1a8e2d7a
52 changed files with 1093 additions and 688 deletions
|
|
@ -5,6 +5,7 @@
|
|||
use std::intrinsics;
|
||||
|
||||
const FOO: &i32 = foo();
|
||||
const FOO_RAW: *const i32 = foo();
|
||||
|
||||
const fn foo() -> &'static i32 {
|
||||
let t = unsafe {
|
||||
|
|
@ -15,5 +16,6 @@ const fn foo() -> &'static i32 {
|
|||
unsafe { &*t }
|
||||
}
|
||||
fn main() {
|
||||
assert_eq!(*FOO, 20)
|
||||
assert_eq!(*FOO, 20);
|
||||
assert_eq!(unsafe { *FOO_RAW }, 20);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
#![feature(core_intrinsics)]
|
||||
#![feature(const_heap)]
|
||||
#![feature(const_mut_refs)]
|
||||
use std::intrinsics;
|
||||
|
||||
const FOO: *const i32 = foo();
|
||||
//~^ ERROR unsupported untyped pointer in constant
|
||||
|
||||
const fn foo() -> &'static i32 {
|
||||
let t = unsafe {
|
||||
let i = intrinsics::const_allocate(4, 4) as *mut i32;
|
||||
*i = 20;
|
||||
i
|
||||
};
|
||||
unsafe { &*t }
|
||||
}
|
||||
fn main() {
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
error: unsupported untyped pointer in constant
|
||||
--> $DIR/alloc_intrinsic_nontransient_fail.rs:6:1
|
||||
|
|
||||
LL | const FOO: *const i32 = foo();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: memory only reachable via raw pointers is not supported
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
@ -4,6 +4,6 @@
|
|||
use std::intrinsics;
|
||||
|
||||
const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32 };
|
||||
//~^ error: unsupported untyped pointer in constant
|
||||
//~^ error: mutable pointer in final value of constant
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
error: unsupported untyped pointer in constant
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/alloc_intrinsic_untyped.rs:6:1
|
||||
|
|
||||
LL | const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32 };
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: memory only reachable via raw pointers is not supported
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
use std::intrinsics;
|
||||
|
||||
const _X: &'static u8 = unsafe {
|
||||
//~^ error: dangling pointer in final constant
|
||||
//~^ error: dangling pointer in final value of constant
|
||||
let ptr = intrinsics::const_allocate(4, 4);
|
||||
intrinsics::const_deallocate(ptr, 4, 4);
|
||||
&*ptr
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: encountered dangling pointer in final constant
|
||||
error: encountered dangling pointer in final value of constant
|
||||
--> $DIR/dealloc_intrinsic_dangling.rs:7:1
|
||||
|
|
||||
LL | const _X: &'static u8 = unsafe {
|
||||
|
|
|
|||
|
|
@ -44,6 +44,21 @@ static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
|
|||
// the enclosing scope rule.
|
||||
const BAR: NotAMutex<&i32> = NotAMutex(UnsafeCell::new(&42));
|
||||
|
||||
struct SyncPtr<T> { x : *const T }
|
||||
unsafe impl<T> Sync for SyncPtr<T> {}
|
||||
|
||||
// These pass the lifetime checks because of the "tail expression" / "outer scope" rule.
|
||||
// (This relies on `SyncPtr` being a curly brace struct.)
|
||||
// However, we intern the inner memory as read-only, so this must be rejected.
|
||||
static RAW_MUT_CAST_S: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
|
||||
//~^ ERROR mutable references are not allowed
|
||||
static RAW_MUT_COERCE_S: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
||||
//~^ ERROR mutable references are not allowed
|
||||
const RAW_MUT_CAST_C: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
|
||||
//~^ ERROR mutable references are not allowed
|
||||
const RAW_MUT_COERCE_C: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
||||
//~^ ERROR mutable references are not allowed
|
||||
|
||||
fn main() {
|
||||
println!("{}", unsafe { *A });
|
||||
unsafe { *B = 4 } // Bad news
|
||||
|
|
|
|||
|
|
@ -54,7 +54,31 @@ LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
|
|||
| | creates a temporary value which is freed while still in use
|
||||
| using this value as a static requires that borrow lasts for `'static`
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error[E0764]: mutable references are not allowed in the final value of statics
|
||||
--> $DIR/mut_ref_in_final.rs:53:53
|
||||
|
|
||||
LL | static RAW_MUT_CAST_S: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0764]: mutable references are not allowed in the final value of statics
|
||||
--> $DIR/mut_ref_in_final.rs:55:54
|
||||
|
|
||||
LL | static RAW_MUT_COERCE_S: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
||||
| ^^^^^^
|
||||
|
||||
error[E0764]: mutable references are not allowed in the final value of constants
|
||||
--> $DIR/mut_ref_in_final.rs:57:52
|
||||
|
|
||||
LL | const RAW_MUT_CAST_C: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0764]: mutable references are not allowed in the final value of constants
|
||||
--> $DIR/mut_ref_in_final.rs:59:53
|
||||
|
|
||||
LL | const RAW_MUT_COERCE_C: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0716, E0764.
|
||||
For more information about an error, try `rustc --explain E0716`.
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mut_ref_in_final_dynamic_check.rs:17:1
|
||||
--> $DIR/mut_ref_in_final_dynamic_check.rs:15:1
|
||||
|
|
||||
LL | const A: Option<&mut i32> = helper();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0: encountered mutable reference in a `const`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0: encountered mutable reference in a `const` or `static`
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 4, align: 4) {
|
||||
2a 00 00 00 │ *...
|
||||
}
|
||||
|
||||
error: encountered dangling pointer in final constant
|
||||
--> $DIR/mut_ref_in_final_dynamic_check.rs:24:1
|
||||
error: encountered dangling pointer in final value of constant
|
||||
--> $DIR/mut_ref_in_final_dynamic_check.rs:22:1
|
||||
|
|
||||
LL | const B: Option<&mut i32> = helper2();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mut_ref_in_final_dynamic_check.rs:17:1
|
||||
--> $DIR/mut_ref_in_final_dynamic_check.rs:15:1
|
||||
|
|
||||
LL | const A: Option<&mut i32> = helper();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0: encountered mutable reference in a `const`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0: encountered mutable reference in a `const` or `static`
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 8, align: 8) {
|
||||
2a 00 00 00 00 00 00 00 │ *.......
|
||||
}
|
||||
|
||||
error: encountered dangling pointer in final constant
|
||||
--> $DIR/mut_ref_in_final_dynamic_check.rs:24:1
|
||||
error: encountered dangling pointer in final value of constant
|
||||
--> $DIR/mut_ref_in_final_dynamic_check.rs:22:1
|
||||
|
|
||||
LL | const B: Option<&mut i32> = helper2();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ const fn helper() -> Option<&'static mut i32> { unsafe {
|
|||
// Undefined behaviour (integer as pointer), who doesn't love tests like this.
|
||||
Some(&mut *(42 as *mut i32))
|
||||
} }
|
||||
// The error is an evaluation error and not a validation error, so the error is reported
|
||||
// directly at the site where it occurs.
|
||||
const A: Option<&mut i32> = helper(); //~ ERROR it is undefined behavior to use this value
|
||||
//~^ encountered mutable reference in a `const`
|
||||
|
||||
|
|
@ -21,6 +19,6 @@ const fn helper2() -> Option<&'static mut i32> { unsafe {
|
|||
// Undefined behaviour (dangling pointer), who doesn't love tests like this.
|
||||
Some(&mut *(&mut 42 as *mut i32))
|
||||
} }
|
||||
const B: Option<&mut i32> = helper2(); //~ ERROR encountered dangling pointer in final constant
|
||||
const B: Option<&mut i32> = helper2(); //~ ERROR encountered dangling pointer in final value of constant
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/const-points-to-static.rs:6:1
|
||||
|
|
||||
LL | const TEST: &u8 = &MY_STATIC;
|
||||
| ^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 4, align: 4) {
|
||||
╾ALLOC0<imm>╼ │ ╾──╼
|
||||
}
|
||||
|
||||
warning: skipping const checks
|
||||
|
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/const-points-to-static.rs:6:20
|
||||
|
|
||||
LL | const TEST: &u8 = &MY_STATIC;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/const-points-to-static.rs:6:1
|
||||
|
|
||||
LL | const TEST: &u8 = &MY_STATIC;
|
||||
| ^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 8, align: 8) {
|
||||
╾ALLOC0<imm>╼ │ ╾──────╼
|
||||
}
|
||||
|
||||
warning: skipping const checks
|
||||
|
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/const-points-to-static.rs:6:20
|
||||
|
|
||||
LL | const TEST: &u8 = &MY_STATIC;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
// compile-flags: -Zunleash-the-miri-inside-of-you
|
||||
// stderr-per-bitwidth
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
const TEST: &u8 = &MY_STATIC;
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
//~| encountered a reference pointing to a static variable
|
||||
|
||||
static MY_STATIC: u8 = 4;
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ union Foo<'a> {
|
|||
}
|
||||
|
||||
const FOO: &() = {
|
||||
//~^ ERROR encountered dangling pointer in final constant
|
||||
//~^ ERROR encountered dangling pointer in final value of constant
|
||||
let y = ();
|
||||
unsafe { Foo { y: &y }.long_live_the_unit }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: encountered dangling pointer in final constant
|
||||
error: encountered dangling pointer in final value of constant
|
||||
--> $DIR/dangling-alloc-id-ice.rs:8:1
|
||||
|
|
||||
LL | const FOO: &() = {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const FOO: *const u32 = { //~ ERROR encountered dangling pointer in final constant
|
||||
const FOO: *const u32 = { //~ ERROR encountered dangling pointer in final value of constant
|
||||
let x = 42;
|
||||
&x
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: encountered dangling pointer in final constant
|
||||
error: encountered dangling pointer in final value of constant
|
||||
--> $DIR/dangling_raw_ptr.rs:1:1
|
||||
|
|
||||
LL | const FOO: *const u32 = {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/invalid-union.rs:35:1
|
||||
--> $DIR/interior-mut-const-via-union.rs:35:1
|
||||
|
|
||||
LL | fn main() {
|
||||
| ^^^^^^^^^ constructing invalid value at .<deref>.y.<enum-variant(B)>.0: encountered `UnsafeCell` in a `const`
|
||||
| ^^^^^^^^^ constructing invalid value at .<deref>.y.<enum-variant(B)>.0: encountered `UnsafeCell` in read-only memory
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 4, align: 4) {
|
||||
|
|
@ -10,13 +10,13 @@ LL | fn main() {
|
|||
}
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/invalid-union.rs:37:25
|
||||
--> $DIR/interior-mut-const-via-union.rs:37:25
|
||||
|
|
||||
LL | let _: &'static _ = &C;
|
||||
| ^^
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/invalid-union.rs:37:25
|
||||
--> $DIR/interior-mut-const-via-union.rs:37:25
|
||||
|
|
||||
LL | let _: &'static _ = &C;
|
||||
| ^^
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/invalid-union.rs:35:1
|
||||
--> $DIR/interior-mut-const-via-union.rs:35:1
|
||||
|
|
||||
LL | fn main() {
|
||||
| ^^^^^^^^^ constructing invalid value at .<deref>.y.<enum-variant(B)>.0: encountered `UnsafeCell` in a `const`
|
||||
| ^^^^^^^^^ constructing invalid value at .<deref>.y.<enum-variant(B)>.0: encountered `UnsafeCell` in read-only memory
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 8, align: 8) {
|
||||
|
|
@ -10,13 +10,13 @@ LL | fn main() {
|
|||
}
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/invalid-union.rs:37:25
|
||||
--> $DIR/interior-mut-const-via-union.rs:37:25
|
||||
|
|
||||
LL | let _: &'static _ = &C;
|
||||
| ^^
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/invalid-union.rs:37:25
|
||||
--> $DIR/interior-mut-const-via-union.rs:37:25
|
||||
|
|
||||
LL | let _: &'static _ = &C;
|
||||
| ^^
|
||||
|
|
@ -38,6 +38,17 @@ LL | const READ_IMMUT: &usize = {
|
|||
╾ALLOC1<imm>╼ │ ╾──╼
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/const_refers_to_static.rs:34:1
|
||||
|
|
||||
LL | const REF_IMMUT: &u8 = &MY_STATIC;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 4, align: 4) {
|
||||
╾ALLOC2<imm>╼ │ ╾──╼
|
||||
}
|
||||
|
||||
warning: skipping const checks
|
||||
|
|
||||
help: skipping check that does not even have a feature gate
|
||||
|
|
@ -75,7 +86,12 @@ help: skipping check that does not even have a feature gate
|
|||
|
|
||||
LL | &FOO
|
||||
| ^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/const_refers_to_static.rs:34:25
|
||||
|
|
||||
LL | const REF_IMMUT: &u8 = &MY_STATIC;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 5 previous errors; 1 warning emitted
|
||||
error: aborting due to 6 previous errors; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -38,6 +38,17 @@ LL | const READ_IMMUT: &usize = {
|
|||
╾ALLOC1<imm>╼ │ ╾──────╼
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/const_refers_to_static.rs:34:1
|
||||
|
|
||||
LL | const REF_IMMUT: &u8 = &MY_STATIC;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 8, align: 8) {
|
||||
╾ALLOC2<imm>╼ │ ╾──────╼
|
||||
}
|
||||
|
||||
warning: skipping const checks
|
||||
|
|
||||
help: skipping check that does not even have a feature gate
|
||||
|
|
@ -75,7 +86,12 @@ help: skipping check that does not even have a feature gate
|
|||
|
|
||||
LL | &FOO
|
||||
| ^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/const_refers_to_static.rs:34:25
|
||||
|
|
||||
LL | const REF_IMMUT: &u8 = &MY_STATIC;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 5 previous errors; 1 warning emitted
|
||||
error: aborting due to 6 previous errors; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -30,4 +30,9 @@ const READ_IMMUT: &usize = { //~ ERROR it is undefined behavior to use this valu
|
|||
&FOO
|
||||
};
|
||||
|
||||
static MY_STATIC: u8 = 4;
|
||||
const REF_IMMUT: &u8 = &MY_STATIC;
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
//~| encountered a reference pointing to a static variable
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,54 +1,199 @@
|
|||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mutable_references_err.rs:15:1
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:17:1
|
||||
|
|
||||
LL | const MUH: Meh = Meh {
|
||||
| ^^^^^^^^^^^^^^ constructing invalid value at .x.<deref>: encountered `UnsafeCell` in a `const`
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:27:1
|
||||
|
|
||||
LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mutable_references_err.rs:32:1
|
||||
|
|
||||
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` or `static`
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 4, align: 4) {
|
||||
╾ALLOC0╼ │ ╾──╼
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mutable_references_err.rs:25:1
|
||||
|
|
||||
LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>.x: encountered `UnsafeCell` in a `const`
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 8, align: 4) {
|
||||
╾ALLOC1╼ ╾ALLOC2╼ │ ╾──╼╾──╼
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mutable_references_err.rs:29:1
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:35:1
|
||||
|
|
||||
LL | const BLUNT: &mut i32 = &mut 42;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mutable_references_err.rs:40:1
|
||||
|
|
||||
LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 4, align: 4) {
|
||||
╾ALLOC3╼ │ ╾──╼
|
||||
╾ALLOC1<imm>╼ │ ╾──╼
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mutable_references_err.rs:47:1
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 4, align: 4) {
|
||||
╾ALLOC2<imm>╼ │ ╾──╼
|
||||
}
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/mutable_references_err.rs:51:43
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
|
||||
| ^^^^^^^^^^^^^ constant accesses static
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:55:1
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:57:1
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:59:1
|
||||
|
|
||||
LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:69:1
|
||||
|
|
||||
LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:71:1
|
||||
|
|
||||
LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:73:1
|
||||
|
|
||||
LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: skipping const checks
|
||||
|
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:16:8
|
||||
--> $DIR/mutable_references_err.rs:18:8
|
||||
|
|
||||
LL | x: &UnsafeCell::new(42),
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:25:27
|
||||
--> $DIR/mutable_references_err.rs:27:27
|
||||
|
|
||||
LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:29:25
|
||||
--> $DIR/mutable_references_err.rs:32:40
|
||||
|
|
||||
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
|
||||
| ^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:32:40
|
||||
|
|
||||
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
|
||||
| ^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:32:35
|
||||
|
|
||||
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
|
||||
| ^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:35:25
|
||||
|
|
||||
LL | const BLUNT: &mut i32 = &mut 42;
|
||||
| ^^^^^^^
|
||||
help: skipping check for `const_mut_refs` feature
|
||||
--> $DIR/mutable_references_err.rs:40:49
|
||||
|
|
||||
LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check for `const_mut_refs` feature
|
||||
--> $DIR/mutable_references_err.rs:40:49
|
||||
|
|
||||
LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:40:49
|
||||
|
|
||||
LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:47:44
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
|
||||
| ^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:47:44
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
|
||||
| ^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:50:36
|
||||
|
|
||||
LL | static mut MUTABLE_REF: &mut i32 = &mut 42;
|
||||
| ^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:51:45
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
|
||||
| ^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:51:45
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
|
||||
| ^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:55:45
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _;
|
||||
| ^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:57:46
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _;
|
||||
| ^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:59:47
|
||||
|
|
||||
LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:69:51
|
||||
|
|
||||
LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:71:50
|
||||
|
|
||||
LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
|
||||
| ^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:73:51
|
||||
|
|
||||
LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors; 1 warning emitted
|
||||
error: aborting due to 13 previous errors; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -1,54 +1,199 @@
|
|||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mutable_references_err.rs:15:1
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:17:1
|
||||
|
|
||||
LL | const MUH: Meh = Meh {
|
||||
| ^^^^^^^^^^^^^^ constructing invalid value at .x.<deref>: encountered `UnsafeCell` in a `const`
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:27:1
|
||||
|
|
||||
LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mutable_references_err.rs:32:1
|
||||
|
|
||||
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` or `static`
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 8, align: 8) {
|
||||
╾ALLOC0╼ │ ╾──────╼
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mutable_references_err.rs:25:1
|
||||
|
|
||||
LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>.x: encountered `UnsafeCell` in a `const`
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 16, align: 8) {
|
||||
╾ALLOC1╼ ╾ALLOC2╼ │ ╾──────╼╾──────╼
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mutable_references_err.rs:29:1
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:35:1
|
||||
|
|
||||
LL | const BLUNT: &mut i32 = &mut 42;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mutable_references_err.rs:40:1
|
||||
|
|
||||
LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 8, align: 8) {
|
||||
╾ALLOC3╼ │ ╾──────╼
|
||||
╾ALLOC1<imm>╼ │ ╾──────╼
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mutable_references_err.rs:47:1
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 8, align: 8) {
|
||||
╾ALLOC2<imm>╼ │ ╾──────╼
|
||||
}
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/mutable_references_err.rs:51:43
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
|
||||
| ^^^^^^^^^^^^^ constant accesses static
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:55:1
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:57:1
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:59:1
|
||||
|
|
||||
LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:69:1
|
||||
|
|
||||
LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:71:1
|
||||
|
|
||||
LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:73:1
|
||||
|
|
||||
LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: skipping const checks
|
||||
|
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:16:8
|
||||
--> $DIR/mutable_references_err.rs:18:8
|
||||
|
|
||||
LL | x: &UnsafeCell::new(42),
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:25:27
|
||||
--> $DIR/mutable_references_err.rs:27:27
|
||||
|
|
||||
LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:29:25
|
||||
--> $DIR/mutable_references_err.rs:32:40
|
||||
|
|
||||
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
|
||||
| ^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:32:40
|
||||
|
|
||||
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
|
||||
| ^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:32:35
|
||||
|
|
||||
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
|
||||
| ^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:35:25
|
||||
|
|
||||
LL | const BLUNT: &mut i32 = &mut 42;
|
||||
| ^^^^^^^
|
||||
help: skipping check for `const_mut_refs` feature
|
||||
--> $DIR/mutable_references_err.rs:40:49
|
||||
|
|
||||
LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check for `const_mut_refs` feature
|
||||
--> $DIR/mutable_references_err.rs:40:49
|
||||
|
|
||||
LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:40:49
|
||||
|
|
||||
LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:47:44
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
|
||||
| ^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:47:44
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
|
||||
| ^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:50:36
|
||||
|
|
||||
LL | static mut MUTABLE_REF: &mut i32 = &mut 42;
|
||||
| ^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:51:45
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
|
||||
| ^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:51:45
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
|
||||
| ^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:55:45
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _;
|
||||
| ^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:57:46
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _;
|
||||
| ^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:59:47
|
||||
|
|
||||
LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:69:51
|
||||
|
|
||||
LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:71:50
|
||||
|
|
||||
LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
|
||||
| ^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:73:51
|
||||
|
|
||||
LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors; 1 warning emitted
|
||||
error: aborting due to 13 previous errors; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// stderr-per-bitwidth
|
||||
// compile-flags: -Zunleash-the-miri-inside-of-you
|
||||
#![allow(invalid_reference_casting, static_mut_ref)]
|
||||
|
||||
use std::sync::atomic::*;
|
||||
use std::cell::UnsafeCell;
|
||||
|
||||
// this test ensures that our mutability story is sound
|
||||
|
|
@ -12,7 +14,7 @@ unsafe impl Sync for Meh {}
|
|||
|
||||
// the following will never be ok! no interior mut behind consts, because
|
||||
// all allocs interned here will be marked immutable.
|
||||
const MUH: Meh = Meh { //~ ERROR: it is undefined behavior to use this value
|
||||
const MUH: Meh = Meh { //~ ERROR: mutable pointer in final value
|
||||
x: &UnsafeCell::new(42),
|
||||
};
|
||||
|
||||
|
|
@ -23,11 +25,53 @@ unsafe impl Sync for Synced {}
|
|||
|
||||
// Make sure we also catch this behind a type-erased `dyn Trait` reference.
|
||||
const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
|
||||
//~^ ERROR: it is undefined behavior to use this value
|
||||
//~^ ERROR: mutable pointer in final value
|
||||
|
||||
// Make sure we also catch mutable references.
|
||||
const BLUNT: &mut i32 = &mut 42;
|
||||
// Make sure we also catch mutable references in values that shouldn't have them.
|
||||
static mut FOO: i32 = 0;
|
||||
const SUBTLE: &mut i32 = unsafe { &mut FOO };
|
||||
//~^ ERROR: it is undefined behavior to use this value
|
||||
//~| static
|
||||
const BLUNT: &mut i32 = &mut 42;
|
||||
//~^ ERROR: mutable pointer in final value
|
||||
|
||||
// Check for mutable references to read-only memory.
|
||||
static READONLY: i32 = 0;
|
||||
static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
|
||||
//~^ ERROR: it is undefined behavior to use this value
|
||||
//~| pointing to read-only memory
|
||||
|
||||
// Check for consts pointing to mutable memory.
|
||||
// Currently it's not even possible to create such a const.
|
||||
static mut MUTABLE: i32 = 42;
|
||||
const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
|
||||
//~^ ERROR: undefined behavior to use this value
|
||||
//~| pointing to a static
|
||||
static mut MUTABLE_REF: &mut i32 = &mut 42;
|
||||
const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
|
||||
//~^ ERROR: evaluation of constant value failed
|
||||
//~| accesses static
|
||||
|
||||
const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _;
|
||||
//~^ ERROR: mutable pointer in final value
|
||||
const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _;
|
||||
//~^ ERROR: mutable pointer in final value
|
||||
const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
|
||||
//~^ ERROR: mutable pointer in final value
|
||||
|
||||
struct SyncPtr<T> { x : *const T }
|
||||
unsafe impl<T> Sync for SyncPtr<T> {}
|
||||
|
||||
// These pass the lifetime checks because of the "tail expression" / "outer scope" rule.
|
||||
// (This relies on `SyncPtr` being a curly brace struct.)
|
||||
// However, we intern the inner memory as read-only, so this must be rejected.
|
||||
// (Also see `static-no-inner-mut` for similar tests on `static`.)
|
||||
const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
|
||||
//~^ ERROR mutable pointer in final value
|
||||
const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
|
||||
//~^ ERROR mutable pointer in final value
|
||||
const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
||||
//~^ ERROR mutable pointer in final value
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
// compile-flags: -Zunleash-the-miri-inside-of-you
|
||||
|
||||
use std::cell::UnsafeCell;
|
||||
|
||||
const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
|
||||
//~^ ERROR: unsupported untyped pointer in constant
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
error: unsupported untyped pointer in constant
|
||||
--> $DIR/raw_mutable_const.rs:5:1
|
||||
|
|
||||
LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: memory only reachable via raw pointers is not supported
|
||||
|
||||
warning: skipping const checks
|
||||
|
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/raw_mutable_const.rs:5:38
|
||||
|
|
||||
LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error; 1 warning emitted
|
||||
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
error: encountered mutable pointer in final value of static
|
||||
--> $DIR/static-no-inner-mut.rs:9:1
|
||||
|
|
||||
LL | static REF: &AtomicI32 = &AtomicI32::new(42);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of static
|
||||
--> $DIR/static-no-inner-mut.rs:10:1
|
||||
|
|
||||
LL | static REFMUT: &mut i32 = &mut 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of static
|
||||
--> $DIR/static-no-inner-mut.rs:13:1
|
||||
|
|
||||
LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}};
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of static
|
||||
--> $DIR/static-no-inner-mut.rs:14:1
|
||||
|
|
||||
LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}};
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of static
|
||||
--> $DIR/static-no-inner-mut.rs:29:1
|
||||
|
|
||||
LL | static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of static
|
||||
--> $DIR/static-no-inner-mut.rs:31:1
|
||||
|
|
||||
LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of static
|
||||
--> $DIR/static-no-inner-mut.rs:33:1
|
||||
|
|
||||
LL | static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: skipping const checks
|
||||
|
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/static-no-inner-mut.rs:9:26
|
||||
|
|
||||
LL | static REF: &AtomicI32 = &AtomicI32::new(42);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/static-no-inner-mut.rs:10:27
|
||||
|
|
||||
LL | static REFMUT: &mut i32 = &mut 0;
|
||||
| ^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/static-no-inner-mut.rs:13:56
|
||||
|
|
||||
LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}};
|
||||
| ^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/static-no-inner-mut.rs:14:44
|
||||
|
|
||||
LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}};
|
||||
| ^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/static-no-inner-mut.rs:29:52
|
||||
|
|
||||
LL | static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/static-no-inner-mut.rs:31:51
|
||||
|
|
||||
LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
|
||||
| ^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/static-no-inner-mut.rs:33:52
|
||||
|
|
||||
LL | static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 7 previous errors; 1 warning emitted
|
||||
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
error: encountered mutable pointer in final value of static
|
||||
--> $DIR/static-no-inner-mut.rs:9:1
|
||||
|
|
||||
LL | static REF: &AtomicI32 = &AtomicI32::new(42);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of static
|
||||
--> $DIR/static-no-inner-mut.rs:10:1
|
||||
|
|
||||
LL | static REFMUT: &mut i32 = &mut 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of static
|
||||
--> $DIR/static-no-inner-mut.rs:13:1
|
||||
|
|
||||
LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}};
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of static
|
||||
--> $DIR/static-no-inner-mut.rs:14:1
|
||||
|
|
||||
LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}};
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of static
|
||||
--> $DIR/static-no-inner-mut.rs:29:1
|
||||
|
|
||||
LL | static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of static
|
||||
--> $DIR/static-no-inner-mut.rs:31:1
|
||||
|
|
||||
LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of static
|
||||
--> $DIR/static-no-inner-mut.rs:33:1
|
||||
|
|
||||
LL | static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: skipping const checks
|
||||
|
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/static-no-inner-mut.rs:9:26
|
||||
|
|
||||
LL | static REF: &AtomicI32 = &AtomicI32::new(42);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/static-no-inner-mut.rs:10:27
|
||||
|
|
||||
LL | static REFMUT: &mut i32 = &mut 0;
|
||||
| ^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/static-no-inner-mut.rs:13:56
|
||||
|
|
||||
LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}};
|
||||
| ^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/static-no-inner-mut.rs:14:44
|
||||
|
|
||||
LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}};
|
||||
| ^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/static-no-inner-mut.rs:29:52
|
||||
|
|
||||
LL | static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/static-no-inner-mut.rs:31:51
|
||||
|
|
||||
LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
|
||||
| ^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/static-no-inner-mut.rs:33:52
|
||||
|
|
||||
LL | static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 7 previous errors; 1 warning emitted
|
||||
|
||||
36
tests/ui/consts/miri_unleashed/static-no-inner-mut.rs
Normal file
36
tests/ui/consts/miri_unleashed/static-no-inner-mut.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
// stderr-per-bitwidth
|
||||
// compile-flags: -Zunleash-the-miri-inside-of-you
|
||||
#![feature(const_refs_to_cell, const_mut_refs)]
|
||||
// All "inner" allocations that come with a `static` are interned immutably. This means it is
|
||||
// crucial that we do not accept any form of (interior) mutability there.
|
||||
|
||||
use std::sync::atomic::*;
|
||||
|
||||
static REF: &AtomicI32 = &AtomicI32::new(42); //~ERROR mutable pointer in final value
|
||||
static REFMUT: &mut i32 = &mut 0; //~ERROR mutable pointer in final value
|
||||
|
||||
// Different way of writing this that avoids promotion.
|
||||
static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}}; //~ERROR mutable pointer in final value
|
||||
static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; //~ERROR mutable pointer in final value
|
||||
|
||||
// This one is obvious, since it is non-Sync. (It also suppresses the other errors, so it is
|
||||
// commented out.)
|
||||
// static RAW: *const AtomicI32 = &AtomicI32::new(42);
|
||||
|
||||
struct SyncPtr<T> { x : *const T }
|
||||
unsafe impl<T> Sync for SyncPtr<T> {}
|
||||
|
||||
// All of these pass the lifetime checks because of the "tail expression" / "outer scope" rule.
|
||||
// (This relies on `SyncPtr` being a curly brace struct.)
|
||||
// Then they get interned immutably, which is not great.
|
||||
// `mut_ref_in_final.rs` and `std/cell.rs` ensure that we don't accept this even with the feature
|
||||
// fate, but for unleashed Miri there's not really any way we can reject them: it's just
|
||||
// non-dangling raw pointers.
|
||||
static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
|
||||
//~^ ERROR mutable pointer in final value
|
||||
static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
|
||||
//~^ ERROR mutable pointer in final value
|
||||
static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
||||
//~^ ERROR mutable pointer in final value
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
// check-pass
|
||||
|
||||
// This is a regression test for a `span_delayed_bug` during interning when a constant
|
||||
// evaluates to a (non-dangling) raw pointer. For now this errors; potentially it
|
||||
// could also be allowed.
|
||||
// evaluates to a (non-dangling) raw pointer.
|
||||
|
||||
const CONST_RAW: *const Vec<i32> = &Vec::new() as *const _;
|
||||
//~^ ERROR unsupported untyped pointer in constant
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
error: unsupported untyped pointer in constant
|
||||
--> $DIR/raw-ptr-const.rs:5:1
|
||||
|
|
||||
LL | const CONST_RAW: *const Vec<i32> = &Vec::new() as *const _;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: memory only reachable via raw pointers is not supported
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
6
tests/ui/consts/raw-ptr-temp-const.rs
Normal file
6
tests/ui/consts/raw-ptr-temp-const.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// A variant of raw-ptr-const that directly constructs a raw pointer.
|
||||
|
||||
const CONST_RAW: *const Vec<i32> = std::ptr::addr_of!(Vec::new());
|
||||
//~^ ERROR cannot take address of a temporary
|
||||
|
||||
fn main() {}
|
||||
9
tests/ui/consts/raw-ptr-temp-const.stderr
Normal file
9
tests/ui/consts/raw-ptr-temp-const.stderr
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
error[E0745]: cannot take address of a temporary
|
||||
--> $DIR/raw-ptr-temp-const.rs:3:55
|
||||
|
|
||||
LL | const CONST_RAW: *const Vec<i32> = std::ptr::addr_of!(Vec::new());
|
||||
| ^^^^^^^^^^ temporary value
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0745`.
|
||||
18
tests/ui/consts/refs-to-cell-in-final.rs
Normal file
18
tests/ui/consts/refs-to-cell-in-final.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#![feature(const_refs_to_cell)]
|
||||
|
||||
use std::cell::*;
|
||||
|
||||
struct SyncPtr<T> { x : *const T }
|
||||
unsafe impl<T> Sync for SyncPtr<T> {}
|
||||
|
||||
// These pass the lifetime checks because of the "tail expression" / "outer scope" rule.
|
||||
// (This relies on `SyncPtr` being a curly brace struct.)
|
||||
// However, we intern the inner memory as read-only.
|
||||
// The resulting constant would pass all validation checks, so it is crucial that this gets rejected
|
||||
// by static const checks!
|
||||
static RAW_SYNC_S: SyncPtr<Cell<i32>> = SyncPtr { x: &Cell::new(42) };
|
||||
//~^ ERROR: cannot refer to interior mutable data
|
||||
const RAW_SYNC_C: SyncPtr<Cell<i32>> = SyncPtr { x: &Cell::new(42) };
|
||||
//~^ ERROR: cannot refer to interior mutable data
|
||||
|
||||
fn main() {}
|
||||
17
tests/ui/consts/refs-to-cell-in-final.stderr
Normal file
17
tests/ui/consts/refs-to-cell-in-final.stderr
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
error[E0492]: statics cannot refer to interior mutable data
|
||||
--> $DIR/refs-to-cell-in-final.rs:13:54
|
||||
|
|
||||
LL | static RAW_SYNC_S: SyncPtr<Cell<i32>> = SyncPtr { x: &Cell::new(42) };
|
||||
| ^^^^^^^^^^^^^^ this borrow of an interior mutable value may end up in the final value
|
||||
|
|
||||
= help: to fix this, the value can be extracted to a separate `static` item and then referenced
|
||||
|
||||
error[E0492]: constants cannot refer to interior mutable data
|
||||
--> $DIR/refs-to-cell-in-final.rs:15:53
|
||||
|
|
||||
LL | const RAW_SYNC_C: SyncPtr<Cell<i32>> = SyncPtr { x: &Cell::new(42) };
|
||||
| ^^^^^^^^^^^^^^ this borrow of an interior mutable value may end up in the final value
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0492`.
|
||||
|
|
@ -1,22 +1,22 @@
|
|||
error: encountered dangling pointer in final constant
|
||||
error: encountered dangling pointer in final value of static
|
||||
--> $DIR/cell.rs:6:1
|
||||
|
|
||||
LL | static FOO: Wrap<*mut u32> = Wrap(Cell::new(42).as_ptr());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered dangling pointer in final constant
|
||||
error: encountered dangling pointer in final value of constant
|
||||
--> $DIR/cell.rs:8:1
|
||||
|
|
||||
LL | const FOO_CONST: Wrap<*mut u32> = Wrap(Cell::new(42).as_ptr());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered dangling pointer in final constant
|
||||
error: encountered dangling pointer in final value of constant
|
||||
--> $DIR/cell.rs:22:1
|
||||
|
|
||||
LL | const FOO4_CONST: Wrap<*mut u32> = Wrap(FOO3_CONST.0.as_ptr());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered dangling pointer in final constant
|
||||
error: encountered dangling pointer in final value of constant
|
||||
--> $DIR/cell.rs:27:1
|
||||
|
|
||||
LL | const FOO2: *mut u32 = Cell::new(42).as_ptr();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue