Diagnostics: show closure signatures (configurable)#20575
Diagnostics: show closure signatures (configurable)#20575ali90h wants to merge 2 commits intorust-lang:masterfrom
Conversation
|
Thanks! Instead of creating a |
2e4c11f to
5afd0b2
Compare
|
I personally think we should not switch this. Unlike other IDE features, the identity of a closure is important for mismatches (different closures are not the same). But if we do, a setting most likely will make sense, like we do for inlay hints (rust-analyzer.inlayHints.closureStyle). We can also unify the settings. |
Thanks! That hir-ty test came from an upstream commit slipped into my branch. I’ve rebased; this PR now only changes ide-diagnostics and the focused test. No hir-ty files are part of this PR anymore. |
…efault ClosureWithId; thread through CLI/bench initializers
Thank you, the update has been completed. No behavior change by default; setting |
|
IMO we should just do whatever rustc does here? |
Checked against |
ChayimFriedman2
left a comment
There was a problem hiding this comment.
Generally I'm onboard with this, but I do prefer to keep the current style the default (can be done by making inlayHints_closureStyle be Option<ClosureStyle> then matching on that).
Also, maybe we should rename the setting given it's no longer inlay-hint-only? Not sure.
| } | ||
| #[test] | ||
| fn shows_closure_signatures_in_mismatch() { | ||
| let mut config = crate::DiagnosticsConfig::test_sample(); |
There was a problem hiding this comment.
Struct update syntax (Struct { ..FOO }) is useful here.
| closure_style: match self.inlayHints_closureStyle() { | ||
| ClosureStyle::ImplFn => hir::ClosureStyle::ImplFn, | ||
| ClosureStyle::RustAnalyzer => hir::ClosureStyle::RANotation, | ||
| ClosureStyle::WithId => hir::ClosureStyle::ClosureWithId, | ||
| ClosureStyle::Hide => hir::ClosureStyle::Hide, | ||
| }, |
There was a problem hiding this comment.
Since inlay hints also do this conversion, better to extract it into a function (or a From implementation).
|
☔ The latest upstream changes (possibly #21804) made this pull request unmergeable. Please resolve the merge conflicts. |
Type-mismatch messages now respect the existing
rust-analyzer.inlayHints.closureStylesetting.Default stays{closure#…}. If users setImplFn, diagnostics renderimpl Fn…signatures.closure_styletoDiagnosticsConfig(defaultClosureWithId)ctx.config.closure_stylein the type-mismatch handlerinlayHints.closureStyle(no new setting)Before / After
Example 1
Code
Before
After
(with ImplFn):Example 2
Code
Before
After
(with ImplFn):Refs #20555