From 64d98f8ee037282c35007b64c2649055c56af1db Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:03 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/mut/mutable-class-fields-2.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/ui/mut/mutable-class-fields-2.rs (limited to 'tests/ui/mut/mutable-class-fields-2.rs') diff --git a/tests/ui/mut/mutable-class-fields-2.rs b/tests/ui/mut/mutable-class-fields-2.rs new file mode 100644 index 000000000..30e54dfc9 --- /dev/null +++ b/tests/ui/mut/mutable-class-fields-2.rs @@ -0,0 +1,24 @@ +struct Cat { + meows : usize, + + how_hungry : isize, +} + +impl Cat { + pub fn eat(&self) { + self.how_hungry -= 5; //~ ERROR cannot assign + } + +} + +fn cat(in_x : usize, in_y : isize) -> Cat { + Cat { + meows: in_x, + how_hungry: in_y + } +} + +fn main() { + let nyan : Cat = cat(52, 99); + nyan.eat(); +} -- cgit v1.2.3