blob: 544458dfcd8bbd30ca7127348341ccc6b8e1429a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
// check-pass
#![feature(const_mut_refs)]
struct Foo {
x: 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 = 2;
*x
}
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];
}
|