Move and rewrite tests to use &mut in constants
This commit is contained in:
parent
1f420b9891
commit
de60f721c4
15
src/test/ui/consts/const-mut-refs/const_mut_refs.rs
Normal file
15
src/test/ui/consts/const-mut-refs/const_mut_refs.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// run-pass
|
||||
|
||||
#![feature(const_mut_refs)]
|
||||
|
||||
struct Foo {
|
||||
x: usize
|
||||
}
|
||||
|
||||
const fn bar(foo: &mut Foo) -> usize {
|
||||
foo.x + 1
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _: [(); bar(&mut Foo { x: 0 })] = [(); 1];
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
error[E0723]: mutable references in const fn are unstable
|
||||
--> $DIR/feature-gate-const_fn_mut_refs.rs:5:14
|
||||
--> $DIR/feature-gate-const_mut_refs.rs:5:14
|
||||
|
|
||||
LL | const fn foo(x: &mut i32) -> i32 {
|
||||
| ^
|
@ -1,15 +0,0 @@
|
||||
// run-pass
|
||||
|
||||
#![feature(const_mut_refs)]
|
||||
|
||||
struct Foo {
|
||||
x: i32
|
||||
}
|
||||
|
||||
const fn bar(foo: &mut Foo) -> i32 {
|
||||
foo.x + 1
|
||||
}
|
||||
|
||||
fn main() {
|
||||
assert_eq!(bar(&mut Foo{x: 0}), 1);
|
||||
}
|
Loading…
Reference in New Issue
Block a user