-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
All callable types could have better error messages in the "no method found" case to suggest that you may have forgotten to actually call them #29124
Comments
I feel like this would be a great way for me to simultaneously start getting to know the compiler and to contribute to rust, so I'd like to take a look at this this evening. Would anyone be willing to mentor should I need it? |
@djrollins note that I only think that this should be an easy task, I don't have enough experience with the compiler to know that it's easy. :) Theoretically you should only need to find where the compiler is printing that specific error message, then add a "note" when the type mentioned in the error message implements any of For any compiler hacking, I'd recommend joining the #rust-internals IRC channel and casting around in there as you think of questions. That's also probably the best place to find a mentor. Good luck! :) |
I've given it a go trying to match the type to a TyBareFn as I wasn't sure how I could check for trait implementations with the information available on MethodError. Should I try and get someone to look at it on my fork or should I make a pull request? |
There's a callable check here which you can try to use. Might be worth moving that out as a utility. |
@djrollins I actually wrote the portion of code referenced by @Manishearth. I wrote a blog post detailing the changes here, which should help out if you're unfamiliar with the compiler. There's no guarantee that those portions of the compiler will be the same, but from what I saw in @Manishearth's link, the important parts are still the same. I haven't worked with the compiler in a little while, but I should still be able to help explain some portions if you need help. |
Thank you all for all of the advice so far. @Nashenas88 I took the time to read your blog, it was a great read and very informative; I'm going to sit down and go through it again at the weekend before taking another punt at this issue. |
Are you still working on this? |
Hey @Manishearth. Sorry, I've not actively looked at it for a while and let it slip away from me. I do want to carry on tackling this issue though if that's OK. |
I'd like to give this a shot @Manishearth -- can I reach you in irc? |
Yes, but @djrollins is already working on this. Try #31686 instead? |
Fixes issue rust-lang#29124. If method is called on a function type a note is generated to suggest that the developer may have forgotten to call it. e.g. fn main() { let mut guess = String::new(); std::io::stdin.read_line(&mut guess); } will generate the note: note: called method on function type. did you mean `std::io::stdin().read_line(..)`?
@vegai - are you still working on this? I wouldn't mind picking it up if you've moved on, though if you're still working on it no worries :) |
@jonathandturner this landed as #32053 / #32358 😄 |
Taking a real-life example from #rust today:
Yields the following error message:
The problem is that the code should read
stdin().read_line
rather thanstdin.read_line
, but the error message only hints at that. How hard would it be to add a note to all "no method found" errors when the type is callable?The text was updated successfully, but these errors were encountered: