summaryrefslogtreecommitdiffstats
path: root/tests/ui/confuse-field-and-method/private-field.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/confuse-field-and-method/private-field.rs')
-rw-r--r--tests/ui/confuse-field-and-method/private-field.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/ui/confuse-field-and-method/private-field.rs b/tests/ui/confuse-field-and-method/private-field.rs
new file mode 100644
index 000000000..28b8935ac
--- /dev/null
+++ b/tests/ui/confuse-field-and-method/private-field.rs
@@ -0,0 +1,19 @@
+pub mod animal {
+ pub struct Dog {
+ pub age: usize,
+ dog_age: usize,
+ }
+
+ impl Dog {
+ pub fn new(age: usize) -> Dog {
+ Dog { age: age, dog_age: age * 7 }
+ }
+ }
+}
+
+fn main() {
+ let dog = animal::Dog::new(3);
+ let dog_age = dog.dog_age(); //~ ERROR no method
+ //let dog_age = dog.dog_age;
+ println!("{}", dog_age);
+}