From: Esteban Küber Date: Sat, 23 Mar 2019 03:14:20 +0000 (-0700) Subject: Reword type ascription note to reduce verbosity X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=d72ef21ddd4d56b3ec169a5ed64fa4cbf778c5c8;p=rust.git Reword type ascription note to reduce verbosity --- diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index d5b64eaaef5..ea81094a996 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3708,11 +3708,7 @@ fn bad_type_ascription( you annotate an expression with a type: `: `"); err.span_note( lhs_span, - "this expression is annotated with type ascription...", - ); - err.span_note( - cur_op_span, - "...due to this, which is why a type is expected after", + "this expression expects an ascribed type after the colon", ); err.help("this might be indicative of a syntax error elsewhere"); } diff --git a/src/test/ui/error-codes/E0423.stderr b/src/test/ui/error-codes/E0423.stderr index 29a264ba162..b0ef4e1b254 100644 --- a/src/test/ui/error-codes/E0423.stderr +++ b/src/test/ui/error-codes/E0423.stderr @@ -5,16 +5,11 @@ LL | if let S { x: _x, y: 2 } = S { x: 1, y: 2 } { println!("Ok"); } | ^ expecting a type here because of type ascription | = note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `: ` -note: this expression is annotated with type ascription... +note: this expression expects an ascribed type after the colon --> $DIR/E0423.rs:12:36 | LL | if let S { x: _x, y: 2 } = S { x: 1, y: 2 } { println!("Ok"); } | ^ -note: ...due to this, which is why a type is expected after - --> $DIR/E0423.rs:12:37 - | -LL | if let S { x: _x, y: 2 } = S { x: 1, y: 2 } { println!("Ok"); } - | ^ = help: this might be indicative of a syntax error elsewhere error: expected expression, found `==` @@ -30,16 +25,11 @@ LL | for _ in std::ops::Range { start: 0, end: 10 } {} | ^ expecting a type here because of type ascription | = note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `: ` -note: this expression is annotated with type ascription... +note: this expression expects an ascribed type after the colon --> $DIR/E0423.rs:21:32 | LL | for _ in std::ops::Range { start: 0, end: 10 } {} | ^^^^^ -note: ...due to this, which is why a type is expected after - --> $DIR/E0423.rs:21:37 - | -LL | for _ in std::ops::Range { start: 0, end: 10 } {} - | ^ = help: this might be indicative of a syntax error elsewhere error[E0423]: expected function, found struct `Foo` diff --git a/src/test/ui/issues/issue-22644.stderr b/src/test/ui/issues/issue-22644.stderr index 5d40909f097..a28ea0d09f8 100644 --- a/src/test/ui/issues/issue-22644.stderr +++ b/src/test/ui/issues/issue-22644.stderr @@ -90,16 +90,11 @@ LL | println!("{}", a: &mut 4); | ^ expecting a type here because of type ascription | = note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `: ` -note: this expression is annotated with type ascription... +note: this expression expects an ascribed type after the colon --> $DIR/issue-22644.rs:34:20 | LL | println!("{}", a: &mut 4); | ^ -note: ...due to this, which is why a type is expected after - --> $DIR/issue-22644.rs:34:21 - | -LL | println!("{}", a: &mut 4); - | ^ = help: this might be indicative of a syntax error elsewhere error: aborting due to 9 previous errors diff --git a/src/test/ui/issues/issue-34255-1.stderr b/src/test/ui/issues/issue-34255-1.stderr index 15779705426..7899c8d30f1 100644 --- a/src/test/ui/issues/issue-34255-1.stderr +++ b/src/test/ui/issues/issue-34255-1.stderr @@ -5,16 +5,11 @@ LL | Test::Drill(field: 42); | ^^ expecting a type here because of type ascription | = note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `: ` -note: this expression is annotated with type ascription... +note: this expression expects an ascribed type after the colon --> $DIR/issue-34255-1.rs:8:17 | LL | Test::Drill(field: 42); | ^^^^^ -note: ...due to this, which is why a type is expected after - --> $DIR/issue-34255-1.rs:8:22 - | -LL | Test::Drill(field: 42); - | ^ = help: this might be indicative of a syntax error elsewhere error: aborting due to previous error diff --git a/src/test/ui/lifetime_starts_expressions.stderr b/src/test/ui/lifetime_starts_expressions.stderr index 850e3563cab..cb5a52a3e08 100644 --- a/src/test/ui/lifetime_starts_expressions.stderr +++ b/src/test/ui/lifetime_starts_expressions.stderr @@ -15,16 +15,11 @@ LL | loop { break 'label: loop { break 'label 42; }; } | ^^^^ expecting a type here because of type ascription | = note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `: ` -note: this expression is annotated with type ascription... +note: this expression expects an ascribed type after the colon --> $DIR/lifetime_starts_expressions.rs:6:12 | LL | loop { break 'label: loop { break 'label 42; }; } | ^^^^^^^^^^^^ -note: ...due to this, which is why a type is expected after - --> $DIR/lifetime_starts_expressions.rs:6:24 - | -LL | loop { break 'label: loop { break 'label 42; }; } - | ^ = help: this might be indicative of a syntax error elsewhere error: aborting due to 2 previous errors diff --git a/src/test/ui/parser/struct-literal-in-for.stderr b/src/test/ui/parser/struct-literal-in-for.stderr index 9056fac4226..07f2e41ac4f 100644 --- a/src/test/ui/parser/struct-literal-in-for.stderr +++ b/src/test/ui/parser/struct-literal-in-for.stderr @@ -5,16 +5,11 @@ LL | x: 3 | ^ expecting a type here because of type ascription | = note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `: ` -note: this expression is annotated with type ascription... +note: this expression expects an ascribed type after the colon --> $DIR/struct-literal-in-for.rs:13:9 | LL | x: 3 | ^ -note: ...due to this, which is why a type is expected after - --> $DIR/struct-literal-in-for.rs:13:10 - | -LL | x: 3 - | ^ = help: this might be indicative of a syntax error elsewhere error: expected one of `.`, `;`, `?`, `}`, or an operator, found `{` diff --git a/src/test/ui/parser/struct-literal-in-if.stderr b/src/test/ui/parser/struct-literal-in-if.stderr index 558f5a15cc5..3dd61e74f12 100644 --- a/src/test/ui/parser/struct-literal-in-if.stderr +++ b/src/test/ui/parser/struct-literal-in-if.stderr @@ -5,16 +5,11 @@ LL | x: 3 | ^ expecting a type here because of type ascription | = note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `: ` -note: this expression is annotated with type ascription... +note: this expression expects an ascribed type after the colon --> $DIR/struct-literal-in-if.rs:13:9 | LL | x: 3 | ^ -note: ...due to this, which is why a type is expected after - --> $DIR/struct-literal-in-if.rs:13:10 - | -LL | x: 3 - | ^ = help: this might be indicative of a syntax error elsewhere error: expected one of `.`, `;`, `?`, `}`, or an operator, found `{` diff --git a/src/test/ui/parser/struct-literal-in-while.stderr b/src/test/ui/parser/struct-literal-in-while.stderr index ae6e1d4577c..d48244654cd 100644 --- a/src/test/ui/parser/struct-literal-in-while.stderr +++ b/src/test/ui/parser/struct-literal-in-while.stderr @@ -5,16 +5,11 @@ LL | x: 3 | ^ expecting a type here because of type ascription | = note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `: ` -note: this expression is annotated with type ascription... +note: this expression expects an ascribed type after the colon --> $DIR/struct-literal-in-while.rs:13:9 | LL | x: 3 | ^ -note: ...due to this, which is why a type is expected after - --> $DIR/struct-literal-in-while.rs:13:10 - | -LL | x: 3 - | ^ = help: this might be indicative of a syntax error elsewhere error: expected one of `.`, `;`, `?`, `}`, or an operator, found `{` diff --git a/src/test/ui/parser/struct-literal-restrictions-in-lamda.stderr b/src/test/ui/parser/struct-literal-restrictions-in-lamda.stderr index 6dbf7eb1b10..a8c93233dbc 100644 --- a/src/test/ui/parser/struct-literal-restrictions-in-lamda.stderr +++ b/src/test/ui/parser/struct-literal-restrictions-in-lamda.stderr @@ -5,16 +5,11 @@ LL | x: 3 | ^ expecting a type here because of type ascription | = note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `: ` -note: this expression is annotated with type ascription... +note: this expression expects an ascribed type after the colon --> $DIR/struct-literal-restrictions-in-lamda.rs:13:9 | LL | x: 3 | ^ -note: ...due to this, which is why a type is expected after - --> $DIR/struct-literal-restrictions-in-lamda.rs:13:10 - | -LL | x: 3 - | ^ = help: this might be indicative of a syntax error elsewhere error: expected one of `.`, `;`, `?`, `}`, or an operator, found `{` diff --git a/src/test/ui/type/type-ascription-instead-of-statement-end.stderr b/src/test/ui/type/type-ascription-instead-of-statement-end.stderr index c80056e4487..2084cbcce4f 100644 --- a/src/test/ui/type/type-ascription-instead-of-statement-end.stderr +++ b/src/test/ui/type/type-ascription-instead-of-statement-end.stderr @@ -13,16 +13,11 @@ LL | println!("test"): 0; | ^ expecting a type here because of type ascription | = note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `: ` -note: this expression is annotated with type ascription... +note: this expression expects an ascribed type after the colon --> $DIR/type-ascription-instead-of-statement-end.rs:9:5 | LL | println!("test"): 0; | ^^^^^^^^^^^^^^^^ -note: ...due to this, which is why a type is expected after - --> $DIR/type-ascription-instead-of-statement-end.rs:9:21 - | -LL | println!("test"): 0; - | ^ = help: this might be indicative of a syntax error elsewhere error: aborting due to 2 previous errors