From f3e9b1a703203be4f375dc5fa3950b642a156ec7 Mon Sep 17 00:00:00 2001 From: "Zack M. Davis" Date: Sat, 10 Nov 2018 20:46:05 -0800 Subject: in which the E0618 "expected function" diagnostic gets a makeover Now the main span focuses on the erroneous not-a-function callee, while showing the entire call expression is relegated to a secondary span. In the case where the erroneous callee is itself a call, we point out the definition, and, if the call expression spans multiple lines, tentatively suggest a semicolon (because we suspect that the "outer" call is actually supposed to be a tuple). The new `bug!` assertion is, in fact, safe (`confirm_builtin_call` is only called by `check_call`, which is only called with a first arg of kind `ExprKind::Call` in `check_expr_kind`). Resolves #51055. --- src/test/ui/empty/empty-struct-unit-expr.stderr | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/test/ui/empty') diff --git a/src/test/ui/empty/empty-struct-unit-expr.stderr b/src/test/ui/empty/empty-struct-unit-expr.stderr index fff696fc80f..360e0c6f107 100644 --- a/src/test/ui/empty/empty-struct-unit-expr.stderr +++ b/src/test/ui/empty/empty-struct-unit-expr.stderr @@ -5,7 +5,9 @@ LL | struct Empty2; | -------------- `Empty2` defined here ... LL | let e2 = Empty2(); //~ ERROR expected function, found `Empty2` - | ^^^^^^^^ not a function + | ^^^^^^-- + | | + | call expression requires function error[E0618]: expected function, found enum variant `E::Empty4` --> $DIR/empty-struct-unit-expr.rs:26:14 @@ -14,7 +16,9 @@ LL | Empty4 | ------ `E::Empty4` defined here ... LL | let e4 = E::Empty4(); - | ^^^^^^^^^^^ not a function + | ^^^^^^^^^-- + | | + | call expression requires function help: `E::Empty4` is a unit variant, you need to write it without the parenthesis | LL | let e4 = E::Empty4; @@ -24,13 +28,17 @@ error[E0618]: expected function, found `empty_struct::XEmpty2` --> $DIR/empty-struct-unit-expr.rs:28:15 | LL | let xe2 = XEmpty2(); //~ ERROR expected function, found `empty_struct::XEmpty2` - | ^^^^^^^^^ not a function + | ^^^^^^^-- + | | + | call expression requires function error[E0618]: expected function, found enum variant `XE::XEmpty4` --> $DIR/empty-struct-unit-expr.rs:29:15 | LL | let xe4 = XE::XEmpty4(); - | ^^^^^^^^^^^^^ not a function + | ^^^^^^^^^^^-- + | | + | call expression requires function help: `XE::XEmpty4` is a unit variant, you need to write it without the parenthesis | LL | let xe4 = XE::XEmpty4; -- cgit 1.4.1-3-g733a5