]> git.lizzy.rs Git - rust.git/blob - src/test/ui/self/self-in-mut-slot-immediate-value.rs
Update ui tests
[rust.git] / src / test / ui / self / self-in-mut-slot-immediate-value.rs
1 // run-pass
2 // Assert that `mut self` on an immediate value doesn't
3 // allow mutating the original - issue #10615.
4
5
6 #[derive(Copy, Clone)]
7 struct Value {
8     n: isize
9 }
10
11 impl Value {
12     fn squared(mut self) -> Value {
13         self.n *= self.n;
14         self
15     }
16 }
17
18 pub fn main() {
19     let x = Value { n: 3 };
20     let y = x.squared();
21     assert_eq!(x.n, 3);
22     assert_eq!(y.n, 9);
23 }