We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d92e9b7 commit e31a136Copy full SHA for e31a136
src/test/ui/consts/const-mut-refs/const_mut_refs.rs
@@ -6,12 +6,31 @@ struct Foo {
6
x: usize
7
}
8
9
-const fn bar(foo: &mut Foo) -> usize {
+const fn foo() -> Foo {
10
+ Foo { x: 0 }
11
+}
12
+
13
+impl Foo {
14
+ const fn bar(&mut self) -> usize {
15
+ self.x = 1;
16
+ self.x
17
+ }
18
19
20
21
+const fn baz(foo: &mut Foo) -> usize {
22
let x = &mut foo.x;
- *x = 1;
23
+ *x = 2;
24
*x
25
26
27
+const fn bazz(foo: &mut Foo) -> usize {
28
+ foo.x = 3;
29
+ foo.x
30
31
32
fn main() {
- let _: [(); bar(&mut Foo { x: 0 })] = [(); 1];
33
+ let _: [(); foo().bar()] = [(); 1];
34
+ let _: [(); baz(&mut foo())] = [(); 2];
35
+ let _: [(); bazz(&mut foo())] = [(); 3];
36
0 commit comments