{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/2392","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/2392/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/2392/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/2392/events","html_url":"https://github.com/rust-lang/rust/issues/2392","id":4625535,"number":2392,"title":"Helpful error message when confusing a field with a method","user":{"login":"catamorphism","id":427212,"avatar_url":"https://avatars.githubusercontent.com/u/427212?v=3","gravatar_id":"","url":"https://api.github.com/users/catamorphism","html_url":"https://github.com/catamorphism","followers_url":"https://api.github.com/users/catamorphism/followers","following_url":"https://api.github.com/users/catamorphism/following{/other_user}","gists_url":"https://api.github.com/users/catamorphism/gists{/gist_id}","starred_url":"https://api.github.com/users/catamorphism/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/catamorphism/subscriptions","organizations_url":"https://api.github.com/users/catamorphism/orgs","repos_url":"https://api.github.com/users/catamorphism/repos","events_url":"https://api.github.com/users/catamorphism/events{/privacy}","received_events_url":"https://api.github.com/users/catamorphism/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-diagnostics","name":"A-diagnostics","color":"d7e102"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-typesystem","name":"A-typesystem","color":"d7e102"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/E-easy","name":"E-easy","color":"02e10c"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/I-papercut","name":"I-papercut","color":"e10c02"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/P-low","name":"P-low","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2012-05-17T15:07:46Z","updated_at":"2015-06-13T18:52:21Z","closed_at":null,"body":"I forget if there's already a bug on this, but it would be nice if, when you wrote ```A.B``` and ```A``` doesn't have a field named ```B```, but does have a nullary method named ```B```, the compiler gave a hint like \"did you mean to write ```A.B()```?\" It could also do vice versa (if you write A.B()``` and ```A``` is a class with field ```B```, it could ask \"did you mean ```A.B```?)\n\nI ran into this in trans, where I have frequently written ```bcx.ccx``` instead of ```bcx.ccx()```."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/111739747","html_url":"https://github.com/rust-lang/rust/issues/2392#issuecomment-111739747","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/2392","id":111739747,"user":{"login":"Nashenas88","id":1673130,"avatar_url":"https://avatars.githubusercontent.com/u/1673130?v=3","gravatar_id":"","url":"https://api.github.com/users/Nashenas88","html_url":"https://github.com/Nashenas88","followers_url":"https://api.github.com/users/Nashenas88/followers","following_url":"https://api.github.com/users/Nashenas88/following{/other_user}","gists_url":"https://api.github.com/users/Nashenas88/gists{/gist_id}","starred_url":"https://api.github.com/users/Nashenas88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nashenas88/subscriptions","organizations_url":"https://api.github.com/users/Nashenas88/orgs","repos_url":"https://api.github.com/users/Nashenas88/repos","events_url":"https://api.github.com/users/Nashenas88/events{/privacy}","received_events_url":"https://api.github.com/users/Nashenas88/received_events","type":"User","site_admin":false},"created_at":"2015-06-13T18:52:21Z","updated_at":"2015-06-13T18:52:21Z","body":"I'm working on a fix for this, but I'm struggling with the final portion. With this code:\r\n\r\n```rust\r\nstruct Cat<F> where F: FnMut() -> u32 {\r\n    func: F,\r\n    x: i32\r\n}\r\n\r\ntrait Meow {\r\n    fn mew(&self) -> i32;\r\n}\r\n\r\nimpl Meow for Cat {\r\n    fn mew(&self) -> i32 {\r\n        self.x\r\n    }\r\n}\r\n\r\nfn main() {\r\n    let kitty = Cat { func: || 5, x: 5 };\r\n    assert!(kitty.x() == 5);\r\n    let x = kitty.func();\r\n    assert_eq!(x, 5);\r\n}\r\n```\r\n\r\nI get the output:\r\n\r\n```\r\n<anon>:18:19: 18:22 error: type `Cat` does not implement any method in scope named `x`\r\n<anon>:18     assert!(kitty.x() == 5);\r\n                            ^~~\r\n<anon>:18:19: 18:22 note: did you mean to write `Cat.x`?\r\n<anon>:18     assert!(kitty.x() == 5);\r\n                            ^~~\r\n<anon>:19:19: 19:25 error: type `Cat` does not implement any method in scope named `func`\r\n<anon>:19     let x = kitty.func();\r\n                            ^~~~~~\r\n<anon>:19:19: 19:25 note: use `(Cat.func)(...)` if you meant to call the function stored in the `func` field\r\n<anon>:19     let x = kitty.func();\r\n                            ^~~~~~\r\n```\r\n\r\nMy current changes are [here](https://github.com/rust-lang/rust/compare/master...Nashenas88:field-method-message-2392). I'm not sure if it's possible to have the output say \"kitty.func\" and \"kitty.x\" with the input to the `report_error` function. Any ideas? Or should I just keep the message in the same format as it is now and output \"s.func\" and \"did you mean to write `s.x`?\"?"}}