-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Improve fn pointer notes #107287
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Improve fn pointer notes #107287
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @compiler-errors (or someone else) soon. Please see the contribution instructions for more information. |
1371c1c
to
78c2035
Compare
Some changes occurred in src/tools/cargo cc @ehuss |
78c2035
to
80d9aea
Compare
rebased onto master and ready for review |
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.
Just the one suggestion from me; otherwise looks good!
} | ||
}; | ||
let msg = format!( | ||
"consider casting the expected and found fn items to fn pointers, i.e. `{}` and the following suggestion", |
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.
"consider casting the expected and found fn items to fn pointers, i.e. `{}` and the following suggestion", | |
"consider casting both fn items to fn pointers using `as ....`", |
(fill in the ....
with just the signature they need to be casted to)
And then perhaps using https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/diagnostic/struct.Diagnostic.html#method.span_suggestion_hidden
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.
Let me explain my thinking here: the phrasing "expected and found fn items" is a bit verbose, and "and the following suggestion" is a bit awkward. Let's avoid both by just explaining the gist of what the user needs to do.
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.
Yeah, that explanation is much nicer to read. --verbose
is my default and it has been much harder than expected to be concise.
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've applied the suggestions.
0a71c1d
to
6baec2c
Compare
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.
Thanks for following up on this, and for applying the suggestions.
@bors r+ rollup |
📌 Commit 6baec2c91668ae53a7631f10a911b4a1837710cf has been approved by It is now in the queue for this repository. |
Sorry for the back and forth, just one tiny nit I totally overlooked @bors r- |
- add note and suggestion for casting both expected and found fn items to fn pointers - add note for casting expected fn item to fn pointer
6baec2c
to
3016f55
Compare
ty @bors r+ |
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#97373 (impl DispatchFromDyn for Cell and UnsafeCell) - rust-lang#106625 (Remove backwards compat for LLVM 12 coverage format) - rust-lang#106779 (Avoid __cxa_thread_atexit_impl on Emscripten) - rust-lang#106811 (Append .dwp to the binary filename instead of replacing the existing extension.) - rust-lang#106836 (Remove optimistic spinning from `mpsc::SyncSender`) - rust-lang#106946 (implement Hash for proc_macro::LineColumn) - rust-lang#107074 (remove unnecessary check for opaque types) - rust-lang#107287 (Improve fn pointer notes) - rust-lang#107304 (Use `can_eq` to compare types for default assoc type error) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
continuation of #105552
r? @compiler-errors