Skip to content

Commit d72ef21

Browse files
committed
Reword type ascription note to reduce verbosity
1 parent 44a086e commit d72ef21

10 files changed

+11
-65
lines changed

src/libsyntax/parse/parser.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -3708,11 +3708,7 @@ impl<'a> Parser<'a> {
37083708
you annotate an expression with a type: `<expr>: <type>`");
37093709
err.span_note(
37103710
lhs_span,
3711-
"this expression is annotated with type ascription...",
3712-
);
3713-
err.span_note(
3714-
cur_op_span,
3715-
"...due to this, which is why a type is expected after",
3711+
"this expression expects an ascribed type after the colon",
37163712
);
37173713
err.help("this might be indicative of a syntax error elsewhere");
37183714
}

src/test/ui/error-codes/E0423.stderr

+2-12
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@ LL | if let S { x: _x, y: 2 } = S { x: 1, y: 2 } { println!("Ok"); }
55
| ^ expecting a type here because of type ascription
66
|
77
= note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `<expr>: <type>`
8-
note: this expression is annotated with type ascription...
8+
note: this expression expects an ascribed type after the colon
99
--> $DIR/E0423.rs:12:36
1010
|
1111
LL | if let S { x: _x, y: 2 } = S { x: 1, y: 2 } { println!("Ok"); }
1212
| ^
13-
note: ...due to this, which is why a type is expected after
14-
--> $DIR/E0423.rs:12:37
15-
|
16-
LL | if let S { x: _x, y: 2 } = S { x: 1, y: 2 } { println!("Ok"); }
17-
| ^
1813
= help: this might be indicative of a syntax error elsewhere
1914

2015
error: expected expression, found `==`
@@ -30,16 +25,11 @@ LL | for _ in std::ops::Range { start: 0, end: 10 } {}
3025
| ^ expecting a type here because of type ascription
3126
|
3227
= note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `<expr>: <type>`
33-
note: this expression is annotated with type ascription...
28+
note: this expression expects an ascribed type after the colon
3429
--> $DIR/E0423.rs:21:32
3530
|
3631
LL | for _ in std::ops::Range { start: 0, end: 10 } {}
3732
| ^^^^^
38-
note: ...due to this, which is why a type is expected after
39-
--> $DIR/E0423.rs:21:37
40-
|
41-
LL | for _ in std::ops::Range { start: 0, end: 10 } {}
42-
| ^
4333
= help: this might be indicative of a syntax error elsewhere
4434

4535
error[E0423]: expected function, found struct `Foo`

src/test/ui/issues/issue-22644.stderr

+1-6
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,11 @@ LL | println!("{}", a: &mut 4);
9090
| ^ expecting a type here because of type ascription
9191
|
9292
= note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `<expr>: <type>`
93-
note: this expression is annotated with type ascription...
93+
note: this expression expects an ascribed type after the colon
9494
--> $DIR/issue-22644.rs:34:20
9595
|
9696
LL | println!("{}", a: &mut 4);
9797
| ^
98-
note: ...due to this, which is why a type is expected after
99-
--> $DIR/issue-22644.rs:34:21
100-
|
101-
LL | println!("{}", a: &mut 4);
102-
| ^
10398
= help: this might be indicative of a syntax error elsewhere
10499

105100
error: aborting due to 9 previous errors

src/test/ui/issues/issue-34255-1.stderr

+1-6
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@ LL | Test::Drill(field: 42);
55
| ^^ expecting a type here because of type ascription
66
|
77
= note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `<expr>: <type>`
8-
note: this expression is annotated with type ascription...
8+
note: this expression expects an ascribed type after the colon
99
--> $DIR/issue-34255-1.rs:8:17
1010
|
1111
LL | Test::Drill(field: 42);
1212
| ^^^^^
13-
note: ...due to this, which is why a type is expected after
14-
--> $DIR/issue-34255-1.rs:8:22
15-
|
16-
LL | Test::Drill(field: 42);
17-
| ^
1813
= help: this might be indicative of a syntax error elsewhere
1914

2015
error: aborting due to previous error

src/test/ui/lifetime_starts_expressions.stderr

