diff options
| author | bors <bors@rust-lang.org> | 2019-09-01 18:04:49 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-09-01 18:04:49 +0000 | 
| commit | dfd43f0fdd4e6969c7d82c0670d70bf305fbccf8 (patch) | |
| tree | 31a87971a84ffc967645099773910d6498d0cb0b /src/test/ui/traits/trait-static-method-generic-inference.stderr | |
| parent | e29faf0d095a51f5a06cfc6208a914b13481e1fe (diff) | |
| parent | e5530519502baf3ae37fa94eda27c2461d8c94aa (diff) | |
| download | rust-dfd43f0fdd4e6969c7d82c0670d70bf305fbccf8.tar.gz rust-dfd43f0fdd4e6969c7d82c0670d70bf305fbccf8.zip  | |
Auto merge of #63870 - estebank:async-fn-call, r=oli-obk
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.
Diffstat (limited to 'src/test/ui/traits/trait-static-method-generic-inference.stderr')
| -rw-r--r-- | src/test/ui/traits/trait-static-method-generic-inference.stderr | 9 | 
1 files changed, 3 insertions, 6 deletions
diff --git a/src/test/ui/traits/trait-static-method-generic-inference.stderr b/src/test/ui/traits/trait-static-method-generic-inference.stderr index 390d21c4a69..a99536d31ef 100644 --- a/src/test/ui/traits/trait-static-method-generic-inference.stderr +++ b/src/test/ui/traits/trait-static-method-generic-inference.stderr @@ -1,14 +1,11 @@ error[E0283]: type annotations required: cannot resolve `_: base::HasNew<base::Foo>` --> $DIR/trait-static-method-generic-inference.rs:24:25 | +LL | fn new() -> T; + | -------------- required by `base::HasNew::new` +... LL | let _f: base::Foo = base::HasNew::new(); | ^^^^^^^^^^^^^^^^^ - | -note: required by `base::HasNew::new` - --> $DIR/trait-static-method-generic-inference.rs:8:9 - | -LL | fn new() -> T; - | ^^^^^^^^^^^^^^ error: aborting due to previous error  | 
