Skip to content

Commit 5d1796a

Browse files
committed
soften the wording for removing type ascription
1 parent 0fe1ff2 commit 5d1796a

14 files changed

+16
-23
lines changed

compiler/rustc_builtin_macros/src/asm.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ pub fn parse_asm_args<'a>(
6868
if !p.eat(&token::Comma) {
6969
if allow_templates {
7070
// After a template string, we always expect *only* a comma...
71-
let mut err = diag.create_err(errors::AsmExpectedComma { span: p.token.span });
72-
return Err(err);
71+
return Err(diag.create_err(errors::AsmExpectedComma { span: p.token.span }));
7372
} else {
7473
// ...after that delegate to `expect` to also include the other expected tokens.
7574
return Err(p.expect(&token::Comma).err().unwrap());

compiler/rustc_parse/messages.ftl

+2-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,8 @@ parse_path_single_colon = path separator must be a double colon
426426
parse_colon_as_semi = statements are terminated with a semicolon
427427
.suggestion = use a semicolon instead
428428
429-
parse_type_ascription_removed = type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
429+
parse_type_ascription_removed =
430+
if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
430431
431432
parse_where_clause_before_tuple_struct_body = where clauses are not allowed before tuple struct bodies
432433
.label = unexpected where clause

compiler/rustc_parse/src/parser/diagnostics.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -1569,14 +1569,9 @@ impl<'a> Parser<'a> {
15691569
}
15701570

15711571
pub(super) fn expect_semi(&mut self) -> PResult<'a, ()> {
1572-
if self.eat(&token::Semi) {
1572+
if self.eat(&token::Semi) || self.recover_colon_as_semi() {
15731573
return Ok(());
15741574
}
1575-
1576-
if self.recover_colon_as_semi() {
1577-
return Ok(());
1578-
}
1579-
15801575
self.expect(&token::Semi).map(drop) // Error unconditionally
15811576
}
15821577

@@ -1597,9 +1592,7 @@ impl<'a> Parser<'a> {
15971592
span: self.token.span,
15981593
type_ascription: self.sess.unstable_features.is_nightly_build().then_some(()),
15991594
});
1600-
16011595
self.bump();
1602-
16031596
return true;
16041597
}
16051598

compiler/rustc_parse/src/parser/path.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_ast::{
99
AssocConstraintKind, BlockCheckMode, GenericArg, GenericArgs, Generics, ParenthesizedArgs,
1010
Path, PathSegment, QSelf,
1111
};
12-
use rustc_errors::{pluralize, Applicability, IntoDiagnostic, PResult};
12+
use rustc_errors::{Applicability, IntoDiagnostic, PResult};
1313
use rustc_span::source_map::{BytePos, Span};
1414
use rustc_span::symbol::{kw, sym, Ident};
1515
use std::mem;

compiler/rustc_parse/src/parser/stmt.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ impl<'a> Parser<'a> {
645645

646646
if self.recover_colon_as_semi() {
647647
// recover_colon_as_semi has already emitted a nicer error.
648-
e.cancel();
648+
e.delay_as_bug();
649649
add_semi_to_stmt = true;
650650
eat_semi = false;
651651

@@ -672,7 +672,7 @@ impl<'a> Parser<'a> {
672672
};
673673
match self.parse_expr_labeled(label, false) {
674674
Ok(labeled_expr) => {
675-
e.cancel();
675+
e.delay_as_bug();
676676
self.sess.emit_err(MalformedLoopLabel {
677677
span: label.ident.span,
678678
correct_label: label.ident,

tests/ui/generics/single-colon-path-not-const-generics.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | pub struct Foo {
66
LL | a: Vec<foo::bar:A>,
77
| ^ help: use a double colon instead: `::`
88
|
9-
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
9+
= note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
1010

1111
error: aborting due to previous error
1212

tests/ui/suggestions/type-ascription-instead-of-method.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: path separator must be a double colon
44
LL | let _ = Box:new("foo".to_string());
55
| ^ help: use a double colon instead: `::`
66
|
7-
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
7+
= note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
88

99
error: aborting due to previous error
1010

tests/ui/suggestions/type-ascription-instead-of-path.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: path separator must be a double colon
44
LL | std:io::stdin();
55
| ^ help: use a double colon instead: `::`
66
|
7-
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
7+
= note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
88

99
error: aborting due to previous error
1010

tests/ui/suggestions/type-ascription-instead-of-variant.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: path separator must be a double colon
44
LL | let _ = Option:Some("");
55
| ^ help: use a double colon instead: `::`
66
|
7-
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
7+
= note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
88

99
error: aborting due to previous error
1010

tests/ui/type/ascription/issue-47666.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: path separator must be a double colon
44
LL | let _ = Option:Some(vec![0, 1]);
55
| ^ help: use a double colon instead: `::`
66
|
7-
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
7+
= note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
88

99
error: aborting due to previous error
1010

tests/ui/type/ascription/issue-54516.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: path separator must be a double colon
44
LL | println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>());
55
| ^ help: use a double colon instead: `::`
66
|
7-
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
7+
= note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
88

99
error: aborting due to previous error
1010

tests/ui/type/ascription/issue-60933.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: path separator must be a double colon
44
LL | let _: usize = std::mem:size_of::<u32>();
55
| ^ help: use a double colon instead: `::`
66
|
7-
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
7+
= note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
88

99
error: aborting due to previous error
1010

tests/ui/type/type-ascription-instead-of-statement-end.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: statements are terminated with a semicolon
44
LL | println!("test"):
55
| ^ help: use a semicolon instead: `;`
66
|
7-
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
7+
= note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
88

99
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:`
1010
--> $DIR/type-ascription-instead-of-statement-end.rs:7:21

tests/ui/type/type-ascription-with-fn-call.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: statements are terminated with a semicolon
44
LL | f() :
55
| ^ help: use a semicolon instead: `;`
66
|
7-
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
7+
= note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
88

99
error: aborting due to previous error
1010

0 commit comments

Comments
 (0)