+1-6
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,11 @@ LL | loop { break 'label: loop { break 'label 42; }; }
1515
| ^^^^ expecting a type here because of type ascription
1616
|
1717
= note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `<expr>: <type>`
18-
note: this expression is annotated with type ascription...
18+
note: this expression expects an ascribed type after the colon
1919
--> $DIR/lifetime_starts_expressions.rs:6:12
2020
|
2121
LL | loop { break 'label: loop { break 'label 42; }; }
2222
| ^^^^^^^^^^^^
23-
note: ...due to this, which is why a type is expected after
24-
--> $DIR/lifetime_starts_expressions.rs:6:24
25-
|
26-
LL | loop { break 'label: loop { break 'label 42; }; }
27-
| ^
2823
= help: this might be indicative of a syntax error elsewhere
2924

3025
error: aborting due to 2 previous errors

src/test/ui/parser/struct-literal-in-for.stderr

+1-6
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@ LL | x: 3
55
| ^ expecting a type here because of type ascription
66
|
77
= note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `<expr>: <type>`
8-
note: this expression is annotated with type ascription...
8+
note: this expression expects an ascribed type after the colon
99
--> $DIR/struct-literal-in-for.rs:13:9
1010
|
1111
LL | x: 3
1212
| ^
13-
note: ...due to this, which is why a type is expected after
14-
--> $DIR/struct-literal-in-for.rs:13:10
15-
|
16-
LL | x: 3
17-
| ^
1813
= help: this might be indicative of a syntax error elsewhere
1914

2015
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `{`

src/test/ui/parser/struct-literal-in-if.stderr

+1-6
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@ LL | x: 3
55
| ^ expecting a type here because of type ascription
66
|
77
= note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `<expr>: <type>`
8-
note: this expression is annotated with type ascription...
8+
note: this expression expects an ascribed type after the colon
99
--> $DIR/struct-literal-in-if.rs:13:9
1010
|
1111
LL | x: 3
1212
| ^
13-
note: ...due to this, which is why a type is expected after
14-
--> $DIR/struct-literal-in-if.rs:13:10
15-
|
16-
LL | x: 3
17-
| ^
1813
= help: this might be indicative of a syntax error elsewhere
1914

2015
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `{`

src/test/ui/parser/struct-literal-in-while.stderr

+1-6
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@ LL | x: 3
55
| ^ expecting a type here because of type ascription
66
|
77
= note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `<expr>: <type>`
8-
note: this expression is annotated with type ascription...
8+
note: this expression expects an ascribed type after the colon
99
--> $DIR/struct-literal-in-while.rs:13:9
1010
|
1111
LL | x: 3
1212
| ^
13-
note: ...due to this, which is why a type is expected after
14-
--> $DIR/struct-literal-in-while.rs:13:10
15-
|
16-
LL | x: 3
17-
| ^
1813
= help: this might be indicative of a syntax error elsewhere
1914

2015
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `{`

src/test/ui/parser/struct-literal-restrictions-in-lamda.stderr

+1-6
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@ LL | x: 3
55
| ^ expecting a type here because of type ascription
66
|
77
= note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `<expr>: <type>`
8-
note: this expression is annotated with type ascription...
8+
note: this expression expects an ascribed type after the colon
99
--> $DIR/struct-literal-restrictions-in-lamda.rs:13:9
1010
|
1111
LL | x: 3
1212
| ^
13-
note: ...due to this, which is why a type is expected after
14-
--> $DIR/struct-literal-restrictions-in-lamda.rs:13:10
15-
|
16-
LL | x: 3
17-
| ^
1813
= help: this might be indicative of a syntax error elsewhere
1914

2015
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `{`

src/test/ui/type/type-ascription-instead-of-statement-end.stderr

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,11 @@ LL | println!("test"): 0;
1313
| ^ expecting a type here because of type ascription
1414
|
1515
= note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `<expr>: <type>`
16-
note: this expression is annotated with type ascription...
16+
note: this expression expects an ascribed type after the colon
1717
--> $DIR/type-ascription-instead-of-statement-end.rs:9:5
1818
|
1919
LL | println!("test"): 0;
2020
| ^^^^^^^^^^^^^^^^
21-
note: ...due to this, which is why a type is expected after
22-
--> $DIR/type-ascription-instead-of-statement-end.rs:9:21
23-
|
24-
LL | println!("test"): 0;
25-
| ^
2621
= help: this might be indicative of a syntax error elsewhere
2722

2823
error: aborting due to 2 previous errors

0 commit comments

Comments
 (0)