diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2021-09-30 18:05:21 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-30 18:05:21 -0700 |
| commit | b437be45ea74905298b046b521a328b0d7899511 (patch) | |
| tree | 96f5ebb0af818e42385053d975a0480c6dfe0e37 | |
| parent | 3d86aac990c0310726da05fe1fdb5827ccfc495d (diff) | |
| parent | 072d107b438207e2c2c83fdf8c22bb5e8699138e (diff) | |
| download | rust-b437be45ea74905298b046b521a328b0d7899511.tar.gz rust-b437be45ea74905298b046b521a328b0d7899511.zip | |
Rollup merge of #89202 - estebank:infer-call-type, r=oli-obk
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
```
| -rw-r--r-- | compiler/rustc_typeck/src/check/callee.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/typeck/call-block.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/typeck/call-block.stderr | 11 |
3 files changed, 15 insertions, 0 deletions
diff --git a/compiler/rustc_typeck/src/check/callee.rs b/compiler/rustc_typeck/src/check/callee.rs index e007d971bb0..4ffb061f7b4 100644 --- a/compiler/rustc_typeck/src/check/callee.rs +++ b/compiler/rustc_typeck/src/check/callee.rs @@ -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, diff --git a/src/test/ui/typeck/call-block.rs b/src/test/ui/typeck/call-block.rs new file mode 100644 index 00000000000..0390d7db040 --- /dev/null +++ b/src/test/ui/typeck/call-block.rs @@ -0,0 +1,3 @@ +fn main() { + let _ = {42}(); //~ ERROR expected function, found `{integer}` +} diff --git a/src/test/ui/typeck/call-block.stderr b/src/test/ui/typeck/call-block.stderr new file mode 100644 index 00000000000..68984bc1c45 --- /dev/null +++ b/src/test/ui/typeck/call-block.stderr @@ -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`. |
