1
Fork 0

Bless mut tests

This commit is contained in:
Dylan MacKenzie 2020-09-29 14:58:00 -07:00
parent b518ccb4c3
commit a23297f5c0
16 changed files with 173 additions and 107 deletions

View file

@ -515,8 +515,6 @@ pub mod ty {
#[derive(Debug)] #[derive(Debug)]
pub struct MutRef; pub struct MutRef;
impl NonConstOp for MutRef { impl NonConstOp for MutRef {
const STOPS_CONST_CHECKING: bool = true;
fn status_in_item(&self, _ccx: &ConstCx<'_, '_>) -> Status { fn status_in_item(&self, _ccx: &ConstCx<'_, '_>) -> Status {
Status::Unstable(sym::const_mut_refs) Status::Unstable(sym::const_mut_refs)
} }

View file

@ -1,7 +1,7 @@
// New test for #53818: modifying static memory at compile-time is not allowed. // New test for #53818: modifying static memory at compile-time is not allowed.
// The test should never compile successfully // The test should never compile successfully
#![feature(const_raw_ptr_deref)] #![feature(const_raw_ptr_deref, const_mut_refs)]
use std::cell::UnsafeCell; use std::cell::UnsafeCell;
@ -13,7 +13,7 @@ unsafe impl Sync for Foo {}
static FOO: Foo = Foo(UnsafeCell::new(42)); static FOO: Foo = Foo(UnsafeCell::new(42));
static BAR: () = unsafe { static BAR: () = unsafe {
*FOO.0.get() = 5; //~ ERROR contains unimplemented expression type *FOO.0.get() = 5; //~ ERROR
}; };
fn main() {} fn main() {}

View file

@ -1,11 +1,9 @@
error[E0019]: static contains unimplemented expression type error[E0080]: could not evaluate static initializer
--> $DIR/assign-to-static-within-other-static-2.rs:16:5 --> $DIR/assign-to-static-within-other-static-2.rs:16:5
| |
LL | *FOO.0.get() = 5; LL | *FOO.0.get() = 5;
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^ modifying a static's initial value from another static's initializer
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0019`. For more information about this error, try `rustc --explain E0080`.

View file

@ -12,14 +12,9 @@ unsafe impl Sync for Foo {}
static FOO: Foo = Foo(UnsafeCell::new(42)); static FOO: Foo = Foo(UnsafeCell::new(42));
fn foo() {}
static BAR: () = unsafe { static BAR: () = unsafe {
*FOO.0.get() = 5; *FOO.0.get() = 5;
//~^ contains unimplemented expression //~^ mutation through a reference
foo();
//~^ ERROR calls in statics are limited to constant functions, tuple structs and tuple variants
}; };
fn main() { fn main() {

View file

@ -1,18 +1,12 @@
error[E0019]: static contains unimplemented expression type error[E0658]: mutation through a reference is not allowed in statics
--> $DIR/mod-static-with-const-fn.rs:18:5 --> $DIR/mod-static-with-const-fn.rs:15:5
| |
LL | *FOO.0.get() = 5; LL | *FOO.0.get() = 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 = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants error: aborting due to previous error
--> $DIR/mod-static-with-const-fn.rs:21:5
|
LL | foo();
| ^^^^^
error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`.
Some errors have detailed explanations: E0015, E0019.
For more information about an error, try `rustc --explain E0015`.

View file

@ -6,23 +6,21 @@ struct S {
impl S { impl S {
const fn foo(&mut self, x: u32) { const fn foo(&mut self, x: u32) {
//~^ ERROR mutable references //~^ ERROR mutable reference
self.state = x; self.state = x;
} }
} }
const FOO: S = { const FOO: S = {
let mut s = S { state: 42 }; let mut s = S { state: 42 };
s.foo(3); //~ ERROR mutable references are not allowed in constants s.foo(3); //~ ERROR mutable reference
s s
}; };
type Array = [u32; { type Array = [u32; {
let mut x = 2; let mut x = 2;
let y = &mut x; let y = &mut x; //~ ERROR mutable reference
//~^ ERROR mutable references are not allowed in constants
*y = 42; *y = 42;
//~^ ERROR constant contains unimplemented expression type
*y *y
}]; }];

View file

@ -19,15 +19,7 @@ error[E0764]: mutable references are not allowed in constants
LL | let y = &mut x; LL | let y = &mut x;
| ^^^^^^ `&mut` is only allowed in `const fn` | ^^^^^^ `&mut` is only allowed in `const fn`
error[E0019]: constant contains unimplemented expression type error: aborting due to 3 previous errors
--> $DIR/const_let_assign3.rs:24:5
|
LL | *y = 42;
| ^^^^^^^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error: aborting due to 4 previous errors Some errors have detailed explanations: E0658, E0764.
For more information about an error, try `rustc --explain E0658`.
Some errors have detailed explanations: E0019, E0658, E0764.
For more information about an error, try `rustc --explain E0019`.

View file

@ -1,7 +1,6 @@
const fn foo(a: i32) -> Vec<i32> { const fn foo(a: i32) -> Vec<i32> {
vec![1, 2, 3] vec![1, 2, 3]
//~^ ERROR allocations are not allowed //~^ ERROR allocations are not allowed
//~| ERROR unimplemented expression type
//~| ERROR calls in constant functions //~| ERROR calls in constant functions
} }

View file

@ -6,15 +6,6 @@ LL | vec![1, 2, 3]
| |
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0019]: constant function contains unimplemented expression type
--> $DIR/bad_const_fn_body_ice.rs:2:5
|
LL | vec![1, 2, 3]
| ^^^^^^^^^^^^^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
--> $DIR/bad_const_fn_body_ice.rs:2:5 --> $DIR/bad_const_fn_body_ice.rs:2:5
| |
@ -23,7 +14,7 @@ LL | vec![1, 2, 3]
| |
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 3 previous errors error: aborting due to 2 previous errors
Some errors have detailed explanations: E0010, E0015, E0019. Some errors have detailed explanations: E0010, E0015.
For more information about an error, try `rustc --explain E0010`. For more information about an error, try `rustc --explain E0010`.

View file

@ -38,6 +38,9 @@ impl<T> Foo<T> {
const fn get(&self) -> &T { &self.0 } const fn get(&self) -> &T { &self.0 }
const fn get_mut(&mut self) -> &mut T { &mut self.0 } const fn get_mut(&mut self) -> &mut T { &mut self.0 }
//~^ mutable references //~^ mutable references
//~| mutable references
//~| mutable references
//~| mutable references
} }
impl<'a, T> Foo<T> { impl<'a, T> Foo<T> {
const fn new_lt(t: T) -> Self { Foo(t) } const fn new_lt(t: T) -> Self { Foo(t) }
@ -45,6 +48,9 @@ impl<'a, T> Foo<T> {
const fn get_lt(&'a self) -> &T { &self.0 } const fn get_lt(&'a self) -> &T { &self.0 }
const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 } const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 }
//~^ mutable references //~^ mutable references
//~| mutable references
//~| mutable references
//~| mutable references
} }
impl<T: Sized> Foo<T> { impl<T: Sized> Foo<T> {
const fn new_s(t: T) -> Self { Foo(t) } const fn new_s(t: T) -> Self { Foo(t) }
@ -52,11 +58,17 @@ impl<T: Sized> Foo<T> {
const fn get_s(&self) -> &T { &self.0 } const fn get_s(&self) -> &T { &self.0 }
const fn get_mut_s(&mut self) -> &mut T { &mut self.0 } const fn get_mut_s(&mut self) -> &mut T { &mut self.0 }
//~^ mutable references //~^ mutable references
//~| mutable references
//~| mutable references
//~| mutable references
} }
impl<T: ?Sized> Foo<T> { impl<T: ?Sized> Foo<T> {
const fn get_sq(&self) -> &T { &self.0 } const fn get_sq(&self) -> &T { &self.0 }
const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 } const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 }
//~^ mutable references //~^ mutable references
//~| mutable references
//~| mutable references
//~| mutable references
} }

