Compiler Missing Hint Of Misusing Methods As Functions

I recently found that the compiler is missing a good hint of misusing methods as functions. For example, if there is fn foo(&self);, and I called bar::foo() instead of bar.foo() (the correct one), the compiler wil emit error[E0433]: failed to resolve: use of undeclared type or module 'val'. For your convenience, here goes a playground link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a737d2347b79083e0d6b0a85590f3999.

I think this should be improved, but I wonder whether this requires a RFC, and, if yes, does there exist any RFCs I can use as a guidance of writing the RFC. If not, then how would I contribute to Rust?

Besides, would anyone come up with a better idea of how this should be handled? As far as I see, a note would be attached if such mistake detected.

Sorry for any possible disturbance, but I am quite a newbie to Rust compiler, and I really need some guidance.

1 Like

Simply improving the error message doesn't require an RFC.

5 Likes

Please post an issue on the rust-lang/rust repository, providing a reasonably minimal example, the output, and suggestions for what you'd like to see. This seems entirely reasonable.

2 Likes