about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authoryukang <moorekang@gmail.com>2023-04-28 09:55:38 +0800
committeryukang <moorekang@gmail.com>2023-05-01 16:37:00 +0800
commit5d1796a608d387be784f17c28ec7c81f178a81eb (patch)
tree5a5aaafdd30a1c51393aa9d3215b048269089a81 /compiler
parent0fe1ff2137f75ff5fafd45c04558c5f8ce9a00ee (diff)
downloadrust-5d1796a608d387be784f17c28ec7c81f178a81eb.tar.gz
rust-5d1796a608d387be784f17c28ec7c81f178a81eb.zip
soften the wording for removing type ascription
Diffstat (limited to 'compiler')
-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
5 files changed, 7 insertions, 14 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,