-
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
Suggest call fn ctor passed as arg to fn with type param bounds #63870
Conversation
r? @varkor (rust_highfive has picked a reviewer for you, use r? to override) |
Future work: keep accurate obligation spans for type bounds associated to specific fn arguments to point at the argument instead of the ident of the fn call. CC @oli-obk |
This comment has been minimized.
This comment has been minimized.
928e528
to
3129bc8
Compare
ping |
LL | bar(foo); | ||
| ^^^ the trait `T` is not implemented for `fn() -> impl T {foo}` | ||
| | ||
= help: it looks like you forgot to use parentheses to call the function: `foo()` |
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.
In case anyone is wondering why this is not a suggestion on foo
's span: the error itself is already wrongly highlighting the bar
function instead of its foo
argument. That's a longstanding issue, but we have some ideas on how to continue with it.
📌 Commit eb21c09edd79cb46625ca2f633dbe5fd7eee55b6 has been approved by |
⌛ Testing commit eb21c09edd79cb46625ca2f633dbe5fd7eee55b6 with merge 9e2c72f0c0fc8b9cc8c8dc738b1b92277fddcbc8... |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
💔 Test failed - checks-azure |
@bors retry 😅
|
⌛ Testing commit eb21c09edd79cb46625ca2f633dbe5fd7eee55b6 with merge 544cc59e7f4607dc9f061b849cef01a1fe4edba3... |
💔 Test failed - checks-azure |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
💔 Test failed - checks-azure |
@bors retry |
@bors r=oli-obk |
📌 Commit ae93fa90a8f1d899372a0251dc6110f9b971cd1e has been approved by |
⌛ Testing commit ae93fa90a8f1d899372a0251dc6110f9b971cd1e with merge 4e180593b75b6fc0a1fb8ec6c3146ab6ef05b389... |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
💔 Test failed - checks-azure |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
ae93fa9
to
e553051
Compare
@bors r=oli-obk |
📌 Commit e553051 has been approved by |
Suggest call fn ctor passed as arg to fn with type param bounds _Reviewer note: the relevant changes are in the second commit, the first is simple and mechanical, but verbose._ When forgetting to call a fn in an argument position to an fn that has a generic bound: ```rust async fn foo() {} fn bar(f: impl Future<Output=()>) {} fn main() { bar(foo); // <- should be `bar(foo());` } ``` suggest calling it: ``` error[E0277]: the trait bound `fn() -> impl std::future::Future {foo}: std::future::Future` is not satisfied --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:9:5 | LL | fn bar(f: impl Future<Output=()>) {} | --------------------------------- required by `bar` ... LL | bar(foo); | ^^^ the trait `std::future::Future` is not implemented for `fn() -> impl std::future::Future {foo}` | = help: it looks like you forgot to use parentheses to call the function: `foo()` ``` Fix #63100. Follow up to #63833 and #63337.
☀️ Test successful - checks-azure |
Reviewer note: the relevant changes are in the second commit, the first is simple and mechanical, but verbose.
When forgetting to call a fn in an argument position to an fn that has a generic bound:
suggest calling it:
Fix #63100. Follow up to #63833 and #63337.