Skip to content

Commit

Permalink
Rollup merge of rust-lang#89202 - estebank:infer-call-type, r=oli-obk
Browse files Browse the repository at this point in the history
Resolve infered types when complaining about unexpected call type

```
error[E0618]: expected function, found `{integer}`
  --> $DIR/call-block.rs:2:13
   |
LL |     let _ = {42}();
   |             ^^^^--
   |             |
   |             call expression requires function
```
instead of
```
error[E0618]: expected function, found `_`
  --> $DIR/call-block.rs:2:13
   |
LL |     let _ = {42}();
   |             ^^^^--
   |             |
   |             call expression requires function
```
  • Loading branch information
Manishearth authored Sep 30, 2021
2 parents 57897da + 072d107 commit ff7b1c2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_typeck/src/check/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}

let callee_ty = self.resolve_vars_if_possible(callee_ty);
let mut err = type_error_struct!(
self.tcx.sess,
callee_expr.span,
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/typeck/call-block.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
let _ = {42}(); //~ ERROR expected function, found `{integer}`
}
11 changes: 11 additions & 0 deletions src/test/ui/typeck/call-block.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0618]: expected function, found `{integer}`
--> $DIR/call-block.rs:2:13
|
LL | let _ = {42}();
| ^^^^--
| |
| call expression requires function

error: aborting due to previous error

For more information about this error, try `rustc --explain E0618`.

0 comments on commit ff7b1c2

Please sign in to comment.