stabilize const_mut_refs
This commit is contained in:
parent
4f1be92153
commit
3175cc2814
152 changed files with 286 additions and 1376 deletions
|
|
@ -1,5 +1,4 @@
|
|||
#![allow(incomplete_features)]
|
||||
#![feature(const_mut_refs)]
|
||||
#![feature(adt_const_params, unsized_const_params)]
|
||||
|
||||
struct T<const B: &'static bool>;
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/issue-100313.rs:10:13
|
||||
--> $DIR/issue-100313.rs:9:13
|
||||
|
|
||||
LL | *(B as *const bool as *mut bool) = false;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ writing to ALLOC0 which is read-only
|
||||
|
|
||||
note: inside `T::<&true>::set_false`
|
||||
--> $DIR/issue-100313.rs:10:13
|
||||
--> $DIR/issue-100313.rs:9:13
|
||||
|
|
||||
LL | *(B as *const bool as *mut bool) = false;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: inside `_`
|
||||
--> $DIR/issue-100313.rs:18:5
|
||||
--> $DIR/issue-100313.rs:17:5
|
||||
|
|
||||
LL | x.set_false();
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@
|
|||
// See also ../const-mut-refs-crate.rs for more details
|
||||
// about this test.
|
||||
|
||||
#![feature(const_mut_refs)]
|
||||
|
||||
// if we used immutable references here, then promotion would
|
||||
// turn the `&42` into a promoted, which gets duplicated arbitrarily.
|
||||
pub static mut FOO: &'static mut i32 = &mut 42;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
const A: () = { let mut x = 2; &raw mut x; }; //~ mutable pointer
|
||||
//@check-pass
|
||||
|
||||
static B: () = { let mut x = 2; &raw mut x; }; //~ mutable pointer
|
||||
const A: () = { let mut x = 2; &raw mut x; };
|
||||
|
||||
static B: () = { let mut x = 2; &raw mut x; };
|
||||
|
||||
const fn foo() {
|
||||
let mut x = 0;
|
||||
let y = &raw mut x; //~ mutable pointer
|
||||
let y = &raw mut x;
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
error[E0658]: raw mutable pointers are not allowed in constants
|
||||
--> $DIR/const-address-of-mut.rs:1:32
|
||||
|
|
||||
LL | const A: () = { let mut x = 2; &raw mut x; };
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: raw mutable pointers are not allowed in statics
|
||||
--> $DIR/const-address-of-mut.rs:3:33
|
||||
|
|
||||
LL | static B: () = { let mut x = 2; &raw mut x; };
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: raw mutable pointers are not allowed in constant functions
|
||||
--> $DIR/const-address-of-mut.rs:7:13
|
||||
|
|
||||
LL | let y = &raw mut x;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
#![feature(core_intrinsics)]
|
||||
#![feature(const_heap)]
|
||||
#![feature(const_mut_refs)]
|
||||
use std::intrinsics;
|
||||
|
||||
const FOO: i32 = foo();
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/alloc_intrinsic_errors.rs:9:17
|
||||
--> $DIR/alloc_intrinsic_errors.rs:8:17
|
||||
|
|
||||
LL | let _ = intrinsics::const_allocate(4, 3) as *mut i32;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid align passed to `const_allocate`: 3 is not a power of 2
|
||||
|
|
||||
note: inside `foo`
|
||||
--> $DIR/alloc_intrinsic_errors.rs:9:17
|
||||
--> $DIR/alloc_intrinsic_errors.rs:8:17
|
||||
|
|
||||
LL | let _ = intrinsics::const_allocate(4, 3) as *mut i32;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: inside `FOO`
|
||||
--> $DIR/alloc_intrinsic_errors.rs:6:18
|
||||
--> $DIR/alloc_intrinsic_errors.rs:5:18
|
||||
|
|
||||
LL | const FOO: i32 = foo();
|
||||
| ^^^^^
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
//@ run-pass
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(const_heap)]
|
||||
#![feature(const_mut_refs)]
|
||||
use std::intrinsics;
|
||||
|
||||
const FOO: &i32 = foo();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
//@ run-pass
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(const_heap)]
|
||||
#![feature(const_mut_refs)]
|
||||
use std::intrinsics;
|
||||
|
||||
const FOO: i32 = foo();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/alloc_intrinsic_uninit.rs:8:1
|
||||
--> $DIR/alloc_intrinsic_uninit.rs:7:1
|
||||
|
|
||||
LL | const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) };
|
||||
| ^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered uninitialized memory, but expected an integer
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/alloc_intrinsic_uninit.rs:8:1
|
||||
--> $DIR/alloc_intrinsic_uninit.rs:7:1
|
||||
|
|
||||
LL | const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) };
|
||||
| ^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered uninitialized memory, but expected an integer
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
// compile-test
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(const_heap)]
|
||||
#![feature(const_mut_refs)]
|
||||
use std::intrinsics;
|
||||
|
||||
const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) };
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
// We unleash Miri here since this test demonstrates code that bypasses the checks against interning
|
||||
// mutable pointers, which currently ICEs. Unleashing Miri silence the ICE.
|
||||
// mutable pointers, which currently ICEs. Unleashing Miri silences the ICE.
|
||||
//@ compile-flags: -Zunleash-the-miri-inside-of-you
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(const_heap)]
|
||||
#![feature(const_mut_refs)]
|
||||
use std::intrinsics;
|
||||
|
||||
const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32 };
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/alloc_intrinsic_untyped.rs:9:1
|
||||
--> $DIR/alloc_intrinsic_untyped.rs:8:1
|
||||
|
|
||||
LL | const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32 };
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
//@ run-pass
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(const_heap)]
|
||||
#![feature(const_mut_refs)]
|
||||
|
||||
use std::intrinsics;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#![feature(core_intrinsics)]
|
||||
#![feature(const_heap)]
|
||||
#![feature(const_mut_refs)]
|
||||
|
||||
// Strip out raw byte dumps to make comparison platform-independent:
|
||||
//@ normalize-stderr-test: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/dealloc_intrinsic_dangling.rs:12:1
|
||||
--> $DIR/dealloc_intrinsic_dangling.rs:11:1
|
||||
|
|
||||
LL | const _X: &'static u8 = unsafe {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (use-after-free)
|
||||
|
|
@ -10,7 +10,7 @@ LL | const _X: &'static u8 = unsafe {
|
|||
}
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/dealloc_intrinsic_dangling.rs:23:5
|
||||
--> $DIR/dealloc_intrinsic_dangling.rs:22:5
|
||||
|
|
||||
LL | *reference
|
||||
| ^^^^^^^^^^ memory access failed: ALLOC1 has been freed, so this pointer is dangling
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
// This checks that function pointer signatures that are referenced mutably
|
||||
// but contain a &mut T parameter still fail in a constant context: see issue #114994.
|
||||
//
|
||||
//@ check-fail
|
||||
|
||||
const fn use_mut_const_fn(_f: &mut fn(&mut String)) { //~ ERROR mutable references are not allowed in constant functions
|
||||
()
|
||||
}
|
||||
|
||||
const fn use_mut_const_tuple_fn(_f: (fn(), &mut u32)) { //~ ERROR mutable references are not allowed in constant functions
|
||||
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/issue-114994-fail.rs:6:27
|
||||
|
|
||||
LL | const fn use_mut_const_fn(_f: &mut fn(&mut String)) {
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/issue-114994-fail.rs:10:33
|
||||
|
|
||||
LL | const fn use_mut_const_tuple_fn(_f: (fn(), &mut u32)) {
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
// This checks that function pointer signatures containing &mut T types
|
||||
// work in a constant context: see issue #114994.
|
||||
//
|
||||
//@ check-pass
|
||||
|
||||
const fn use_const_fn(_f: fn(&mut String)) {
|
||||
()
|
||||
}
|
||||
|
||||
const fn get_some_fn() -> fn(&mut String) {
|
||||
String::clear
|
||||
}
|
||||
|
||||
const fn some_const_fn() {
|
||||
let _f: fn(&mut String) = String::clear;
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,11 +1,16 @@
|
|||
//@ revisions: stock precise_drops
|
||||
//@[precise_drops] check-pass
|
||||
|
||||
// This test originated from #65394. We conservatively assume that `x` is still `LiveDrop` even
|
||||
// after it has been moved because a mutable reference to it exists at some point in the const body.
|
||||
//
|
||||
// We will likely have to change this behavior before we allow `&mut` in a `const`.
|
||||
// With `&mut` in `const` being stable, this surprising behavior is now observable.
|
||||
// `const_precise_live_drops` fixes that.
|
||||
#![cfg_attr(precise_drops, feature(const_precise_live_drops))]
|
||||
|
||||
const _: Vec<i32> = {
|
||||
let mut x = Vec::<i32>::new(); //~ ERROR destructor of
|
||||
let r = &mut x; //~ ERROR mutable references are not allowed in constants
|
||||
let mut x = Vec::<i32>::new(); //[stock]~ ERROR destructor of
|
||||
let r = &mut x;
|
||||
let y = x;
|
||||
y
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
error[E0658]: mutable references are not allowed in constants
|
||||
--> $DIR/issue-65394.rs:8:13
|
||||
|
|
||||
LL | let r = &mut x;
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0493]: destructor of `Vec<i32>` cannot be evaluated at compile-time
|
||||
--> $DIR/issue-65394.rs:7:9
|
||||
|
|
||||
LL | let mut x = Vec::<i32>::new();
|
||||
| ^^^^^ the destructor for this type cannot be evaluated in constants
|
||||
...
|
||||
LL | };
|
||||
| - value is dropped here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0493, E0658.
|
||||
For more information about an error, try `rustc --explain E0493`.
|
||||
12
tests/ui/consts/const-eval/issue-65394.stock.stderr
Normal file
12
tests/ui/consts/const-eval/issue-65394.stock.stderr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
error[E0493]: destructor of `Vec<i32>` cannot be evaluated at compile-time
|
||||
--> $DIR/issue-65394.rs:12:9
|
||||
|
|
||||
LL | let mut x = Vec::<i32>::new();
|
||||
| ^^^^^ the destructor for this type cannot be evaluated in constants
|
||||
...
|
||||
LL | };
|
||||
| - value is dropped here
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0493`.
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
// New test for #53818: modifying static memory at compile-time is not allowed.
|
||||
// The test should never compile successfully
|
||||
|
||||
#![feature(const_mut_refs)]
|
||||
|
||||
use std::cell::UnsafeCell;
|
||||
|
||||
struct Foo(UnsafeCell<u32>);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0080]: could not evaluate static initializer
|
||||
--> $DIR/mod-static-with-const-fn.rs:16:5
|
||||
--> $DIR/mod-static-with-const-fn.rs:14:5
|
||||
|
|
||||
LL | *FOO.0.get() = 5;
|
||||
| ^^^^^^^^^^^^^^^^ modifying a static's initial value from another static's initializer
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
// its address may be taken and it may be written to indirectly. Ensure that the const-eval
|
||||
// interpreter can handle this.
|
||||
|
||||
#![feature(const_mut_refs)]
|
||||
|
||||
#[inline(never)] // Try to ensure that MIR optimizations don't optimize this away.
|
||||
const fn init(buf: &mut [u8; 1024]) {
|
||||
buf[33] = 3;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
// Test for the behavior described in <https://github.com/rust-lang/rust/issues/87184>.
|
||||
#![feature(const_mut_refs)]
|
||||
|
||||
const PARTIAL_OVERWRITE: () = {
|
||||
let mut p = &42;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/partial_ptr_overwrite.rs:8:9
|
||||
--> $DIR/partial_ptr_overwrite.rs:7:9
|
||||
|
|
||||
LL | *(ptr as *mut u8) = 123;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ unable to overwrite parts of a pointer in memory at ALLOC0
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(const_mut_refs, const_intrinsic_copy)]
|
||||
#![feature(const_intrinsic_copy)]
|
||||
|
||||
|
||||
const MISALIGNED_LOAD: () = unsafe {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_mut_refs)]
|
||||
|
||||
enum E {
|
||||
A(u8),
|
||||
B,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/ub-enum-overwrite.rs:13:14
|
||||
--> $DIR/ub-enum-overwrite.rs:11:14
|
||||
|
|
||||
LL | unsafe { *p }
|
||||
| ^^ using uninitialized data, but this operation requires initialized memory
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
//! Ensure we catch UB due to writing through a shared reference.
|
||||
#![feature(const_mut_refs, const_refs_to_cell)]
|
||||
#![feature(const_refs_to_cell)]
|
||||
#![allow(invalid_reference_casting)]
|
||||
|
||||
use std::mem;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ const fn f(x: usize) -> usize {
|
|||
for i in 0..x {
|
||||
//~^ ERROR cannot convert
|
||||
//~| ERROR `for` is not allowed in a `const fn`
|
||||
//~| ERROR mutable references are not allowed in constant functions
|
||||
//~| ERROR cannot call non-const fn
|
||||
sum += i;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ LL | / for i in 0..x {
|
|||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | sum += i;
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
@ -28,16 +27,6 @@ help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
|
|||
LL + #![feature(const_trait_impl)]
|
||||
|
|
||||
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/const-fn-error.rs:5:14
|
||||
|
|
||||
LL | for i in 0..x {
|
||||
| ^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0015]: cannot call non-const fn `<std::ops::Range<usize> as Iterator>::next` in constant functions
|
||||
--> $DIR/const-fn-error.rs:5:14
|
||||
|
|
||||
|
|
@ -50,7 +39,7 @@ help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
|
|||
LL + #![feature(const_trait_impl)]
|
||||
|
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0015, E0658.
|
||||
For more information about an error, try `rustc --explain E0015`.
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ const _: () = {
|
|||
//~^ error: `for` is not allowed in a `const`
|
||||
//~| ERROR: cannot convert
|
||||
//~| ERROR: cannot call
|
||||
//~| ERROR: mutable references
|
||||
};
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -22,16 +22,6 @@ help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
|
|||
LL + #![feature(const_trait_impl)]
|
||||
|
|
||||
|
||||
error[E0658]: mutable references are not allowed in constants
|
||||
--> $DIR/const-for-feature-gate.rs:4:14
|
||||
|
|
||||
LL | for _ in 0..5 {}
|
||||
| ^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0015]: cannot call non-const fn `<std::ops::Range<i32> as Iterator>::next` in constants
|
||||
--> $DIR/const-for-feature-gate.rs:4:14
|
||||
|
|
||||
|
|
@ -44,7 +34,7 @@ help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
|
|||
LL + #![feature(const_trait_impl)]
|
||||
|
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0015, E0658.
|
||||
For more information about an error, try `rustc --explain E0015`.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#![feature(const_for)]
|
||||
#![feature(const_mut_refs)]
|
||||
|
||||
const _: () = {
|
||||
for _ in 0..5 {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0015]: cannot convert `std::ops::Range<i32>` into an iterator in constants
|
||||
--> $DIR/const-for.rs:5:14
|
||||
--> $DIR/const-for.rs:4:14
|
||||
|
|
||||
LL | for _ in 0..5 {}
|
||||
| ^^^^
|
||||
|
|
@ -13,7 +13,7 @@ LL + #![feature(const_trait_impl)]
|
|||
|
|
||||
|
||||
error[E0015]: cannot call non-const fn `<std::ops::Range<i32> as Iterator>::next` in constants
|
||||
--> $DIR/const-for.rs:5:14
|
||||
--> $DIR/const-for.rs:4:14
|
||||
|
|
||||
LL | for _ in 0..5 {}
|
||||
| ^^^^
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
// Ensure that we point the user to the erroneous borrow but not to any subsequent borrows of that
|
||||
// initial one.
|
||||
|
||||
const _: i32 = {
|
||||
let mut a = 5;
|
||||
let p = &mut a; //~ ERROR mutable references are not allowed in constants
|
||||
|
||||
let reborrow = {p};
|
||||
let pp = &reborrow;
|
||||
let ppp = &pp;
|
||||
***ppp
|
||||
};
|
||||
|
||||
const _: std::cell::Cell<i32> = {
|
||||
let mut a = std::cell::Cell::new(5);
|
||||
let p = &a; //~ ERROR borrowed element may contain interior mutability
|
||||
|
||||
let reborrow = {p};
|
||||
let pp = &reborrow;
|
||||
let ppp = &pp;
|
||||
a
|
||||
};
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
error[E0658]: mutable references are not allowed in constants
|
||||
--> $DIR/const-multi-ref.rs:6:13
|
||||
|
|
||||
LL | let p = &mut a;
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: cannot borrow here, since the borrowed element may contain interior mutability
|
||||
--> $DIR/const-multi-ref.rs:16:13
|
||||
|
|
||||
LL | let p = &a;
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #80384 <https://github.com/rust-lang/rust/issues/80384> for more information
|
||||
= help: add `#![feature(const_refs_to_cell)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
//@ run-pass
|
||||
//@ aux-build:const_mut_refs_crate.rs
|
||||
|
||||
#![feature(const_mut_refs)]
|
||||
|
||||
//! Regression test for https://github.com/rust-lang/rust/issues/79738
|
||||
//! Show how we are not duplicating allocations anymore. Statics that
|
||||
//! copy their value from another static used to also duplicate
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
//@ check-pass
|
||||
#![feature(const_mut_refs)]
|
||||
|
||||
struct Foo {
|
||||
x: usize
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
//@ check-pass
|
||||
#![feature(const_mut_refs)]
|
||||
|
||||
use std::sync::Mutex;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
fn main() {
|
||||
foo(&mut 5);
|
||||
}
|
||||
|
||||
const fn foo(x: &mut i32) -> i32 { //~ ERROR mutable references
|
||||
*x + 1
|
||||
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/feature-gate-const_mut_refs.rs:5:14
|
||||
|
|
||||
LL | const fn foo(x: &mut i32) -> i32 {
|
||||
| ^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -2,7 +2,6 @@ use std::mem::{transmute, ManuallyDrop};
|
|||
|
||||
const S: &'static mut str = &mut " hello ";
|
||||
//~^ ERROR: mutable references are not allowed in the final value of constants
|
||||
//~| ERROR: mutation through a reference is not allowed in constants
|
||||
|
||||
const fn trigger() -> [(); unsafe {
|
||||
let s = transmute::<(*const u8, usize), &ManuallyDrop<str>>((S.as_ptr(), 3));
|
||||
|
|
|
|||
|
|
@ -4,17 +4,6 @@ error[E0764]: mutable references are not allowed in the final value of constants
|
|||
LL | const S: &'static mut str = &mut " hello ";
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error[E0658]: mutation through a reference is not allowed in constants
|
||||
--> $DIR/issue-76510.rs:3:29
|
||||
|
|
||||
LL | const S: &'static mut str = &mut " hello ";
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0658, E0764.
|
||||
For more information about an error, try `rustc --explain E0658`.
|
||||
For more information about this error, try `rustc --explain E0764`.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(const_mut_refs)]
|
||||
use std::cell::UnsafeCell;
|
||||
|
||||
const NULL: *mut i32 = std::ptr::null_mut();
|
||||
const A: *const i32 = &4;
|
||||
|
|
@ -25,7 +25,14 @@ const C: *const i32 = &{
|
|||
x
|
||||
};
|
||||
|
||||
use std::cell::UnsafeCell;
|
||||
// Still ok, since `x` will be moved before the final pointer is crated,
|
||||
// so `_ref` doesn't actually point to the memory that escapes.
|
||||
const C_NO: *const i32 = &{
|
||||
let mut x = 42;
|
||||
let _ref = &mut x;
|
||||
x
|
||||
};
|
||||
|
||||
struct NotAMutex<T>(UnsafeCell<T>);
|
||||
|
||||
unsafe impl<T> Sync for NotAMutex<T> {}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ LL | const B4: Option<&mut i32> = helper(&mut 42);
|
|||
| using this value as a constant requires that borrow lasts for `'static`
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/mut_ref_in_final.rs:33:65
|
||||
--> $DIR/mut_ref_in_final.rs:40:65
|
||||
|
|
||||
LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
|
||||
| -------------------------------^^--
|
||||
|
|
@ -35,7 +35,7 @@ LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
|
|||
| using this value as a constant requires that borrow lasts for `'static`
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/mut_ref_in_final.rs:36:67
|
||||
--> $DIR/mut_ref_in_final.rs:43:67
|
||||
|
|
||||
LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
|
||||
| -------------------------------^^--
|
||||
|
|
@ -45,7 +45,7 @@ LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
|
|||
| using this value as a static requires that borrow lasts for `'static`
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/mut_ref_in_final.rs:39:71
|
||||
--> $DIR/mut_ref_in_final.rs:46:71
|
||||
|
|
||||
LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
|
||||
| -------------------------------^^--
|
||||
|
|
@ -55,25 +55,25 @@ LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
|
|||
| using this value as a static requires that borrow lasts for `'static`
|
||||
|
||||
error[E0764]: mutable references are not allowed in the final value of statics
|
||||
--> $DIR/mut_ref_in_final.rs:52:53
|
||||
--> $DIR/mut_ref_in_final.rs:59: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:54:54
|
||||
--> $DIR/mut_ref_in_final.rs:61: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:56:52
|
||||
--> $DIR/mut_ref_in_final.rs:63: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:58:53
|
||||
--> $DIR/mut_ref_in_final.rs:65:53
|
||||
|
|
||||
LL | const RAW_MUT_COERCE_C: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
||||
| ^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//@ normalize-stderr-test: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
|
||||
//@ normalize-stderr-test: "( 0x[0-9a-f][0-9a-f] │)? ([0-9a-f][0-9a-f] |__ |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> " HEX_DUMP"
|
||||
//@ normalize-stderr-test: "HEX_DUMP\s*\n\s*HEX_DUMP" -> "HEX_DUMP"
|
||||
#![feature(const_mut_refs, const_refs_to_static)]
|
||||
#![feature(const_refs_to_static)]
|
||||
|
||||
use std::sync::Mutex;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//@check-pass
|
||||
//! This is the reduced version of the "Linux kernel vtable" use-case.
|
||||
#![feature(const_mut_refs, const_refs_to_static)]
|
||||
#![feature(const_refs_to_static)]
|
||||
use std::ptr::addr_of_mut;
|
||||
|
||||
#[repr(C)]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
use std::cell::Cell;
|
||||
|
||||
const WRITE: () = unsafe {
|
||||
*std::ptr::null_mut() = 0;
|
||||
//~^ ERROR dereferencing raw mutable pointers in constants is unstable
|
||||
//~| HELP add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
let x = Cell::new(0);
|
||||
let y = &x;
|
||||
//~^ ERROR interior mutability
|
||||
//~| HELP add `#![feature(const_refs_to_cell)]` to the crate attributes to enable
|
||||
};
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error[E0658]: dereferencing raw mutable pointers in constants is unstable
|
||||
--> $DIR/const-suggest-feature.rs:2:5
|
||||
error[E0658]: cannot borrow here, since the borrowed element may contain interior mutability
|
||||
--> $DIR/const-suggest-feature.rs:5:13
|
||||
|
|
||||
LL | *std::ptr::null_mut() = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | let y = &x;
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: see issue #80384 <https://github.com/rust-lang/rust/issues/80384> for more information
|
||||
= help: add `#![feature(const_refs_to_cell)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -1,23 +1,24 @@
|
|||
//@ check-pass
|
||||
|
||||
struct S {
|
||||
state: u32,
|
||||
}
|
||||
|
||||
impl S {
|
||||
const fn foo(&mut self, x: u32) {
|
||||
//~^ ERROR mutable reference
|
||||
self.state = x;
|
||||
}
|
||||
}
|
||||
|
||||
const FOO: S = {
|
||||
let mut s = S { state: 42 };
|
||||
s.foo(3); //~ ERROR mutable reference
|
||||
s.foo(3);
|
||||
s
|
||||
};
|
||||
|
||||
type Array = [u32; {
|
||||
let mut x = 2;
|
||||
let y = &mut x; //~ ERROR mutable reference
|
||||
let y = &mut x;
|
||||
*y = 42;
|
||||
*y
|
||||
}];
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
error[E0658]: mutable references are not allowed in constants
|
||||
--> $DIR/const_let_assign3.rs:14:5
|
||||
|
|
||||
LL | s.foo(3);
|
||||
| ^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/const_let_assign3.rs:6:18
|
||||
|
|
||||
LL | const fn foo(&mut self, x: u32) {
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: mutable references are not allowed in constants
|
||||
--> $DIR/const_let_assign3.rs:20:13
|
||||
|
|
||||
LL | let y = &mut x;
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
//@ normalize-stderr-test: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
|
||||
//@ normalize-stderr-test: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
|
||||
#![feature(const_refs_to_static, const_mut_refs, sync_unsafe_cell)]
|
||||
#![feature(const_refs_to_static, sync_unsafe_cell)]
|
||||
use std::cell::SyncUnsafeCell;
|
||||
|
||||
static S: SyncUnsafeCell<i32> = SyncUnsafeCell::new(0);
|
||||
|
|
|
|||
|
|
@ -52,14 +52,12 @@ const _: i32 = {
|
|||
|
||||
for i in 0..4 { //~ ERROR `for` is not allowed in a `const`
|
||||
//~^ ERROR: cannot call
|
||||
//~| ERROR: mutable references
|
||||
//~| ERROR: cannot convert
|
||||
x += i;
|
||||
}
|
||||
|
||||
for i in 0..4 { //~ ERROR `for` is not allowed in a `const`
|
||||
//~^ ERROR: cannot call
|
||||
//~| ERROR: mutable references
|
||||
//~| ERROR: cannot convert
|
||||
x += i;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ error[E0658]: `for` is not allowed in a `const`
|
|||
LL | / for i in 0..4 {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | x += i;
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
@ -14,12 +13,11 @@ LL | | }
|
|||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: `for` is not allowed in a `const`
|
||||
--> $DIR/loop.rs:60:5
|
||||
--> $DIR/loop.rs:59:5
|
||||
|
|
||||
LL | / for i in 0..4 {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | x += i;
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
@ -42,16 +40,6 @@ help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
|
|||
LL + #![feature(const_trait_impl)]
|
||||
|
|
||||
|
||||
error[E0658]: mutable references are not allowed in constants
|
||||
--> $DIR/loop.rs:53:14
|
||||
|
|
||||
LL | for i in 0..4 {
|
||||
| ^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0015]: cannot call non-const fn `<std::ops::Range<i32> as Iterator>::next` in constants
|
||||
--> $DIR/loop.rs:53:14
|
||||
|
|
||||
|
|
@ -65,7 +53,7 @@ LL + #![feature(const_trait_impl)]
|
|||
|
|
||||
|
||||
error[E0015]: cannot convert `std::ops::Range<i32>` into an iterator in constants
|
||||
--> $DIR/loop.rs:60:14
|
||||
--> $DIR/loop.rs:59:14
|
||||
|
|
||||
LL | for i in 0..4 {
|
||||
| ^^^^
|
||||
|
|
@ -78,18 +66,8 @@ help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
|
|||
LL + #![feature(const_trait_impl)]
|
||||
|
|
||||
|
||||
error[E0658]: mutable references are not allowed in constants
|
||||
--> $DIR/loop.rs:60:14
|
||||
|
|
||||
LL | for i in 0..4 {
|
||||
| ^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0015]: cannot call non-const fn `<std::ops::Range<i32> as Iterator>::next` in constants
|
||||
--> $DIR/loop.rs:60:14
|
||||
--> $DIR/loop.rs:59:14
|
||||
|
|
||||
LL | for i in 0..4 {
|
||||
| ^^^^
|
||||
|
|
@ -100,7 +78,7 @@ help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
|
|||
LL + #![feature(const_trait_impl)]
|
||||
|
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0015, E0658.
|
||||
For more information about an error, try `rustc --explain E0015`.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
// ignore-tidy-linelength
|
||||
#![feature(intrinsics, staged_api)]
|
||||
#![feature(const_mut_refs)]
|
||||
use std::mem;
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/copy-intrinsic.rs:29:5
|
||||
--> $DIR/copy-intrinsic.rs:28:5
|
||||
|
|
||||
LL | copy_nonoverlapping(0x100 as *const i32, dangle, 1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got 0x100[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/copy-intrinsic.rs:38:5
|
||||
--> $DIR/copy-intrinsic.rs:37:5
|
||||
|
|
||||
LL | copy_nonoverlapping(dangle, 0x100 as *mut i32, 1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x28 which is at or beyond the end of the allocation of size 4 bytes
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/copy-intrinsic.rs:45:5
|
||||
--> $DIR/copy-intrinsic.rs:44:5
|
||||
|
|
||||
LL | copy(&x, &mut y, 1usize << (mem::size_of::<usize>() * 8 - 1));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy`
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/copy-intrinsic.rs:51:5
|
||||
--> $DIR/copy-intrinsic.rs:50:5
|
||||
|
|
||||
LL | copy_nonoverlapping(&x, &mut y, 1usize << (mem::size_of::<usize>() * 8 - 1));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy_nonoverlapping`
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
#![feature(fn_traits)]
|
||||
#![feature(unboxed_closures)]
|
||||
#![feature(const_trait_impl)]
|
||||
#![feature(const_mut_refs)]
|
||||
#![feature(const_cmp)]
|
||||
#![feature(const_refs_to_cell)]
|
||||
|
||||
|
|
|
|||
|
|
@ -5,25 +5,25 @@ LL | #![feature(const_fn_trait_ref_impls)]
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0635]: unknown feature `const_cmp`
|
||||
--> $DIR/fn_trait_refs.rs:8:12
|
||||
--> $DIR/fn_trait_refs.rs:7:12
|
||||
|
|
||||
LL | #![feature(const_cmp)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:15:15
|
||||
--> $DIR/fn_trait_refs.rs:14:15
|
||||
|
|
||||
LL | T: ~const Fn<()> + ~const Destruct,
|
||||
| ^^^^^^
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:15:31
|
||||
--> $DIR/fn_trait_refs.rs:14:31
|
||||
|
|
||||
LL | T: ~const Fn<()> + ~const Destruct,
|
||||
| ^^^^^^^^
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:15:15
|
||||
--> $DIR/fn_trait_refs.rs:14:15
|
||||
|
|
||||
LL | T: ~const Fn<()> + ~const Destruct,
|
||||
| ^^^^^^
|
||||
|
|
@ -31,19 +31,19 @@ LL | T: ~const Fn<()> + ~const Destruct,
|
|||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:22:15
|
||||
--> $DIR/fn_trait_refs.rs:21:15
|
||||
|
|
||||
LL | T: ~const FnMut<()> + ~const Destruct,
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:22:34
|
||||
--> $DIR/fn_trait_refs.rs:21:34
|
||||
|
|
||||
LL | T: ~const FnMut<()> + ~const Destruct,
|
||||
| ^^^^^^^^
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:22:15
|
||||
--> $DIR/fn_trait_refs.rs:21:15
|
||||
|
|
||||
LL | T: ~const FnMut<()> + ~const Destruct,
|
||||
| ^^^^^^^^^
|
||||
|
|
@ -51,13 +51,13 @@ LL | T: ~const FnMut<()> + ~const Destruct,
|
|||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:29:15
|
||||
--> $DIR/fn_trait_refs.rs:28:15
|
||||
|
|
||||
LL | T: ~const FnOnce<()>,
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:29:15
|
||||
--> $DIR/fn_trait_refs.rs:28:15
|
||||
|
|
||||
LL | T: ~const FnOnce<()>,
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -65,19 +65,19 @@ LL | T: ~const FnOnce<()>,
|
|||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:36:15
|
||||
--> $DIR/fn_trait_refs.rs:35:15
|
||||
|
|
||||
LL | T: ~const Fn<()> + ~const Destruct,
|
||||
| ^^^^^^
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:36:31
|
||||
--> $DIR/fn_trait_refs.rs:35:31
|
||||
|
|
||||
LL | T: ~const Fn<()> + ~const Destruct,
|
||||
| ^^^^^^^^
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:36:15
|
||||
--> $DIR/fn_trait_refs.rs:35:15
|
||||
|
|
||||
LL | T: ~const Fn<()> + ~const Destruct,
|
||||
| ^^^^^^
|
||||
|
|
@ -85,19 +85,19 @@ LL | T: ~const Fn<()> + ~const Destruct,
|
|||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:50:15
|
||||
--> $DIR/fn_trait_refs.rs:49:15
|
||||
|
|
||||
LL | T: ~const FnMut<()> + ~const Destruct,
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:50:34
|
||||
--> $DIR/fn_trait_refs.rs:49:34
|
||||
|
|
||||
LL | T: ~const FnMut<()> + ~const Destruct,
|
||||
| ^^^^^^^^
|
||||
|
||||
error: `~const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/fn_trait_refs.rs:50:15
|
||||
--> $DIR/fn_trait_refs.rs:49:15
|
||||
|
|
||||
LL | T: ~const FnMut<()> + ~const Destruct,
|
||||
| ^^^^^^^^^
|
||||
|
|
@ -105,7 +105,7 @@ LL | T: ~const FnMut<()> + ~const Destruct,
|
|||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error[E0015]: cannot call non-const operator in constants
|
||||
--> $DIR/fn_trait_refs.rs:72:17
|
||||
--> $DIR/fn_trait_refs.rs:71:17
|
||||
|
|
||||
LL | assert!(test_one == (1, 1, 1));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -117,7 +117,7 @@ LL + #![feature(effects)]
|
|||
|
|
||||
|
||||
error[E0015]: cannot call non-const operator in constants
|
||||
--> $DIR/fn_trait_refs.rs:75:17
|
||||
--> $DIR/fn_trait_refs.rs:74:17
|
||||
|
|
||||
LL | assert!(test_two == (2, 2));
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -129,7 +129,7 @@ LL + #![feature(effects)]
|
|||
|
|
||||
|
||||
error[E0015]: cannot call non-const closure in constant functions
|
||||
--> $DIR/fn_trait_refs.rs:17:5
|
||||
--> $DIR/fn_trait_refs.rs:16:5
|
||||
|
|
||||
LL | f()
|
||||
| ^^^
|
||||
|
|
@ -145,7 +145,7 @@ LL + #![feature(effects)]
|
|||
|
|
||||
|
||||
error[E0493]: destructor of `T` cannot be evaluated at compile-time
|
||||
--> $DIR/fn_trait_refs.rs:13:23
|
||||
--> $DIR/fn_trait_refs.rs:12:23
|
||||
|
|
||||
LL | const fn tester_fn<T>(f: T) -> T::Output
|
||||
| ^ the destructor for this type cannot be evaluated in constant functions
|
||||
|
|
@ -154,7 +154,7 @@ LL | }
|
|||
| - value is dropped here
|
||||
|
||||
error[E0015]: cannot call non-const closure in constant functions
|
||||
--> $DIR/fn_trait_refs.rs:24:5
|
||||
--> $DIR/fn_trait_refs.rs:23:5
|
||||
|
|
||||
LL | f()
|
||||
| ^^^
|
||||
|
|
@ -170,7 +170,7 @@ LL + #![feature(effects)]
|
|||
|
|
||||
|
||||
error[E0493]: destructor of `T` cannot be evaluated at compile-time
|
||||
--> $DIR/fn_trait_refs.rs:20:27
|
||||
--> $DIR/fn_trait_refs.rs:19:27
|
||||
|
|
||||
LL | const fn tester_fn_mut<T>(mut f: T) -> T::Output
|
||||
| ^^^^^ the destructor for this type cannot be evaluated in constant functions
|
||||
|
|
@ -179,7 +179,7 @@ LL | }
|
|||
| - value is dropped here
|
||||
|
||||
error[E0015]: cannot call non-const closure in constant functions
|
||||
--> $DIR/fn_trait_refs.rs:31:5
|
||||
--> $DIR/fn_trait_refs.rs:30:5
|
||||
|
|
||||
LL | f()
|
||||
| ^^^
|
||||
|
|
@ -195,7 +195,7 @@ LL + #![feature(effects)]
|
|||
|
|
||||
|
||||
error[E0493]: destructor of `T` cannot be evaluated at compile-time
|
||||
--> $DIR/fn_trait_refs.rs:34:21
|
||||
--> $DIR/fn_trait_refs.rs:33:21
|
||||
|
|
||||
LL | const fn test_fn<T>(mut f: T) -> (T::Output, T::Output, T::Output)
|
||||
| ^^^^^ the destructor for this type cannot be evaluated in constant functions
|
||||
|
|
@ -204,7 +204,7 @@ LL | }
|
|||
| - value is dropped here
|
||||
|
||||
error[E0493]: destructor of `T` cannot be evaluated at compile-time
|
||||
--> $DIR/fn_trait_refs.rs:48:25
|
||||
--> $DIR/fn_trait_refs.rs:47:25
|
||||
|
|
||||
LL | const fn test_fn_mut<T>(mut f: T) -> (T::Output, T::Output)
|
||||
| ^^^^^ the destructor for this type cannot be evaluated in constant functions
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/interior-mut-const-via-union.rs:35:1
|
||||
--> $DIR/interior-mut-const-via-union.rs:34:1
|
||||
|
|
||||
LL | fn main() {
|
||||
| ^^^^^^^^^ constructing invalid value at .<deref>.y.<enum-variant(B)>.0: encountered `UnsafeCell` in read-only memory
|
||||
|
|
@ -10,13 +10,13 @@ LL | fn main() {
|
|||
}
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/interior-mut-const-via-union.rs:37:25
|
||||
--> $DIR/interior-mut-const-via-union.rs:36:25
|
||||
|
|
||||
LL | let _: &'static _ = &C;
|
||||
| ^^
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/interior-mut-const-via-union.rs:37:25
|
||||
--> $DIR/interior-mut-const-via-union.rs:36:25
|
||||
|
|
||||
LL | let _: &'static _ = &C;
|
||||
| ^^
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/interior-mut-const-via-union.rs:35:1
|
||||
--> $DIR/interior-mut-const-via-union.rs:34:1
|
||||
|
|
||||
LL | fn main() {
|
||||
| ^^^^^^^^^ constructing invalid value at .<deref>.y.<enum-variant(B)>.0: encountered `UnsafeCell` in read-only memory
|
||||
|
|
@ -10,13 +10,13 @@ LL | fn main() {
|
|||
}
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/interior-mut-const-via-union.rs:37:25
|
||||
--> $DIR/interior-mut-const-via-union.rs:36:25
|
||||
|
|
||||
LL | let _: &'static _ = &C;
|
||||
| ^^
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/interior-mut-const-via-union.rs:37:25
|
||||
--> $DIR/interior-mut-const-via-union.rs:36:25
|
||||
|
|
||||
LL | let _: &'static _ = &C;
|
||||
| ^^
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
//
|
||||
//@ build-fail
|
||||
//@ stderr-per-bitwidth
|
||||
#![feature(const_mut_refs)]
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::mem::ManuallyDrop;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,5 @@ const C1: &'static mut [usize] = &mut [];
|
|||
static mut S: usize = 3;
|
||||
const C2: &'static mut usize = unsafe { &mut S };
|
||||
//~^ ERROR: referencing statics in constants
|
||||
//~| ERROR: mutable references are not allowed
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -16,17 +16,7 @@ LL | const C2: &'static mut usize = unsafe { &mut S };
|
|||
= note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
|
||||
= help: to fix this, the value can be extracted to a `const` and then used.
|
||||
|
||||
error[E0658]: mutable references are not allowed in constants
|
||||
--> $DIR/issue-17718-const-bad-values.rs:7:41
|
||||
|
|
||||
LL | const C2: &'static mut usize = unsafe { &mut S };
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0658, E0764.
|
||||
For more information about an error, try `rustc --explain E0658`.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
//@ run-pass
|
||||
|
||||
#![feature(const_ptr_write)]
|
||||
#![feature(const_mut_refs)]
|
||||
|
||||
// Or, equivalently: `MaybeUninit`.
|
||||
pub union BagOfBits<T: Copy> {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
//@ check-pass
|
||||
|
||||
#![feature(const_swap)]
|
||||
#![feature(const_mut_refs)]
|
||||
|
||||
#[repr(C)]
|
||||
struct Demo(u64, bool, u64, u32, u64, u64, u64);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//@ known-bug: #103507
|
||||
|
||||
#![feature(const_trait_impl, const_mut_refs)]
|
||||
#![feature(const_trait_impl)]
|
||||
|
||||
struct Foo<'a> {
|
||||
bar: &'a mut Vec<usize>,
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
const fn mutable_address_of_in_const() {
|
||||
let mut a = 0;
|
||||
let b = &raw mut a; //~ ERROR mutable pointer
|
||||
}
|
||||
|
||||
struct X;
|
||||
|
||||
impl X {
|
||||
const fn inherent_mutable_address_of_in_const() {
|
||||
let mut a = 0;
|
||||
let b = &raw mut a; //~ ERROR mutable pointer
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
error[E0658]: raw mutable pointers are not allowed in constant functions
|
||||
--> $DIR/address_of.rs:3:13
|
||||
|
|
||||
LL | let b = &raw mut a;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: raw mutable pointers are not allowed in constant functions
|
||||
--> $DIR/address_of.rs:11:17
|
||||
|
|
||||
LL | let b = &raw mut a;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -37,34 +37,22 @@ impl<T> Foo<T> {
|
|||
const fn into_inner(self) -> T { self.0 } //~ destructor of
|
||||
const fn get(&self) -> &T { &self.0 }
|
||||
const fn get_mut(&mut self) -> &mut T { &mut self.0 }
|
||||
//~^ mutable references
|
||||
//~| mutable references
|
||||
//~| mutable references
|
||||
}
|
||||
impl<'a, T> Foo<T> {
|
||||
const fn new_lt(t: T) -> Self { Foo(t) }
|
||||
const fn into_inner_lt(self) -> T { self.0 } //~ destructor of
|
||||
const fn get_lt(&'a self) -> &T { &self.0 } //~ WARNING elided lifetime has a name
|
||||
const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 } //~ WARNING elided lifetime has a name
|
||||
//~^ mutable references
|
||||
//~| mutable references
|
||||
//~| mutable references
|
||||
const fn get_lt(&self) -> &T { &self.0 }
|
||||
const fn get_mut_lt(&mut self) -> &mut T { &mut self.0 }
|
||||
}
|
||||
impl<T: Sized> Foo<T> {
|
||||
const fn new_s(t: T) -> Self { Foo(t) }
|
||||
const fn into_inner_s(self) -> T { self.0 } //~ ERROR destructor
|
||||
const fn get_s(&self) -> &T { &self.0 }
|
||||
const fn get_mut_s(&mut self) -> &mut T { &mut self.0 }
|
||||
//~^ mutable references
|
||||
//~| mutable references
|
||||
//~| mutable references
|
||||
}
|
||||
impl<T: ?Sized> Foo<T> {
|
||||
const fn get_sq(&self) -> &T { &self.0 }
|
||||
const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 }
|
||||
//~^ mutable references
|
||||
//~| mutable references
|
||||
//~| mutable references
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -98,7 +86,6 @@ const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } }
|
|||
//~^ ERROR pointers cannot be cast to integers
|
||||
const fn foo30_6() -> bool { let x = true; x }
|
||||
const fn inc(x: &mut i32) { *x += 1 }
|
||||
//~^ ERROR mutable references
|
||||
|
||||
// ok
|
||||
const fn foo36(a: bool, b: bool) -> bool { a && b }
|
||||
|
|
|
|||
|
|
@ -1,23 +1,3 @@
|
|||
warning: elided lifetime has a name
|
||||
--> $DIR/min_const_fn.rs:47:34
|
||||
|
|
||||
LL | impl<'a, T> Foo<T> {
|
||||
| -- lifetime `'a` declared here
|
||||
...
|
||||
LL | const fn get_lt(&'a self) -> &T { &self.0 }
|
||||
| ^ this elided lifetime gets resolved as `'a`
|
||||
|
|
||||
= note: `#[warn(elided_named_lifetimes)]` on by default
|
||||
|
||||
warning: elided lifetime has a name
|
||||
--> $DIR/min_const_fn.rs:48:42
|
||||
|
|
||||
LL | impl<'a, T> Foo<T> {
|
||||
| -- lifetime `'a` declared here
|
||||
...
|
||||
LL | const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 }
|
||||
| ^ this elided lifetime gets resolved as `'a`
|
||||
|
||||
error[E0493]: destructor of `Foo<T>` cannot be evaluated at compile-time
|
||||
--> $DIR/min_const_fn.rs:37:25
|
||||
|
|
||||
|
|
@ -26,144 +6,24 @@ LL | const fn into_inner(self) -> T { self.0 }
|
|||
| |
|
||||
| the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/min_const_fn.rs:39:22
|
||||
|
|
||||
LL | const fn get_mut(&mut self) -> &mut T { &mut self.0 }
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/min_const_fn.rs:39:36
|
||||
|
|
||||
LL | const fn get_mut(&mut self) -> &mut T { &mut self.0 }
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/min_const_fn.rs:39:45
|
||||
|
|
||||
LL | const fn get_mut(&mut self) -> &mut T { &mut self.0 }
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0493]: destructor of `Foo<T>` cannot be evaluated at compile-time
|
||||
--> $DIR/min_const_fn.rs:46:28
|
||||
--> $DIR/min_const_fn.rs:43:28
|
||||
|
|
||||
LL | const fn into_inner_lt(self) -> T { self.0 }
|
||||
| ^^^^ - value is dropped here
|
||||
| |
|
||||
| the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/min_const_fn.rs:48:25
|
||||
|
|
||||
LL | const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 }
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/min_const_fn.rs:48:42
|
||||
|
|
||||
LL | const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 }
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/min_const_fn.rs:48:51
|
||||
|
|
||||
LL | const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 }
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0493]: destructor of `Foo<T>` cannot be evaluated at compile-time
|
||||
--> $DIR/min_const_fn.rs:55:27
|
||||
--> $DIR/min_const_fn.rs:49:27
|
||||
|
|
||||
LL | const fn into_inner_s(self) -> T { self.0 }
|
||||
| ^^^^ - value is dropped here
|
||||
| |
|
||||
| the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/min_const_fn.rs:57:24
|
||||
|
|
||||
LL | const fn get_mut_s(&mut self) -> &mut T { &mut self.0 }
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/min_const_fn.rs:57:38
|
||||
|
|
||||
LL | const fn get_mut_s(&mut self) -> &mut T { &mut self.0 }
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/min_const_fn.rs:57:47
|
||||
|
|
||||
LL | const fn get_mut_s(&mut self) -> &mut T { &mut self.0 }
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/min_const_fn.rs:64:25
|
||||
|
|
||||
LL | const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 }
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/min_const_fn.rs:64:39
|
||||
|
|
||||
LL | const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 }
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/min_const_fn.rs:64:48
|
||||
|
|
||||
LL | const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 }
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: referencing statics in constant functions is unstable
|
||||
--> $DIR/min_const_fn.rs:89:27
|
||||
--> $DIR/min_const_fn.rs:77:27
|
||||
|
|
||||
LL | const fn foo25() -> u32 { BAR }
|
||||
| ^^^
|
||||
|
|
@ -175,7 +35,7 @@ LL | const fn foo25() -> u32 { BAR }
|
|||
= help: to fix this, the value can be extracted to a `const` and then used.
|
||||
|
||||
error[E0658]: referencing statics in constant functions is unstable
|
||||
--> $DIR/min_const_fn.rs:90:37
|
||||
--> $DIR/min_const_fn.rs:78:37
|
||||
|
|
||||
LL | const fn foo26() -> &'static u32 { &BAR }
|
||||
| ^^^
|
||||
|
|
@ -187,7 +47,7 @@ LL | const fn foo26() -> &'static u32 { &BAR }
|
|||
= help: to fix this, the value can be extracted to a `const` and then used.
|
||||
|
||||
error: pointers cannot be cast to integers during const eval
|
||||
--> $DIR/min_const_fn.rs:91:42
|
||||
--> $DIR/min_const_fn.rs:79:42
|
||||
|
|
||||
LL | const fn foo30(x: *const u32) -> usize { x as usize }
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -196,7 +56,7 @@ LL | const fn foo30(x: *const u32) -> usize { x as usize }
|
|||
= note: avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior
|
||||
|
||||
error: pointers cannot be cast to integers during const eval
|
||||
--> $DIR/min_const_fn.rs:93:63
|
||||
--> $DIR/min_const_fn.rs:81:63
|
||||
|
|
||||
LL | const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize } }
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -205,7 +65,7 @@ LL | const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize }
|
|||
= note: avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior
|
||||
|
||||
error: pointers cannot be cast to integers during const eval
|
||||
--> $DIR/min_const_fn.rs:95:42
|
||||
--> $DIR/min_const_fn.rs:83:42
|
||||
|
|
||||
LL | const fn foo30_2(x: *mut u32) -> usize { x as usize }
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -214,7 +74,7 @@ LL | const fn foo30_2(x: *mut u32) -> usize { x as usize }
|
|||
= note: avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior
|
||||
|
||||
error: pointers cannot be cast to integers during const eval
|
||||
--> $DIR/min_const_fn.rs:97:63
|
||||
--> $DIR/min_const_fn.rs:85:63
|
||||
|
|
||||
LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } }
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -222,18 +82,8 @@ LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize }
|
|||
= note: at compile-time, pointers do not have an integer value
|
||||
= note: avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior
|
||||
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/min_const_fn.rs:100:14
|
||||
|
|
||||
LL | const fn inc(x: &mut i32) { *x += 1 }
|
||||
| ^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0493]: destructor of `AlanTuring<impl std::fmt::Debug>` cannot be evaluated at compile-time
|
||||
--> $DIR/min_const_fn.rs:122:19
|
||||
--> $DIR/min_const_fn.rs:109:19
|
||||
|
|
||||
LL | const fn no_apit2(_x: AlanTuring<impl std::fmt::Debug>) {}
|
||||
| ^^ - value is dropped here
|
||||
|
|
@ -241,14 +91,14 @@ LL | const fn no_apit2(_x: AlanTuring<impl std::fmt::Debug>) {}
|
|||
| the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error[E0493]: destructor of `impl std::fmt::Debug` cannot be evaluated at compile-time
|
||||
--> $DIR/min_const_fn.rs:124:18
|
||||
--> $DIR/min_const_fn.rs:111:18
|
||||
|
|
||||
LL | const fn no_apit(_x: impl std::fmt::Debug) {}
|
||||
| ^^ - value is dropped here
|
||||
| |
|
||||
| the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error: aborting due to 24 previous errors; 2 warnings emitted
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0493, E0658.
|
||||
For more information about an error, try `rustc --explain E0493`.
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
const fn bad_const_fn_deref_raw(x: *mut usize) -> &'static usize { unsafe { &*x } }
|
||||
//~^ dereferencing raw mutable pointers in constant functions
|
||||
|
||||
const unsafe fn bad_const_unsafe_deref_raw(x: *mut usize) -> usize { *x }
|
||||
//~^ dereferencing raw mutable pointers in constant functions
|
||||
|
||||
const unsafe fn bad_const_unsafe_deref_raw_ref(x: *mut usize) -> &'static usize { &*x }
|
||||
//~^ dereferencing raw mutable pointers in constant functions
|
||||
|
||||
const unsafe fn bad_const_unsafe_deref_raw_underscore(x: *mut usize) { let _ = *x; }
|
||||
//~^ dereferencing raw mutable pointers in constant functions
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
error[E0658]: dereferencing raw mutable pointers in constant functions is unstable
|
||||
--> $DIR/min_const_fn_unsafe_bad.rs:1:77
|
||||
|
|
||||
LL | const fn bad_const_fn_deref_raw(x: *mut usize) -> &'static usize { unsafe { &*x } }
|
||||
| ^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: dereferencing raw mutable pointers in constant functions is unstable
|
||||
--> $DIR/min_const_fn_unsafe_bad.rs:4:70
|
||||
|
|
||||
LL | const unsafe fn bad_const_unsafe_deref_raw(x: *mut usize) -> usize { *x }
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: dereferencing raw mutable pointers in constant functions is unstable
|
||||
--> $DIR/min_const_fn_unsafe_bad.rs:7:83
|
||||
|
|
||||
LL | const unsafe fn bad_const_unsafe_deref_raw_ref(x: *mut usize) -> &'static usize { &*x }
|
||||
| ^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: dereferencing raw mutable pointers in constant functions is unstable
|
||||
--> $DIR/min_const_fn_unsafe_bad.rs:10:80
|
||||
|
|
||||
LL | const unsafe fn bad_const_unsafe_deref_raw_underscore(x: *mut usize) { let _ = *x; }
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -41,4 +41,12 @@ const unsafe fn call_unsafe_generic_cell_const_unsafe_fn_immediate()
|
|||
ret_null_mut_ptr_no_unsafe::<Vec<std::cell::Cell<u32>>>()
|
||||
}
|
||||
|
||||
const fn bad_const_fn_deref_raw(x: *mut usize) -> &'static usize { unsafe { &*x } }
|
||||
|
||||
const unsafe fn bad_const_unsafe_deref_raw(x: *mut usize) -> usize { *x }
|
||||
|
||||
const unsafe fn bad_const_unsafe_deref_raw_ref(x: *mut usize) -> &'static usize { &*x }
|
||||
|
||||
const unsafe fn bad_const_unsafe_deref_raw_underscore(x: *mut usize) { let _ = *x; }
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
const fn mutable_ref_in_const() -> u8 {
|
||||
let mut a = 0;
|
||||
let b = &mut a; //~ ERROR mutable references
|
||||
*b
|
||||
}
|
||||
|
||||
struct X;
|
||||
|
||||
impl X {
|
||||
const fn inherent_mutable_ref_in_const() -> u8 {
|
||||
let mut a = 0;
|
||||
let b = &mut a; //~ ERROR mutable references
|
||||
*b
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/mutable_borrow.rs:3:13
|
||||
|
|
||||
LL | let b = &mut a;
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: mutable references are not allowed in constant functions
|
||||
--> $DIR/mutable_borrow.rs:12:17
|
||||
|
|
||||
LL | let b = &mut a;
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -11,16 +11,6 @@ help: skipping check that does not even have a feature gate
|
|||
|
|
||||
LL | &mut *(Box::new(0))
|
||||
| ^^^^^^^^^^^^^
|
||||
help: skipping check for `const_mut_refs` feature
|
||||
--> $DIR/box.rs:8:5
|
||||
|
|
||||
LL | &mut *(Box::new(0))
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check for `const_mut_refs` feature
|
||||
--> $DIR/box.rs:8:5
|
||||
|
|
||||
LL | &mut *(Box::new(0))
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error; 1 warning emitted
|
||||
|
||||
|
|
|
|||
|
|
@ -177,11 +177,6 @@ help: skipping check for `const_refs_to_static` feature
|
|||
|
|
||||
LL | const SUBTLE: &mut i32 = unsafe { static mut STATIC: i32 = 0; &mut STATIC };
|
||||
| ^^^^^^
|
||||
help: skipping check for `const_mut_refs` feature
|
||||
--> $DIR/mutable_references.rs:30:63
|
||||
|
|
||||
LL | const SUBTLE: &mut i32 = unsafe { static mut STATIC: i32 = 0; &mut STATIC };
|
||||
| ^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references.rs:40:28
|
||||
|
|
||||
|
|
@ -197,16 +192,6 @@ help: skipping check that does not even have a feature gate
|
|||
|
|
||||
LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check for `const_mut_refs` feature
|
||||
--> $DIR/mutable_references.rs:65: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.rs:65:49
|
||||
|
|
||||
LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check for `const_refs_to_static` feature
|
||||
--> $DIR/mutable_references.rs:72:43
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//@ 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::*;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
|
||||
#![feature(const_swap)]
|
||||
#![feature(const_mut_refs)]
|
||||
use std::{
|
||||
mem::{self, MaybeUninit},
|
||||
ptr,
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@ note: inside `std::ptr::swap_nonoverlapping_simple_untyped::<MaybeUninit<u8>>`
|
|||
note: inside `swap_nonoverlapping::<MaybeUninit<u8>>`
|
||||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
||||
note: inside `X`
|
||||
--> $DIR/missing_span_in_backtrace.rs:17:9
|
||||
--> $DIR/missing_span_in_backtrace.rs:16:9
|
||||
|
|
||||
17 | / ptr::swap_nonoverlapping(
|
||||
18 | | &mut ptr1 as *mut _ as *mut MaybeUninit<u8>,
|
||||
19 | | &mut ptr2 as *mut _ as *mut MaybeUninit<u8>,
|
||||
20 | | mem::size_of::<&i32>(),
|
||||
21 | | );
|
||||
16 | / ptr::swap_nonoverlapping(
|
||||
17 | | &mut ptr1 as *mut _ as *mut MaybeUninit<u8>,
|
||||
18 | | &mut ptr2 as *mut _ as *mut MaybeUninit<u8>,
|
||||
19 | | mem::size_of::<&i32>(),
|
||||
20 | | );
|
||||
| |_________^
|
||||
= help: this code performed an operation that depends on the underlying bytes representing a pointer
|
||||
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
//@run-pass
|
||||
#![feature(const_mut_refs)]
|
||||
#![feature(sync_unsafe_cell)]
|
||||
|
||||
use std::cell::SyncUnsafeCell;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#![feature(const_trait_impl)]
|
||||
#![feature(const_mut_refs)]
|
||||
|
||||
struct A();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
|
||||
--> $DIR/promoted-const-drop.rs:6:12
|
||||
--> $DIR/promoted-const-drop.rs:5:12
|
||||
|
|
||||
LL | impl const Drop for A {
|
||||
| ^^^^
|
||||
|
|
@ -8,7 +8,7 @@ LL | impl const Drop for A {
|
|||
= note: adding a non-const method body in the future would be a breaking change
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/promoted-const-drop.rs:14:26
|
||||
--> $DIR/promoted-const-drop.rs:13:26
|
||||
|
|
||||
LL | let _: &'static A = &A();
|
||||
| ---------- ^^^ creates a temporary value which is freed while still in use
|
||||
|
|
@ -19,7 +19,7 @@ LL | }
|
|||
| - temporary value is freed at the end of this statement
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/promoted-const-drop.rs:15:28
|
||||
--> $DIR/promoted-const-drop.rs:14:28
|
||||
|
|
||||
LL | let _: &'static [A] = &[C];
|
||||
| ------------ ^^^ creates a temporary value which is freed while still in use
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
//@ known-bug: #103507
|
||||
|
||||
#![feature(const_mut_refs)]
|
||||
#![feature(const_trait_impl)]
|
||||
|
||||
struct Panic;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
|
||||
--> $DIR/promoted_const_call.rs:7:12
|
||||
--> $DIR/promoted_const_call.rs:6:12
|
||||
|
|
||||
LL | impl const Drop for Panic { fn drop(&mut self) { panic!(); } }
|
||||
| ^^^^
|
||||
|
|
@ -8,7 +8,7 @@ LL | impl const Drop for Panic { fn drop(&mut self) { panic!(); } }
|
|||
= note: adding a non-const method body in the future would be a breaking change
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/promoted_const_call.rs:11:26
|
||||
--> $DIR/promoted_const_call.rs:10:26
|
||||
|
|
||||
LL | let _: &'static _ = &id(&Panic);
|
||||
| ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use
|
||||
|
|
@ -19,7 +19,7 @@ LL | };
|
|||
| - temporary value is freed at the end of this statement
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/promoted_const_call.rs:11:30
|
||||
--> $DIR/promoted_const_call.rs:10:30
|
||||
|
|
||||
LL | let _: &'static _ = &id(&Panic);
|
||||
| ---------- ^^^^^ - temporary value is freed at the end of this statement
|
||||
|
|
@ -28,7 +28,7 @@ LL | let _: &'static _ = &id(&Panic);
|
|||
| type annotation requires that borrow lasts for `'static`
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/promoted_const_call.rs:17:26
|
||||
--> $DIR/promoted_const_call.rs:16:26
|
||||
|
|
||||
LL | let _: &'static _ = &id(&Panic);
|
||||
| ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use
|
||||
|
|
@ -39,7 +39,7 @@ LL | }
|
|||
| - temporary value is freed at the end of this statement
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/promoted_const_call.rs:17:30
|
||||
--> $DIR/promoted_const_call.rs:16:30
|
||||
|
|
||||
LL | let _: &'static _ = &id(&Panic);
|
||||
| ---------- ^^^^^ - temporary value is freed at the end of this statement
|
||||
|
|
@ -48,7 +48,7 @@ LL | let _: &'static _ = &id(&Panic);
|
|||
| type annotation requires that borrow lasts for `'static`
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/promoted_const_call.rs:20:26
|
||||
--> $DIR/promoted_const_call.rs:19:26
|
||||
|
|
||||
LL | let _: &'static _ = &&(Panic, 0).1;
|
||||
| ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
|
||||
|
|
@ -59,7 +59,7 @@ LL | }
|
|||
| - temporary value is freed at the end of this statement
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/promoted_const_call.rs:20:27
|
||||
--> $DIR/promoted_const_call.rs:19:27
|
||||
|
|
||||
LL | let _: &'static _ = &&(Panic, 0).1;
|
||||
| ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
//@ run-pass
|
||||
#![feature(const_mut_refs)]
|
||||
|
||||
static mut TEST: i32 = {
|
||||
// We must not promote this, as CTFE needs to be able to mutate it later.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
//@ compile-flags: --crate-type=lib
|
||||
#![feature(const_mut_refs)]
|
||||
#![feature(const_precise_live_drops)]
|
||||
#![feature(const_swap)]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0493]: destructor of `Option<String>` cannot be evaluated at compile-time
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:14:9
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:13:9
|
||||
|
|
||||
LL | let mut x = None;
|
||||
| ^^^^^ the destructor for this type cannot be evaluated in constants
|
||||
|
|
@ -16,13 +16,13 @@ note: inside `std::ptr::drop_in_place::<String> - shim(Some(String))`
|
|||
note: inside `std::ptr::drop_in_place::<Option<String>> - shim(Some(Option<String>))`
|
||||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
||||
note: inside `A1`
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:20:1
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:19:1
|
||||
|
|
||||
LL | };
|
||||
| ^
|
||||
|
||||
error[E0493]: destructor of `Option<String>` cannot be evaluated at compile-time
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:30:9
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:29:9
|
||||
|
|
||||
LL | let _z = x;
|
||||
| ^^ the destructor for this type cannot be evaluated in constants
|
||||
|
|
@ -39,49 +39,49 @@ note: inside `std::ptr::drop_in_place::<String> - shim(Some(String))`
|
|||
note: inside `std::ptr::drop_in_place::<Option<String>> - shim(Some(Option<String>))`
|
||||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
||||
note: inside `A2`
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:31:1
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:30:1
|
||||
|
|
||||
LL | };
|
||||
| ^
|
||||
|
||||
error[E0493]: destructor of `(u32, Option<String>)` cannot be evaluated at compile-time
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:8:9
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:7:9
|
||||
|
|
||||
LL | let mut a: (u32, Option<String>) = (0, None);
|
||||
| ^^^^^ the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error[E0493]: destructor of `Option<T>` cannot be evaluated at compile-time
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:35:9
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:34:9
|
||||
|
|
||||
LL | let x: Option<T> = None;
|
||||
| ^ the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error[E0493]: destructor of `Option<T>` cannot be evaluated at compile-time
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:43:9
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:42:9
|
||||
|
|
||||
LL | let _y = x;
|
||||
| ^^ the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error[E0493]: destructor of `Option<String>` cannot be evaluated at compile-time
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:51:9
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:50:9
|
||||
|
|
||||
LL | let mut y: Option<String> = None;
|
||||
| ^^^^^ the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error[E0493]: destructor of `Option<String>` cannot be evaluated at compile-time
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:48:9
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:47:9
|
||||
|
|
||||
LL | let mut x: Option<String> = None;
|
||||
| ^^^^^ the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error[E0493]: destructor of `Option<String>` cannot be evaluated at compile-time
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:61:9
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:60:9
|
||||
|
|
||||
LL | let y: Option<String> = None;
|
||||
| ^ the destructor for this type cannot be evaluated in constant functions
|
||||
|
||||
error[E0493]: destructor of `Option<String>` cannot be evaluated at compile-time
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:58:9
|
||||
--> $DIR/qualif-indirect-mutation-fail.rs:57:9
|
||||
|
|
||||
LL | let x: Option<String> = None;
|
||||
| ^ the destructor for this type cannot be evaluated in constant functions
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
//@ compile-flags: --crate-type=lib
|
||||
//@ check-pass
|
||||
#![feature(const_mut_refs)]
|
||||
#![feature(const_precise_live_drops)]
|
||||
|
||||
// Mutable reference allows only mutation of !Drop place.
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
//@ revisions: stock mut_refs
|
||||
#![allow(static_mut_refs)]
|
||||
#![cfg_attr(mut_refs, feature(const_mut_refs))]
|
||||
|
||||
static mut STDERR_BUFFER_SPACE: u8 = 0;
|
||||
|
||||
pub static mut STDERR_BUFFER: () = unsafe {
|
||||
*(&mut STDERR_BUFFER_SPACE) = 42;
|
||||
//[mut_refs]~^ ERROR could not evaluate static initializer
|
||||
//[stock]~^^ ERROR mutation through a reference is not allowed in statics
|
||||
//~^ ERROR could not evaluate static initializer
|
||||
};
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0080]: could not evaluate static initializer
|
||||
--> $DIR/static_mut_containing_mut_ref2.rs:8:5
|
||||
--> $DIR/static_mut_containing_mut_ref2.rs:6:5
|
||||
|
|
||||
LL | *(&mut STDERR_BUFFER_SPACE) = 42;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ modifying a static's initial value from another static's initializer
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
error[E0658]: mutation through a reference is not allowed in statics
|
||||
--> $DIR/static_mut_containing_mut_ref2.rs:8:5
|
||||
|
|
||||
LL | *(&mut STDERR_BUFFER_SPACE) = 42;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -1,17 +1,14 @@
|
|||
//@ revisions: stock mut_refs
|
||||
//@[mut_refs] check-pass
|
||||
|
||||
#![cfg_attr(mut_refs, feature(const_mut_refs))]
|
||||
|
||||
use std::cell::Cell;
|
||||
//@run-pass
|
||||
|
||||
const FOO: &u32 = {
|
||||
let mut a = 42;
|
||||
{
|
||||
let b: *mut u32 = &mut a; //[stock]~ ERROR mutable references are not allowed in constants
|
||||
unsafe { *b = 5; } //[stock]~ ERROR dereferencing raw mutable pointers in constants
|
||||
let b: *mut u32 = &mut a;
|
||||
unsafe { *b = 5; }
|
||||
}
|
||||
&{a}
|
||||
};
|
||||
|
||||
fn main() {}
|
||||
fn main() {
|
||||
assert_eq!(*FOO, 5);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_mut_refs)]
|
||||
|
||||
static OH_NO: &mut i32 = &mut 42; //~ ERROR mutable references are not allowed
|
||||
fn main() {
|
||||
assert_eq!(*OH_NO, 42);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error[E0764]: mutable references are not allowed in the final value of statics
|
||||
--> $DIR/write_to_static_via_mut_ref.rs:3:26
|
||||
--> $DIR/write_to_static_via_mut_ref.rs:1:26
|
||||
|
|
||||
LL | static OH_NO: &mut i32 = &mut 42;
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0594]: cannot assign to `*OH_NO`, as `OH_NO` is an immutable static item
|
||||
--> $DIR/write_to_static_via_mut_ref.rs:6:5
|
||||
--> $DIR/write_to_static_via_mut_ref.rs:4:5
|
||||
|
|
||||
LL | *OH_NO = 43;
|
||||
| ^^^^^^^^^^^ cannot assign
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_mut_refs)]
|
||||
|
||||
//@ normalize-stderr-test: "\(size: ., align: .\)" -> ""
|
||||
//@ normalize-stderr-test: " +│ ╾─+╼" -> ""
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue