soften the wording for removing type ascription

This commit is contained in:
yukang 2023-04-28 09:55:38 +08:00
parent 0fe1ff2137
commit 5d1796a608
14 changed files with 16 additions and 23 deletions

View File

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

View File

@ -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 parse_colon_as_semi = statements are terminated with a semicolon
.suggestion = use a semicolon instead .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 parse_where_clause_before_tuple_struct_body = where clauses are not allowed before tuple struct bodies
.label = unexpected where clause .label = unexpected where clause

View File

@ -1569,14 +1569,9 @@ impl<'a> Parser<'a> {
} }
pub(super) fn expect_semi(&mut self) -> PResult<'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(()); return Ok(());
} }
if self.recover_colon_as_semi() {
return Ok(());
}
self.expect(&token::Semi).map(drop) // Error unconditionally self.expect(&token::Semi).map(drop) // Error unconditionally
} }
@ -1597,9 +1592,7 @@ impl<'a> Parser<'a> {
span: self.token.span, span: self.token.span,
type_ascription: self.sess.unstable_features.is_nightly_build().then_some(()), type_ascription: self.sess.unstable_features.is_nightly_build().then_some(()),
}); });
self.bump(); self.bump();
return true; return true;
} }

View File

@ -9,7 +9,7 @@ use rustc_ast::{
AssocConstraintKind, BlockCheckMode, GenericArg, GenericArgs, Generics, ParenthesizedArgs, AssocConstraintKind, BlockCheckMode, GenericArg, GenericArgs, Generics, ParenthesizedArgs,
Path, PathSegment, QSelf, 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::source_map::{BytePos, Span};
use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::symbol::{kw, sym, Ident};
use std::mem; use std::mem;

View File

@ -645,7 +645,7 @@ impl<'a> Parser<'a> {
if self.recover_colon_as_semi() { if self.recover_colon_as_semi() {
// recover_colon_as_semi has already emitted a nicer error. // recover_colon_as_semi has already emitted a nicer error.
e.cancel(); e.delay_as_bug();
add_semi_to_stmt = true; add_semi_to_stmt = true;
eat_semi = false; eat_semi = false;
@ -672,7 +672,7 @@ impl<'a> Parser<'a> {
}; };
match self.parse_expr_labeled(label, false) { match self.parse_expr_labeled(label, false) {
Ok(labeled_expr) => { Ok(labeled_expr) => {
e.cancel(); e.delay_as_bug();
self.sess.emit_err(MalformedLoopLabel { self.sess.emit_err(MalformedLoopLabel {
span: label.ident.span, span: label.ident.span,
correct_label: label.ident, correct_label: label.ident,

View File

@ -6,7 +6,7 @@ LL | pub struct Foo {
LL | a: Vec<foo::bar:A>, LL | a: Vec<foo::bar:A>,
| ^ help: use a double colon instead: `::` | ^ 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 error: aborting due to previous error

View File

@ -4,7 +4,7 @@ error: path separator must be a double colon
LL | let _ = Box:new("foo".to_string()); LL | let _ = Box:new("foo".to_string());
| ^ help: use a double colon instead: `::` | ^ 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 error: aborting due to previous error

View File

@ -4,7 +4,7 @@ error: path separator must be a double colon
LL | std:io::stdin(); LL | std:io::stdin();
| ^ help: use a double colon instead: `::` | ^ 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 error: aborting due to previous error

View File

@ -4,7 +4,7 @@ error: path separator must be a double colon
LL | let _ = Option:Some(""); LL | let _ = Option:Some("");
| ^ help: use a double colon instead: `::` | ^ 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 error: aborting due to previous error

View File

@ -4,7 +4,7 @@ error: path separator must be a double colon
LL | let _ = Option:Some(vec![0, 1]); LL | let _ = Option:Some(vec![0, 1]);
| ^ help: use a double colon instead: `::` | ^ 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 error: aborting due to previous error

View File

@ -4,7 +4,7 @@ error: path separator must be a double colon
LL | println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>()); LL | println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>());
| ^ help: use a double colon instead: `::` | ^ 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 error: aborting due to previous error

View File

@ -4,7 +4,7 @@ error: path separator must be a double colon
LL | let _: usize = std::mem:size_of::<u32>(); LL | let _: usize = std::mem:size_of::<u32>();
| ^ help: use a double colon instead: `::` | ^ 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 error: aborting due to previous error

View File

@ -4,7 +4,7 @@ error: statements are terminated with a semicolon
LL | println!("test"): LL | println!("test"):
| ^ help: use a semicolon instead: `;` | ^ 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 `:` error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:`
--> $DIR/type-ascription-instead-of-statement-end.rs:7:21 --> $DIR/type-ascription-instead-of-statement-end.rs:7:21

View File

@ -4,7 +4,7 @@ error: statements are terminated with a semicolon
LL | f() : LL | f() :
| ^ help: use a semicolon instead: `;` | ^ 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 error: aborting due to previous error