-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Wrap dyn type with parentheses in suggestion #120929
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bd3356b
to
62a7989
Compare
@fmease Could you review this PR? Thank you. |
Sure, I plan on reviewing this later today. Sorry for taking a bit, I'm assigned to several PRs and I continuously work on PRs myself ^^' |
☔ The latest upstream changes (presumably #121549) made this pull request unmergeable. Please resolve the merge conflicts. |
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'm sorry for leaving you hanging like that! I have a couple of suggestions for how to structure this a bit differently and some correctness things.
At the moment your changes only trigger in very few cases. I think we should generalize it to apply to more + XXX
-style suggestions.
First and foremost, I would check the other 3 usage sites bounds_span_for_suggestion
whether they could benefit from this, too (I even suggest you to merge bounds_span_for_suggestion_with_parentheses
into it in one of my review comments). You could even consider grep
'ing through tests/ui/
to check if there are any other incorrect consider adding an explicit lifetime bound suggestions.
In summary, I'm a fan of fixing the incorrect diagnostic suggestion but I'd like to make sure to tap the full potential.
@fmease Thank you for detailed review! I will fix them and check for more patterns in a couple of days. |
62a7989
to
2b03887
Compare
This comment has been minimized.
This comment has been minimized.
I will fix testing failure at first. |
@rustbot review |
67e91e9
to
c1ccb05
Compare
I checked them:
I searched I think incorrect suggestions which need parentheses happen with only |
This comment has been minimized.
This comment has been minimized.
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 a lot!
First and foremost, I would check the other 3 usage sites
bounds_span_for_suggestion
whether they could benefit from this, too.
I could find an example for each usage site. Please make them use open_paren_sp
as well, thanks! :)
After that, this PR should be good to go! One more thing, could you squash the commits into one (or fewer) commits?
compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs
Outdated
Show resolved
Hide resolved
9e0d856
to
f0114a1
Compare
@fmease |
@rustbot ready |
This comment has been minimized.
This comment has been minimized.
CI still has errors, please fix them. If you have any questions regarding the failures, don't hesitate to reach out and ask them! |
This comment has been minimized.
This comment has been minimized.
40b99a9
to
31e581e
Compare
@fmease Thank you! All tests are passed. |
@bors r+ rollup |
Rollup of 7 pull requests Successful merges: - rust-lang#120929 (Wrap dyn type with parentheses in suggestion) - rust-lang#122591 (Suggest using type args directly instead of equality constraint) - rust-lang#122598 (deref patterns: lower deref patterns to MIR) - rust-lang#123048 (alloc::Layout: explicitly document size invariant on the type level) - rust-lang#123993 (Do `check_coroutine_obligations` once per typeck root) - rust-lang#124218 (Allow nesting subdiagnostics in #[derive(Subdiagnostic)]) - rust-lang#124285 (Mark ``@RUSTC_BUILTIN`` search path usage as unstable) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#120929 - long-long-float:wrap-dyn-in-suggestion, r=fmease Wrap dyn type with parentheses in suggestion Close rust-lang#120223 Fix wrong suggestion that is grammatically incorrect. Specifically, I added parentheses to dyn types that need lifetime bound. ``` help: consider adding an explicit lifetime bound | 4 | executor: impl FnOnce(T) -> (dyn Future<Output = ()>) + 'static, | + +++++++++++ ```
Close #120223
Fix wrong suggestion that is grammatically incorrect.
Specifically, I added parentheses to dyn types that need lifetime bound.