-
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
More helpful note message when confusing a field with a method #26305
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @huonw (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
// Determine if the field can be used as a function in some way | ||
let fn_once_trait_did = match cx.lang_items.require(FnOnceTraitLangItem) { | ||
Ok(trait_did) => trait_did, | ||
Err(err) => cx.sess.fatal(&err[..]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should fall back gracefully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that. I meant to ask about this case before submitting the PR, but I forgot. What should I do here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either display the message unconditionally, or only if the type is a function pointer or closure, or never display the message.
3a555ef
to
57bafa2
Compare
cx.sess.span_note(span, &format!("did you mean to write `{0}.{1}`?", | ||
expr_string, item_ustring)); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to ask before pushing these changes, is it alright to use a macro here? Is a closure preferred?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say closures are preferred.
☔ The latest upstream changes (presumably #26351) made this pull request unmergeable. Please resolve the merge conflicts. |
…d tests to new file and updated tests
…nd moved tests to new file and updated tests
…ire error with a fallback, renamed variable to something clearer
…it require error with a fallback, renamed variable to something clearer
a96fe74
to
bae1df6
Compare
bump |
I'm unfamiliar with the best ways to drive the type checker for stuff like this, maybe @nikomatsakis or @eddyb are better reviewers. r? @eddyb |
He can make the final determination then. :) |
@bors r+ |
📌 Commit bae1df6 has been approved by |
This fixes #2392
I'd like to thank @eddyb for helping me on this one! I wouldn't have gotten the complicated FnOnce check done without his help.