-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Only suggest removing semicolon when expression is compatible with impl Trait
#95758
Conversation
r? @estebank (rust-highfive has picked a reviewer for you, use r? to override) |
oh, hey, it r?'ed the person i was gonna cc in this followup comment... that being said, @estebank, I don't know the context that you have in this FIXME: // FIXME(estebank): When encountering a method with a trait
// bound not satisfied in the return type with a body that has
// no return, suggest removal of semicolon on last statement.
// Once that is added, close #54771. What more work needs to be done to improve this? I'd love to investigate more. |
LL | fn bar() -> impl Bar { | ||
| ^^^^^^^^ the trait `Bar` is not implemented for `()` |
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.
Should we add a span label pointing at the last statement saying "this is a statement, which are always of type ()
" and maybe mention the type of the expression in that statement if it were a tail expression, explaining that it doesn't match the trait?
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
Outdated
Show resolved
Hide resolved
r=me after removing unnecessary comment. Feel free to address some of the nitpicks at your leisure. |
f8f4c1a
to
dfe13db
Compare
Also changed the equiavlent "consider removing semicolon" to just say "remove" (e.g. @bors r=estebank |
📌 Commit dfe13db has been approved by |
…bank Only suggest removing semicolon when expression is compatible with `impl Trait` rust-lang#54771 (comment) > It still needs checking that the last statement's expr can actually conform to the trait, but the naïve behavior is there. Only suggest removing a semicolon when the type behind the semicolon actually implements the trait in an RPIT `-> impl Trait`. Also upgrade the label that suggests removing the semicolon to a suggestion (should it be verbose?). cc rust-lang#54771
…bank Only suggest removing semicolon when expression is compatible with `impl Trait` rust-lang#54771 (comment) > It still needs checking that the last statement's expr can actually conform to the trait, but the naïve behavior is there. Only suggest removing a semicolon when the type behind the semicolon actually implements the trait in an RPIT `-> impl Trait`. Also upgrade the label that suggests removing the semicolon to a suggestion (should it be verbose?). cc rust-lang#54771
…bank Only suggest removing semicolon when expression is compatible with `impl Trait` rust-lang#54771 (comment) > It still needs checking that the last statement's expr can actually conform to the trait, but the naïve behavior is there. Only suggest removing a semicolon when the type behind the semicolon actually implements the trait in an RPIT `-> impl Trait`. Also upgrade the label that suggests removing the semicolon to a suggestion (should it be verbose?). cc rust-lang#54771
…bank Only suggest removing semicolon when expression is compatible with `impl Trait` rust-lang#54771 (comment) > It still needs checking that the last statement's expr can actually conform to the trait, but the naïve behavior is there. Only suggest removing a semicolon when the type behind the semicolon actually implements the trait in an RPIT `-> impl Trait`. Also upgrade the label that suggests removing the semicolon to a suggestion (should it be verbose?). cc rust-lang#54771
⌛ Testing commit dfe13db with merge 6a4851f22a7d3cd2b908b9e3a3cd8daff692da07... |
@bors retry yield to rollup containing this pr |
☀️ Test successful - checks-actions |
#54771 (comment)
Only suggest removing a semicolon when the type behind the semicolon actually implements the trait in an RPIT
-> impl Trait
. Also upgrade the label that suggests removing the semicolon to a suggestion (should it be verbose?).cc #54771