View file

@ -15,8 +15,35 @@ 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 = 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 = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
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
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
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
error[E0493]: destructors cannot be evaluated at compile-time error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/min_const_fn.rs:44:28 --> $DIR/min_const_fn.rs:47:28
| |
LL | const fn into_inner_lt(self) -> T { self.0 } LL | const fn into_inner_lt(self) -> T { self.0 }
| ^^^^ - value is dropped here | ^^^^ - value is dropped here
@ -24,7 +51,7 @@ LL | const fn into_inner_lt(self) -> T { self.0 }
| constant functions cannot evaluate destructors | constant functions cannot evaluate destructors
error[E0658]: mutable references are not allowed in constant functions error[E0658]: mutable references are not allowed in constant functions
--> $DIR/min_const_fn.rs:46:42 --> $DIR/min_const_fn.rs:49:42
| |
LL | const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 } LL | const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 }
| ^^^^^^ | ^^^^^^
@ -32,8 +59,35 @@ 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 = 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 = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0658]: mutable references are not allowed in constant functions
--> $DIR/min_const_fn.rs:49: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
error[E0658]: mutable references are not allowed in constant functions
--> $DIR/min_const_fn.rs:49: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
error[E0658]: mutable references are not allowed in constant functions
--> $DIR/min_const_fn.rs:49: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
error[E0493]: destructors cannot be evaluated at compile-time error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/min_const_fn.rs:51:27 --> $DIR/min_const_fn.rs:57:27
| |
LL | const fn into_inner_s(self) -> T { self.0 } LL | const fn into_inner_s(self) -> T { self.0 }
| ^^^^ - value is dropped here | ^^^^ - value is dropped here
@ -41,7 +95,7 @@ LL | const fn into_inner_s(self) -> T { self.0 }
| constant functions cannot evaluate destructors | constant functions cannot evaluate destructors
error[E0658]: mutable references are not allowed in constant functions error[E0658]: mutable references are not allowed in constant functions
--> $DIR/min_const_fn.rs:53:38 --> $DIR/min_const_fn.rs:59:38
| |
LL | const fn get_mut_s(&mut self) -> &mut T { &mut self.0 } LL | const fn get_mut_s(&mut self) -> &mut T { &mut self.0 }
| ^^^^^^ | ^^^^^^
@ -50,7 +104,34 @@ LL | const fn get_mut_s(&mut self) -> &mut T { &mut self.0 }
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0658]: mutable references are not allowed in constant functions error[E0658]: mutable references are not allowed in constant functions
--> $DIR/min_const_fn.rs:58:39 --> $DIR/min_const_fn.rs:59: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
error[E0658]: mutable references are not allowed in constant functions
--> $DIR/min_const_fn.rs:59: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
error[E0658]: mutable references are not allowed in constant functions
--> $DIR/min_const_fn.rs:59: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
error[E0658]: mutable references are not allowed in constant functions
--> $DIR/min_const_fn.rs:67:39
| |
LL | const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 } LL | const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 }
| ^^^^^^ | ^^^^^^
@ -58,8 +139,35 @@ 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 = 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 = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0658]: mutable references are not allowed in constant functions
--> $DIR/min_const_fn.rs:67: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
error[E0658]: mutable references are not allowed in constant functions
--> $DIR/min_const_fn.rs:67: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
error[E0658]: mutable references are not allowed in constant functions
--> $DIR/min_const_fn.rs:67: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
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:76:16 --> $DIR/min_const_fn.rs:88:16
| |
LL | const fn foo11<T: std::fmt::Display>(t: T) -> T { t } LL | const fn foo11<T: std::fmt::Display>(t: T) -> T { t }
| ^ | ^
@ -68,7 +176,7 @@ LL | const fn foo11<T: std::fmt::Display>(t: T) -> T { t }
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:78:18 --> $DIR/min_const_fn.rs:90:18
| |
LL | const fn foo11_2<T: Send>(t: T) -> T { t } LL | const fn foo11_2<T: Send>(t: T) -> T { t }
| ^ | ^
@ -77,7 +185,7 @@ LL | const fn foo11_2<T: Send>(t: T) -> T { t }
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0013]: constant functions cannot refer to statics error[E0013]: constant functions cannot refer to statics
--> $DIR/min_const_fn.rs:82:27 --> $DIR/min_const_fn.rs:94:27
| |
LL | const fn foo25() -> u32 { BAR } LL | const fn foo25() -> u32 { BAR }
| ^^^ | ^^^
@ -85,7 +193,7 @@ LL | const fn foo25() -> u32 { BAR }
= help: consider extracting the value of the `static` to a `const`, and referring to that = help: consider extracting the value of the `static` to a `const`, and referring to that
error[E0013]: constant functions cannot refer to statics error[E0013]: constant functions cannot refer to statics
--> $DIR/min_const_fn.rs:83:37 --> $DIR/min_const_fn.rs:95:37
| |
LL | const fn foo26() -> &'static u32 { &BAR } LL | const fn foo26() -> &'static u32 { &BAR }
| ^^^ | ^^^
@ -93,7 +201,7 @@ LL | const fn foo26() -> &'static u32 { &BAR }
= help: consider extracting the value of the `static` to a `const`, and referring to that = help: consider extracting the value of the `static` to a `const`, and referring to that
error[E0658]: casting pointers to integers in constant functions is unstable error[E0658]: casting pointers to integers in constant functions is unstable
--> $DIR/min_const_fn.rs:84:42 --> $DIR/min_const_fn.rs:96:42
| |
LL | const fn foo30(x: *const u32) -> usize { x as usize } LL | const fn foo30(x: *const u32) -> usize { x as usize }
| ^^^^^^^^^^ | ^^^^^^^^^^
@ -102,7 +210,7 @@ LL | const fn foo30(x: *const u32) -> usize { x as usize }
= help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable = help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable
error[E0658]: casting pointers to integers in constant functions is unstable error[E0658]: casting pointers to integers in constant functions is unstable
--> $DIR/min_const_fn.rs:86:63 --> $DIR/min_const_fn.rs:98:63
| |
LL | const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize } } LL | const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize } }
| ^^^^^^^^^^ | ^^^^^^^^^^
@ -111,7 +219,7 @@ LL | const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize }
= help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable = help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable
error[E0658]: casting pointers to integers in constant functions is unstable error[E0658]: casting pointers to integers in constant functions is unstable
--> $DIR/min_const_fn.rs:88:42 --> $DIR/min_const_fn.rs:100:42
| |
LL | const fn foo30_2(x: *mut u32) -> usize { x as usize } LL | const fn foo30_2(x: *mut u32) -> usize { x as usize }
| ^^^^^^^^^^ | ^^^^^^^^^^
@ -120,7 +228,7 @@ LL | const fn foo30_2(x: *mut u32) -> usize { x as usize }
= help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable = help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable
error[E0658]: casting pointers to integers in constant functions is unstable error[E0658]: casting pointers to integers in constant functions is unstable
--> $DIR/min_const_fn.rs:90:63 --> $DIR/min_const_fn.rs:102:63
| |
LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } } LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } }
| ^^^^^^^^^^ | ^^^^^^^^^^
@ -129,7 +237,7 @@ LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize }
= help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable = help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable
error[E0658]: mutable references are not allowed in constant functions error[E0658]: mutable references are not allowed in constant functions
--> $DIR/min_const_fn.rs:93:14 --> $DIR/min_const_fn.rs:105:14
| |
LL | const fn inc(x: &mut i32) { *x += 1 } LL | const fn inc(x: &mut i32) { *x += 1 }
| ^ | ^
@ -138,7 +246,7 @@ LL | const fn inc(x: &mut i32) { *x += 1 }
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:102:6 --> $DIR/min_const_fn.rs:114:6
| |
LL | impl<T: std::fmt::Debug> Foo<T> { LL | impl<T: std::fmt::Debug> Foo<T> {
| ^ | ^
@ -147,7 +255,7 @@ LL | impl<T: std::fmt::Debug> Foo<T> {
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:107:6 --> $DIR/min_const_fn.rs:119:6
| |
LL | impl<T: std::fmt::Debug + Sized> Foo<T> { LL | impl<T: std::fmt::Debug + Sized> Foo<T> {
| ^ | ^
@ -156,7 +264,7 @@ LL | impl<T: std::fmt::Debug + Sized> Foo<T> {
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:112:6 --> $DIR/min_const_fn.rs:124:6
| |
LL | impl<T: Sync + Sized> Foo<T> { LL | impl<T: Sync + Sized> Foo<T> {
| ^ | ^
@ -165,7 +273,7 @@ LL | impl<T: Sync + Sized> Foo<T> {
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:118:34 --> $DIR/min_const_fn.rs:130:34
| |
LL | const fn no_apit2(_x: AlanTuring<impl std::fmt::Debug>) {} LL | const fn no_apit2(_x: AlanTuring<impl std::fmt::Debug>) {}
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
@ -174,7 +282,7 @@ LL | const fn no_apit2(_x: AlanTuring<impl std::fmt::Debug>) {}
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:120:22 --> $DIR/min_const_fn.rs:132:22
| |
LL | const fn no_apit(_x: impl std::fmt::Debug) {} LL | const fn no_apit(_x: impl std::fmt::Debug) {}
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
@ -183,7 +291,7 @@ LL | const fn no_apit(_x: impl std::fmt::Debug) {}
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:121:23 --> $DIR/min_const_fn.rs:133:23
| |
LL | const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {} LL | const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {}
| ^^ | ^^
@ -192,7 +300,7 @@ LL | const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {}
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:122:32 --> $DIR/min_const_fn.rs:134:32
| |
LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -201,7 +309,7 @@ LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:127:41 --> $DIR/min_const_fn.rs:139:41
| |
LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 } LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -210,7 +318,7 @@ LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0658]: function pointers cannot appear in constant functions error[E0658]: function pointers cannot appear in constant functions
--> $DIR/min_const_fn.rs:130:21 --> $DIR/min_const_fn.rs:142:21
| |
LL | const fn no_fn_ptrs(_x: fn()) {} LL | const fn no_fn_ptrs(_x: fn()) {}
| ^^ | ^^
@ -219,7 +327,7 @@ LL | const fn no_fn_ptrs(_x: fn()) {}
= help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable = help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable
error[E0658]: function pointers cannot appear in constant functions error[E0658]: function pointers cannot appear in constant functions
--> $DIR/min_const_fn.rs:132:27 --> $DIR/min_const_fn.rs:144:27
| |
LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo } LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo }
| ^^^^ | ^^^^
@ -227,7 +335,7 @@ LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo }
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable = help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable
error: aborting due to 26 previous errors error: aborting due to 38 previous errors
Some errors have detailed explanations: E0013, E0493, E0658, E0723. Some errors have detailed explanations: E0013, E0493, E0658, E0723.
For more information about an error, try `rustc --explain E0013`. For more information about an error, try `rustc --explain E0013`.

View file

@ -1,17 +1,17 @@
error[E0658]: mutable references are not allowed in constant functions error[E0658]: mutable references are not allowed in constant functions
--> $DIR/mutable_borrow.rs:3:9 --> $DIR/mutable_borrow.rs:3:13
| |
LL | let b = &mut a; LL | let b = &mut a;
| ^ | ^^^^^^
| |
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information = 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 = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0658]: mutable references are not allowed in constant functions error[E0658]: mutable references are not allowed in constant functions
--> $DIR/mutable_borrow.rs:12:13 --> $DIR/mutable_borrow.rs:12:17
| |
LL | let b = &mut a; LL | let b = &mut a;
| ^ | ^^^^^^
| |
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information = 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 = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable

View file

@ -9,7 +9,6 @@ const FOO: &u32 = {
{ {
let b: *mut u32 = &mut a; //~ ERROR mutable references are not allowed in constants let b: *mut u32 = &mut a; //~ ERROR mutable references are not allowed in constants
unsafe { *b = 5; } //~ ERROR dereferencing raw pointers in constants unsafe { *b = 5; } //~ ERROR dereferencing raw pointers in constants
//[stock]~^ contains unimplemented expression
} }
&{a} &{a}
}; };

View file

@ -13,15 +13,7 @@ LL | unsafe { *b = 5; }
= note: see issue #51911 <https://github.com/rust-lang/rust/issues/51911> for more information = note: see issue #51911 <https://github.com/rust-lang/rust/issues/51911> for more information
= help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
error[E0019]: constant contains unimplemented expression type error: aborting due to 2 previous errors
--> $DIR/projection_qualif.rs:11:18
|
LL | unsafe { *b = 5; }
| ^^^^^^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error: aborting due to 3 previous errors Some errors have detailed explanations: E0658, E0764.
For more information about an error, try `rustc --explain E0658`.
Some errors have detailed explanations: E0019, E0658, E0764.
For more information about an error, try `rustc --explain E0019`.

View file

@ -6,6 +6,5 @@ static mut STDERR_BUFFER_SPACE: u8 = 0;
pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; }; pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; };
//~^ ERROR mutable references are not allowed in statics //~^ ERROR mutable references are not allowed in statics
//[stock]~| ERROR static contains unimplemented expression type
fn main() {} fn main() {}

View file

@ -4,15 +4,6 @@ error[E0764]: mutable references are not allowed in statics
LL | pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; }; LL | pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ `&mut` is only allowed in `const fn` | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `&mut` is only allowed in `const fn`
error[E0019]: static contains unimplemented expression type error: aborting due to previous error
--> $DIR/static_mut_containing_mut_ref2.rs:7:45
|
LL | pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0764`.
Some errors have detailed explanations: E0019, E0764.
For more information about an error, try `rustc --explain E0019`.