Move and rewrite tests to use &mut in constants

This commit is contained in:
Christian Poveda 2019-11-21 14:35:19 -05:00
parent 1f420b9891
commit de60f721c4
4 changed files with 16 additions and 16 deletions

View 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];
}

View File

@ -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 {
| ^

View File

@ -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);
}