Skip to content

Commit

Permalink
Reword type ascription note to reduce verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Mar 23, 2019
1 parent 44a086e commit d72ef21
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 65 deletions.
6 changes: 1 addition & 5 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3708,11 +3708,7 @@ impl<'a> Parser<'a> {
you annotate an expression with a type: `<expr>: <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");
}
Expand Down
14 changes: 2 additions & 12 deletions src/test/ui/error-codes/E0423.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<expr>: <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 `==`
Expand All @@ -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: `<expr>: <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`
Expand Down
7 changes: 1 addition & 6 deletions src/test/ui/issues/issue-22644.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<expr>: <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
Expand Down
7 changes: 1 addition & 6 deletions src/test/ui/issues/issue-34255-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<expr>: <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
Expand Down
7 changes: 1 addition & 6 deletions src/test/ui/lifetime_starts_expressions.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<expr>: <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
Expand Down
7 changes: 1 addition & 6 deletions src/test/ui/parser/struct-literal-in-for.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<expr>: <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 `{`
Expand Down
7 changes: 1 addition & 6 deletions src/test/ui/parser/struct-literal-in-if.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<expr>: <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 `{`
Expand Down
7 changes: 1 addition & 6 deletions src/test/ui/parser/struct-literal-in-while.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<expr>: <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 `{`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<expr>: <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 `{`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<expr>: <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
Expand Down

0 comments on commit d72ef21

Please sign in to comment.