Tweak output on E0599 for assoc fn used as method#51135
Tweak output on E0599 for assoc fn used as method#51135bors merged 5 commits intorust-lang:masterfrom
Conversation
When encountering an unexisting method for a given trait where an associated function has the same name, suggest using the appropriate syntax, instead of using `help` text. When only one candidate is found, do not call it "candidate rust-lang#1", just call it "the candidate".
|
(rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
oli-obk
left a comment
There was a problem hiding this comment.
Doesn't need to be acted upon in this PR, just some thoughts of what we should think about in the future
| if static_sources.len() == 1 { | ||
| if let Some(expr) = rcvr_expr { | ||
| err.span_suggestion(expr.span.to(span), | ||
| "use associated function syntax intead", |
| } | ||
| if static_sources.len() == 1 { | ||
| if let Some(expr) = rcvr_expr { | ||
| err.span_suggestion(expr.span.to(span), |
There was a problem hiding this comment.
Why is only the single source case a suggestion?
| } else { | ||
| let limit = if candidates.len() == 5 { 5 } else { 4 }; | ||
| for (i, trait_did) in candidates.iter().take(limit).enumerate() { | ||
| msg.push_str(&format!("\ncandidate #{}: `use {};`", |
There was a problem hiding this comment.
These should probably become a real suggestion, in which case you don't need manual limiting anymore, because the renderer takes care of that
There was a problem hiding this comment.
The suggestions for inserting use statements do that already
There was a problem hiding this comment.
Suggestions currently do not preserve their position in the output, they always come at then end. I need to change that for the first requested fix.
|
r? @oli-obk |
|
ping @oli-obk |
|
@bors r+ |
|
📌 Commit 59b03b1 has been approved by |
Tweak output on E0599 for assoc fn used as method - Use suggestion instead of `help` when possible - Add primary span label - Remove incorrect `help` suggestion using incorrect syntax - Do not refer to only one possible candidate as `candidate #1`, refer to it as `the candidate`
Rollup of 5 pull requests Successful merges: - #51135 (Tweak output on E0599 for assoc fn used as method) - #51152 (Replace `if` with `if and only if` in the definition dox of `Sync`) - #51262 (Add missing whitespace in num example) - #51272 (Remove feature flag from fs::read_to_string example) - #51286 (Pull 1.26.2 release notes into master) Failed merges:
|
💥 Test timed out |
helpwhen possiblehelpsuggestion using incorrect syntaxcandidate #1, refer to it asthe candidate