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 {
squared(mut self) -> Value12     fn squared(mut self) -> Value {
13         self.n *= self.n;
14         self
15     }
16 }
17 
main()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 }
24