summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_builtin_macros/src/asm.rs3
-rw-r--r--compiler/rustc_parse/messages.ftl3
-rw-r--r--compiler/rustc_parse/src/parser/diagnostics.rs9
-rw-r--r--compiler/rustc_parse/src/parser/path.rs2
-rw-r--r--compiler/rustc_parse/src/parser/stmt.rs4
-rw-r--r--tests/ui/generics/single-colon-path-not-const-generics.stderr2
-rw-r--r--tests/ui/suggestions/type-ascription-instead-of-method.stderr2
-rw-r--r--tests/ui/suggestions/type-ascription-instead-of-path.stderr2
-rw-r--r--tests/ui/suggestions/type-ascription-instead-of-variant.stderr2
-rw-r--r--tests/ui/type/ascription/issue-47666.stderr2
-rw-r--r--tests/ui/type/ascription/issue-54516.stderr2
-rw-r--r--tests/ui/type/ascription/issue-60933.stderr2
-rw-r--r--tests/ui/type/type-ascription-instead-of-statement-end.stderr2
-rw-r--r--tests/ui/type/type-ascription-with-fn-call.stderr2
14 files changed, 16 insertions, 23 deletions
diff --git a/compiler/rustc_builtin_macros/src/asm.rs b/compiler/rustc_builtin_macros/src/asm.rs
index 3ccdc8179a5..0ea8454db08 100644
--- a/compiler/rustc_builtin_macros/src/asm.rs
+++ b/compiler/rustc_builtin_macros/src/asm.rs
@@ -68,8 +68,7 @@ pub fn parse_asm_args<'a>(
if !p.eat(&token::Comma) {
if allow_templates {
// After a template string, we always expect *only* a comma...
- let mut err = diag.create_err(errors::AsmExpectedComma { span: p.token.span });
- return Err(err);
+ return Err(diag.create_err(errors::AsmExpectedComma { span: p.token.span }));
} else {
// ...after that delegate to `expect` to also include the other expected tokens.
return Err(p.expect(&token::Comma).err().unwrap());
diff --git a/compiler/rustc_parse/messages.ftl b/compiler/rustc_parse/messages.ftl
index 9c6d00b44ce..9a5232b1bcd 100644
--- a/compiler/rustc_parse/messages.ftl
+++ b/compiler/rustc_parse/messages.ftl
@@ -426,7 +426,8 @@ parse_path_single_colon = path separator must be a double colon
parse_colon_as_semi = statements are terminated with a semicolon
.suggestion = use a semicolon instead
-parse_type_ascription_removed = type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
+parse_type_ascription_removed =
+ 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>
parse_where_clause_before_tuple_struct_body = where clauses are not allowed before tuple struct bodies
.label = unexpected where clause
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs
index da419f06537..638a432cea5 100644
--- a/compiler/rustc_parse/src/parser/diagnostics.rs
+++ b/compiler/rustc_parse/src/parser/diagnostics.rs
@@ -1569,14 +1569,9 @@ impl<'a> Parser<'a> {
}
pub(super) fn expect_semi(&mut self) -> PResult<'a, ()> {
- if self.eat(&token::Semi) {
+ if self.eat(&token::Semi) || self.recover_colon_as_semi() {
return Ok(());
}
-
- if self.recover_colon_as_semi() {
- return Ok(());
- }
-
self.expect(&token::Semi).map(drop) // Error unconditionally
}
@@ -1597,9 +1592,7 @@ impl<'a> Parser<'a> {
span: self.token.span,
type_ascription: self.sess.unstable_features.is_nightly_build().then_some(()),
});
-
self.bump();
-
return true;
}
diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs
index 9a863a8eef7..b9a2b141bce 100644
--- a/compiler/rustc_parse/src/parser/path.rs
+++ b/compiler/rustc_parse/src/parser/path.rs
@@ -9,7 +9,7 @@ use rustc_ast::{
AssocConstraintKind, BlockCheckMode, GenericArg, GenericArgs, Generics, ParenthesizedArgs,
Path, PathSegment, QSelf,
};
-use rustc_errors::{pluralize, Applicability, IntoDiagnostic, PResult};
+use rustc_errors::{Applicability, IntoDiagnostic, PResult};
use rustc_span::source_map::{BytePos, Span};
use rustc_span::symbol::{kw, sym, Ident};
use std::mem;
diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs
index 8e8788beeba..0a571013d44 100644
--- a/compiler/rustc_parse/src/parser/stmt.rs
+++ b/compiler/rustc_parse/src/parser/stmt.rs
@@ -645,7 +645,7 @@ impl<'a> Parser<'a> {
if self.recover_colon_as_semi() {
// recover_colon_as_semi has already emitted a nicer error.
- e.cancel();
+ e.delay_as_bug();
add_semi_to_stmt = true;
eat_semi = false;
@@ -672,7 +672,7 @@ impl<'a> Parser<'a> {
};
match self.parse_expr_labeled(label, false) {
Ok(labeled_expr) => {
- e.cancel();
+ e.delay_as_bug();
self.sess.emit_err(MalformedLoopLabel {
span: label.ident.span,
correct_label: label.ident,
diff --git a/tests/ui/generics/single-colon-path-not-const-generics.stderr b/tests/ui/generics/single-colon-path-not-const-generics.stderr
index bb34c0ba546..96f07e190c1 100644
--- a/tests/ui/generics/single-colon-path-not-const-generics.stderr
+++ b/tests/ui/generics/single-colon-path-not-const-generics.stderr
@@ -6,7 +6,7 @@ LL | pub struct Foo {
LL | a: Vec<foo::bar:A>,
| ^ help: use a double colon instead: `::`
|
- = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
+ = 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>
error: aborting due to previous error
diff --git a/tests/ui/suggestions/type-ascription-instead-of-method.stderr b/tests/ui/suggestions/type-ascription-instead-of-method.stderr
index 9be8c5ce3c1..b3799101cf0 100644
--- a/tests/ui/suggestions/type-ascription-instead-of-method.stderr
+++ b/tests/ui/suggestions/type-ascription-instead-of-method.stderr
@@ -4,7 +4,7 @@ error: path separator must be a double colon
LL | let _ = Box:new("foo".to_string());
| ^ help: use a double colon instead: `::`
|
- = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
+ = 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>
error: aborting due to previous error
diff --git a/tests/ui/suggestions/type-ascription-instead-of-path.stderr b/tests/ui/suggestions/type-ascription-instead-of-path.stderr
index d178621b8c6..849630218da 100644
--- a/tests/ui/suggestions/type-ascription-instead-of-path.stderr
+++ b/tests/ui/suggestions/type-ascription-instead-of-path.stderr
@@ -4,7 +4,7 @@ error: path separator must be a double colon
LL | std:io::stdin();
| ^ help: use a double colon instead: `::`
|
- = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
+ = 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>
error: aborting due to previous error
diff --git a/tests/ui/suggestions/type-ascription-instead-of-variant.stderr b/tests/ui/suggestions/type-ascription-instead-of-variant.stderr
index dfb7d8003fa..11d0f5f527e 100644
--- a/tests/ui/suggestions/type-ascription-instead-of-variant.stderr
+++ b/tests/ui/suggestions/type-ascription-instead-of-variant.stderr
@@ -4,7 +4,7 @@ error: path separator must be a double colon
LL | let _ = Option:Some("");
| ^ help: use a double colon instead: `::`
|
- = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
+ = 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>
error: aborting due to previous error
diff --git a/tests/ui/type/ascription/issue-47666.stderr b/tests/ui/type/ascription/issue-47666.stderr
index 2f815041ce1..74d85a75c85 100644
--- a/tests/ui/type/ascription/issue-47666.stderr
+++ b/tests/ui/type/ascription/issue-47666.stderr
@@ -4,7 +4,7 @@ error: path separator must be a double colon
LL | let _ = Option:Some(vec![0, 1]);
| ^ help: use a double colon instead: `::`
|
- = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
+ = 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>
error: aborting due to previous error
diff --git a/tests/ui/type/ascription/issue-54516.stderr b/tests/ui/type/ascription/issue-54516.stderr
index 7666864a9bc..a1371432f5a 100644
--- a/tests/ui/type/ascription/issue-54516.stderr
+++ b/tests/ui/type/ascription/issue-54516.stderr
@@ -4,7 +4,7 @@ error: path separator must be a double colon
LL | println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>());
| ^ help: use a double colon instead: `::`
|
- = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
+ = 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>
error: aborting due to previous error
diff --git a/tests/ui/type/ascription/issue-60933.stderr b/tests/ui/type/ascription/issue-60933.stderr
index 776cc412c32..0ec527ff5a9 100644
--- a/tests/ui/type/ascription/issue-60933.stderr
+++ b/tests/ui/type/ascription/issue-60933.stderr
@@ -4,7 +4,7 @@ error: path separator must be a double colon
LL | let _: usize = std::mem:size_of::<u32>();
| ^ help: use a double colon instead: `::`
|
- = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
+ = 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>
error: aborting due to previous error
diff --git a/tests/ui/type/type-ascription-instead-of-statement-end.stderr b/tests/ui/type/type-ascription-instead-of-statement-end.stderr
index 678aed7b144..8c09e78bc5f 100644
--- a/tests/ui/type/type-ascription-instead-of-statement-end.stderr
+++ b/tests/ui/type/type-ascription-instead-of-statement-end.stderr
@@ -4,7 +4,7 @@ error: statements are terminated with a semicolon
LL | println!("test"):
| ^ help: use a semicolon instead: `;`
|
- = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
+ = 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>
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:`
--> $DIR/type-ascription-instead-of-statement-end.rs:7:21
diff --git a/tests/ui/type/type-ascription-with-fn-call.stderr b/tests/ui/type/type-ascription-with-fn-call.stderr
index 80fc075383e..e3afa497ac2 100644
--- a/tests/ui/type/type-ascription-with-fn-call.stderr
+++ b/tests/ui/type/type-ascription-with-fn-call.stderr
@@ -4,7 +4,7 @@ error: statements are terminated with a semicolon
LL | f() :
| ^ help: use a semicolon instead: `;`
|
- = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
+ = 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>
error: aborting due to previous error