mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-02 03:33:59 +00:00
Extend test for const_mut_refs feature
This commit is contained in:
parent
d92e9b7374
commit
e31a1368fd
@ -6,12 +6,31 @@ struct Foo {
|
||||
x: usize
|
||||
}
|
||||
|
||||
const fn bar(foo: &mut Foo) -> usize {
|
||||
const fn foo() -> Foo {
|
||||
Foo { x: 0 }
|
||||
}
|
||||
|
||||
impl Foo {
|
||||
const fn bar(&mut self) -> usize {
|
||||
self.x = 1;
|
||||
self.x
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const fn baz(foo: &mut Foo) -> usize {
|
||||
let x = &mut foo.x;
|
||||
*x = 1;
|
||||
*x = 2;
|
||||
*x
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _: [(); bar(&mut Foo { x: 0 })] = [(); 1];
|
||||
const fn bazz(foo: &mut Foo) -> usize {
|
||||
foo.x = 3;
|
||||
foo.x
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _: [(); foo().bar()] = [(); 1];
|
||||
let _: [(); baz(&mut foo())] = [(); 2];
|
||||
let _: [(); bazz(&mut foo())] = [(); 3];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user