Rollup merge of #110873 - clubby789:migrate-rustc-parse-trivial, r=compiler-errors
Migrate trivially translatable `rustc_parse` diagnostics cc #100717 Migrate diagnostics in `rustc_parse` which are emitted in a single statement. I worked on this by expanding the lint introduced in #108760, although that isn't included here as there is much more work to be done to satisfy it
This commit is contained in:
commit
29f5ec3640
17 changed files with 443 additions and 231 deletions
|
@ -2976,7 +2976,7 @@ pub enum ItemKind {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ItemKind {
|
impl ItemKind {
|
||||||
pub fn article(&self) -> &str {
|
pub fn article(&self) -> &'static str {
|
||||||
use ItemKind::*;
|
use ItemKind::*;
|
||||||
match self {
|
match self {
|
||||||
Use(..) | Static(..) | Const(..) | Fn(..) | Mod(..) | GlobalAsm(..) | TyAlias(..)
|
Use(..) | Static(..) | Const(..) | Fn(..) | Mod(..) | GlobalAsm(..) | TyAlias(..)
|
||||||
|
@ -2985,7 +2985,7 @@ impl ItemKind {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn descr(&self) -> &str {
|
pub fn descr(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
ItemKind::ExternCrate(..) => "extern crate",
|
ItemKind::ExternCrate(..) => "extern crate",
|
||||||
ItemKind::Use(..) => "`use` import",
|
ItemKind::Use(..) => "`use` import",
|
||||||
|
|
|
@ -772,3 +772,75 @@ parse_const_bounds_missing_tilde = const bounds must start with `~`
|
||||||
.suggestion = add `~`
|
.suggestion = add `~`
|
||||||
|
|
||||||
parse_underscore_literal_suffix = underscore literal suffix is not allowed
|
parse_underscore_literal_suffix = underscore literal suffix is not allowed
|
||||||
|
|
||||||
|
parse_expect_label_found_ident = expected a label, found an identifier
|
||||||
|
.suggestion = labels start with a tick
|
||||||
|
|
||||||
|
parse_inappropriate_default = {$article} {$descr} cannot be `default`
|
||||||
|
.label = `default` because of this
|
||||||
|
.note = only associated `fn`, `const`, and `type` items can be `default`
|
||||||
|
|
||||||
|
parse_recover_import_as_use = expected item, found {$token_name}
|
||||||
|
.suggestion = items are imported using the `use` keyword
|
||||||
|
|
||||||
|
parse_single_colon_import_path = expected `::`, found `:`
|
||||||
|
.suggestion = use double colon
|
||||||
|
.note = import paths are delimited using `::`
|
||||||
|
|
||||||
|
parse_bad_item_kind = {$descr} is not supported in {$ctx}
|
||||||
|
.help = consider moving the {$descr} out to a nearby module scope
|
||||||
|
|
||||||
|
parse_single_colon_struct_type = found single colon in a struct field type path
|
||||||
|
.suggestion = write a path separator here
|
||||||
|
|
||||||
|
parse_equals_struct_default = default values on `struct` fields aren't supported
|
||||||
|
.suggestion = remove this unsupported default value
|
||||||
|
|
||||||
|
parse_macro_rules_missing_bang = expected `!` after `macro_rules`
|
||||||
|
.suggestion = add a `!`
|
||||||
|
|
||||||
|
parse_macro_name_remove_bang = macro names aren't followed by a `!`
|
||||||
|
.suggestion = remove the `!`
|
||||||
|
|
||||||
|
parse_macro_rules_visibility = can't qualify macro_rules invocation with `{$vis}`
|
||||||
|
.suggestion = try exporting the macro
|
||||||
|
|
||||||
|
parse_macro_invocation_visibility = can't qualify macro invocation with `pub`
|
||||||
|
.suggestion = remove the visibility
|
||||||
|
.help = try adjusting the macro to put `{$vis}` inside the invocation
|
||||||
|
|
||||||
|
parse_nested_adt = `{$kw_str}` definition cannot be nested inside `{$keyword}`
|
||||||
|
.suggestion = consider creating a new `{$kw_str}` definition instead of nesting
|
||||||
|
|
||||||
|
parse_function_body_equals_expr = function body cannot be `= expression;`
|
||||||
|
.suggestion = surround the expression with `{"{"}` and `{"}"}` instead of `=` and `;`
|
||||||
|
|
||||||
|
parse_box_not_pat = expected pattern, found {$descr}
|
||||||
|
.note = `box` is a reserved keyword
|
||||||
|
.suggestion = escape `box` to use it as an identifier
|
||||||
|
|
||||||
|
parse_unmatched_angle = unmatched angle {$plural ->
|
||||||
|
[true] brackets
|
||||||
|
*[false] bracket
|
||||||
|
}
|
||||||
|
.suggestion = remove extra angle {$plural ->
|
||||||
|
[true] brackets
|
||||||
|
*[false] bracket
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_missing_plus_in_bounds = expected `+` between lifetime and {$sym}
|
||||||
|
.suggestion = add `+`
|
||||||
|
|
||||||
|
parse_incorrect_braces_trait_bounds = incorrect braces around trait bounds
|
||||||
|
.suggestion = remove the parentheses
|
||||||
|
|
||||||
|
parse_kw_bad_case = keyword `{$kw}` is written in the wrong case
|
||||||
|
.suggestion = write it in the correct case
|
||||||
|
|
||||||
|
parse_meta_bad_delim = wrong meta list delimiters
|
||||||
|
parse_cfg_attr_bad_delim = wrong `cfg_attr` delimiters
|
||||||
|
parse_meta_bad_delim_suggestion = the delimiters should be `(` and `)`
|
||||||
|
|
||||||
|
parse_malformed_cfg_attr = malformed `cfg_attr` attribute input
|
||||||
|
.suggestion = missing condition and attribute
|
||||||
|
.note = for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
|
||||||
|
|
|
@ -2421,3 +2421,227 @@ pub(crate) struct UnderscoreLiteralSuffix {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_expect_label_found_ident)]
|
||||||
|
pub(crate) struct ExpectedLabelFoundIdent {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
#[suggestion(code = "'", applicability = "machine-applicable", style = "short")]
|
||||||
|
pub start: Span,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_inappropriate_default)]
|
||||||
|
#[note]
|
||||||
|
pub(crate) struct InappropriateDefault {
|
||||||
|
#[primary_span]
|
||||||
|
#[label]
|
||||||
|
pub span: Span,
|
||||||
|
pub article: &'static str,
|
||||||
|
pub descr: &'static str,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_recover_import_as_use)]
|
||||||
|
pub(crate) struct RecoverImportAsUse {
|
||||||
|
#[primary_span]
|
||||||
|
#[suggestion(code = "use", applicability = "machine-applicable", style = "short")]
|
||||||
|
pub span: Span,
|
||||||
|
pub token_name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_single_colon_import_path)]
|
||||||
|
#[note]
|
||||||
|
pub(crate) struct SingleColonImportPath {
|
||||||
|
#[primary_span]
|
||||||
|
#[suggestion(code = "::", applicability = "machine-applicable", style = "short")]
|
||||||
|
pub span: Span,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_bad_item_kind)]
|
||||||
|
#[help]
|
||||||
|
pub(crate) struct BadItemKind {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
pub descr: &'static str,
|
||||||
|
pub ctx: &'static str,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_single_colon_struct_type)]
|
||||||
|
pub(crate) struct SingleColonStructType {
|
||||||
|
#[primary_span]
|
||||||
|
#[suggestion(code = "::", applicability = "maybe-incorrect", style = "verbose")]
|
||||||
|
pub span: Span,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_equals_struct_default)]
|
||||||
|
pub(crate) struct EqualsStructDefault {
|
||||||
|
#[primary_span]
|
||||||
|
#[suggestion(code = "", applicability = "machine-applicable")]
|
||||||
|
pub span: Span,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_macro_rules_missing_bang)]
|
||||||
|
pub(crate) struct MacroRulesMissingBang {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
#[suggestion(code = "!", applicability = "machine-applicable", style = "verbose")]
|
||||||
|
pub hi: Span,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_macro_name_remove_bang)]
|
||||||
|
pub(crate) struct MacroNameRemoveBang {
|
||||||
|
#[primary_span]
|
||||||
|
#[suggestion(code = "", applicability = "machine-applicable")]
|
||||||
|
pub span: Span,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_macro_rules_visibility)]
|
||||||
|
pub(crate) struct MacroRulesVisibility<'a> {
|
||||||
|
#[primary_span]
|
||||||
|
#[suggestion(code = "#[macro_export]", applicability = "maybe-incorrect")]
|
||||||
|
pub span: Span,
|
||||||
|
pub vis: &'a str,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_macro_invocation_visibility)]
|
||||||
|
#[help]
|
||||||
|
pub(crate) struct MacroInvocationVisibility<'a> {
|
||||||
|
#[primary_span]
|
||||||
|
#[suggestion(code = "", applicability = "machine-applicable")]
|
||||||
|
pub span: Span,
|
||||||
|
pub vis: &'a str,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_nested_adt)]
|
||||||
|
pub(crate) struct NestedAdt<'a> {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
#[suggestion(code = "", applicability = "maybe-incorrect")]
|
||||||
|
pub item: Span,
|
||||||
|
pub keyword: &'a str,
|
||||||
|
pub kw_str: Cow<'a, str>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_function_body_equals_expr)]
|
||||||
|
pub(crate) struct FunctionBodyEqualsExpr {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
#[subdiagnostic]
|
||||||
|
pub sugg: FunctionBodyEqualsExprSugg,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subdiagnostic)]
|
||||||
|
#[multipart_suggestion(parse_suggestion, applicability = "machine-applicable")]
|
||||||
|
pub(crate) struct FunctionBodyEqualsExprSugg {
|
||||||
|
#[suggestion_part(code = "{{")]
|
||||||
|
pub eq: Span,
|
||||||
|
#[suggestion_part(code = " }}")]
|
||||||
|
pub semi: Span,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_box_not_pat)]
|
||||||
|
pub(crate) struct BoxNotPat {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
#[note]
|
||||||
|
pub kw: Span,
|
||||||
|
#[suggestion(code = "r#", applicability = "maybe-incorrect", style = "verbose")]
|
||||||
|
pub lo: Span,
|
||||||
|
pub descr: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_unmatched_angle)]
|
||||||
|
pub(crate) struct UnmatchedAngle {
|
||||||
|
#[primary_span]
|
||||||
|
#[suggestion(code = "", applicability = "machine-applicable")]
|
||||||
|
pub span: Span,
|
||||||
|
pub plural: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_missing_plus_in_bounds)]
|
||||||
|
pub(crate) struct MissingPlusBounds {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
#[suggestion(code = " +", applicability = "maybe-incorrect", style = "verbose")]
|
||||||
|
pub hi: Span,
|
||||||
|
pub sym: Symbol,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_incorrect_braces_trait_bounds)]
|
||||||
|
pub(crate) struct IncorrectBracesTraitBounds {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Vec<Span>,
|
||||||
|
#[subdiagnostic]
|
||||||
|
pub sugg: IncorrectBracesTraitBoundsSugg,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subdiagnostic)]
|
||||||
|
#[multipart_suggestion(parse_suggestion, applicability = "machine-applicable")]
|
||||||
|
pub(crate) struct IncorrectBracesTraitBoundsSugg {
|
||||||
|
#[suggestion_part(code = " ")]
|
||||||
|
pub l: Span,
|
||||||
|
#[suggestion_part(code = "")]
|
||||||
|
pub r: Span,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_kw_bad_case)]
|
||||||
|
pub(crate) struct KwBadCase<'a> {
|
||||||
|
#[primary_span]
|
||||||
|
#[suggestion(code = "{kw}", applicability = "machine-applicable")]
|
||||||
|
pub span: Span,
|
||||||
|
pub kw: &'a str,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_meta_bad_delim)]
|
||||||
|
pub(crate) struct MetaBadDelim {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
#[subdiagnostic]
|
||||||
|
pub sugg: MetaBadDelimSugg,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_cfg_attr_bad_delim)]
|
||||||
|
pub(crate) struct CfgAttrBadDelim {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
#[subdiagnostic]
|
||||||
|
pub sugg: MetaBadDelimSugg,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subdiagnostic)]
|
||||||
|
#[multipart_suggestion(parse_meta_bad_delim_suggestion, applicability = "machine-applicable")]
|
||||||
|
pub(crate) struct MetaBadDelimSugg {
|
||||||
|
#[suggestion_part(code = "(")]
|
||||||
|
pub open: Span,
|
||||||
|
#[suggestion_part(code = ")")]
|
||||||
|
pub close: Span,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_malformed_cfg_attr)]
|
||||||
|
#[note]
|
||||||
|
pub(crate) struct MalformedCfgAttr {
|
||||||
|
#[primary_span]
|
||||||
|
#[suggestion(code = "{sugg}")]
|
||||||
|
pub span: Span,
|
||||||
|
pub sugg: &'static str,
|
||||||
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ use rustc_ast::tokenstream::TokenStream;
|
||||||
use rustc_ast::{AttrItem, Attribute, MetaItem};
|
use rustc_ast::{AttrItem, Attribute, MetaItem};
|
||||||
use rustc_ast_pretty::pprust;
|
use rustc_ast_pretty::pprust;
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
use rustc_errors::{Applicability, Diagnostic, FatalError, Level, PResult};
|
use rustc_errors::{Diagnostic, FatalError, Level, PResult};
|
||||||
use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
|
use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
|
||||||
use rustc_fluent_macro::fluent_messages;
|
use rustc_fluent_macro::fluent_messages;
|
||||||
use rustc_session::parse::ParseSess;
|
use rustc_session::parse::ParseSess;
|
||||||
|
@ -243,8 +243,7 @@ pub fn parse_cfg_attr(
|
||||||
ast::AttrArgs::Delimited(ast::DelimArgs { dspan, delim, ref tokens })
|
ast::AttrArgs::Delimited(ast::DelimArgs { dspan, delim, ref tokens })
|
||||||
if !tokens.is_empty() =>
|
if !tokens.is_empty() =>
|
||||||
{
|
{
|
||||||
let msg = "wrong `cfg_attr` delimiters";
|
crate::validate_attr::check_cfg_attr_bad_delim(parse_sess, dspan, delim);
|
||||||
crate::validate_attr::check_meta_bad_delim(parse_sess, dspan, delim, msg);
|
|
||||||
match parse_in(parse_sess, tokens.clone(), "`cfg_attr` input", |p| p.parse_cfg_attr()) {
|
match parse_in(parse_sess, tokens.clone(), "`cfg_attr` input", |p| p.parse_cfg_attr()) {
|
||||||
Ok(r) => return Some(r),
|
Ok(r) => return Some(r),
|
||||||
Err(mut e) => {
|
Err(mut e) => {
|
||||||
|
@ -265,15 +264,5 @@ const CFG_ATTR_NOTE_REF: &str = "for more information, visit \
|
||||||
#the-cfg_attr-attribute>";
|
#the-cfg_attr-attribute>";
|
||||||
|
|
||||||
fn error_malformed_cfg_attr_missing(span: Span, parse_sess: &ParseSess) {
|
fn error_malformed_cfg_attr_missing(span: Span, parse_sess: &ParseSess) {
|
||||||
parse_sess
|
parse_sess.emit_err(errors::MalformedCfgAttr { span, sugg: CFG_ATTR_GRAMMAR_HELP });
|
||||||
.span_diagnostic
|
|
||||||
.struct_span_err(span, "malformed `cfg_attr` attribute input")
|
|
||||||
.span_suggestion(
|
|
||||||
span,
|
|
||||||
"missing condition and attribute",
|
|
||||||
CFG_ATTR_GRAMMAR_HELP,
|
|
||||||
Applicability::HasPlaceholders,
|
|
||||||
)
|
|
||||||
.note(CFG_ATTR_NOTE_REF)
|
|
||||||
.emit();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3151,14 +3151,10 @@ impl<'a> Parser<'a> {
|
||||||
let label = format!("'{}", ident.name);
|
let label = format!("'{}", ident.name);
|
||||||
let ident = Ident { name: Symbol::intern(&label), span: ident.span };
|
let ident = Ident { name: Symbol::intern(&label), span: ident.span };
|
||||||
|
|
||||||
self.struct_span_err(ident.span, "expected a label, found an identifier")
|
self.sess.emit_err(errors::ExpectedLabelFoundIdent {
|
||||||
.span_suggestion(
|
span: ident.span,
|
||||||
ident.span,
|
start: ident.span.shrink_to_lo(),
|
||||||
"labels start with a tick",
|
});
|
||||||
label,
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
|
|
||||||
Label { ident }
|
Label { ident }
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,11 +181,11 @@ impl<'a> Parser<'a> {
|
||||||
/// Error in-case `default` was parsed in an in-appropriate context.
|
/// Error in-case `default` was parsed in an in-appropriate context.
|
||||||
fn error_on_unconsumed_default(&self, def: Defaultness, kind: &ItemKind) {
|
fn error_on_unconsumed_default(&self, def: Defaultness, kind: &ItemKind) {
|
||||||
if let Defaultness::Default(span) = def {
|
if let Defaultness::Default(span) = def {
|
||||||
let msg = format!("{} {} cannot be `default`", kind.article(), kind.descr());
|
self.sess.emit_err(errors::InappropriateDefault {
|
||||||
self.struct_span_err(span, &msg)
|
span,
|
||||||
.span_label(span, "`default` because of this")
|
article: kind.article(),
|
||||||
.note("only associated `fn`, `const`, and `type` items can be `default`")
|
descr: kind.descr(),
|
||||||
.emit();
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,14 +310,7 @@ impl<'a> Parser<'a> {
|
||||||
self.bump();
|
self.bump();
|
||||||
match self.parse_use_item() {
|
match self.parse_use_item() {
|
||||||
Ok(u) => {
|
Ok(u) => {
|
||||||
self.struct_span_err(span, format!("expected item, found {token_name}"))
|
self.sess.emit_err(errors::RecoverImportAsUse { span, token_name });
|
||||||
.span_suggestion_short(
|
|
||||||
span,
|
|
||||||
"items are imported using the `use` keyword",
|
|
||||||
"use",
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
Ok(Some(u))
|
Ok(Some(u))
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
@ -963,15 +956,8 @@ impl<'a> Parser<'a> {
|
||||||
} else {
|
} else {
|
||||||
// Recover from using a colon as path separator.
|
// Recover from using a colon as path separator.
|
||||||
while self.eat_noexpect(&token::Colon) {
|
while self.eat_noexpect(&token::Colon) {
|
||||||
self.struct_span_err(self.prev_token.span, "expected `::`, found `:`")
|
self.sess
|
||||||
.span_suggestion_short(
|
.emit_err(errors::SingleColonImportPath { span: self.prev_token.span });
|
||||||
self.prev_token.span,
|
|
||||||
"use double colon",
|
|
||||||
"::",
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
)
|
|
||||||
.note_once("import paths are delimited using `::`")
|
|
||||||
.emit();
|
|
||||||
|
|
||||||
// We parse the rest of the path and append it to the original prefix.
|
// We parse the rest of the path and append it to the original prefix.
|
||||||
self.parse_path_segments(&mut prefix.segments, PathStyle::Mod, None)?;
|
self.parse_path_segments(&mut prefix.segments, PathStyle::Mod, None)?;
|
||||||
|
@ -1134,13 +1120,11 @@ impl<'a> Parser<'a> {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn error_bad_item_kind<T>(&self, span: Span, kind: &ItemKind, ctx: &str) -> Option<T> {
|
fn error_bad_item_kind<T>(&self, span: Span, kind: &ItemKind, ctx: &'static str) -> Option<T> {
|
||||||
// FIXME(#100717): needs variant for each `ItemKind` (instead of using `ItemKind::descr()`)
|
// FIXME(#100717): needs variant for each `ItemKind` (instead of using `ItemKind::descr()`)
|
||||||
let span = self.sess.source_map().guess_head_span(span);
|
let span = self.sess.source_map().guess_head_span(span);
|
||||||
let descr = kind.descr();
|
let descr = kind.descr();
|
||||||
self.struct_span_err(span, &format!("{descr} is not supported in {ctx}"))
|
self.sess.emit_err(errors::BadItemKind { span, descr, ctx });
|
||||||
.help(&format!("consider moving the {descr} out to a nearby module scope"))
|
|
||||||
.emit();
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1713,27 +1697,13 @@ impl<'a> Parser<'a> {
|
||||||
self.expect_field_ty_separator()?;
|
self.expect_field_ty_separator()?;
|
||||||
let ty = self.parse_ty()?;
|
let ty = self.parse_ty()?;
|
||||||
if self.token.kind == token::Colon && self.look_ahead(1, |tok| tok.kind != token::Colon) {
|
if self.token.kind == token::Colon && self.look_ahead(1, |tok| tok.kind != token::Colon) {
|
||||||
self.struct_span_err(self.token.span, "found single colon in a struct field type path")
|
self.sess.emit_err(errors::SingleColonStructType { span: self.token.span });
|
||||||
.span_suggestion_verbose(
|
|
||||||
self.token.span,
|
|
||||||
"write a path separator here",
|
|
||||||
"::",
|
|
||||||
Applicability::MaybeIncorrect,
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
}
|
}
|
||||||
if self.token.kind == token::Eq {
|
if self.token.kind == token::Eq {
|
||||||
self.bump();
|
self.bump();
|
||||||
let const_expr = self.parse_expr_anon_const()?;
|
let const_expr = self.parse_expr_anon_const()?;
|
||||||
let sp = ty.span.shrink_to_hi().to(const_expr.value.span);
|
let sp = ty.span.shrink_to_hi().to(const_expr.value.span);
|
||||||
self.struct_span_err(sp, "default values on `struct` fields aren't supported")
|
self.sess.emit_err(errors::EqualsStructDefault { span: sp });
|
||||||
.span_suggestion(
|
|
||||||
sp,
|
|
||||||
"remove this unsupported default value",
|
|
||||||
"",
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
}
|
}
|
||||||
Ok(FieldDef {
|
Ok(FieldDef {
|
||||||
span: lo.to(self.prev_token.span),
|
span: lo.to(self.prev_token.span),
|
||||||
|
@ -1871,14 +1841,10 @@ impl<'a> Parser<'a> {
|
||||||
return IsMacroRulesItem::Yes { has_bang: true };
|
return IsMacroRulesItem::Yes { has_bang: true };
|
||||||
} else if self.look_ahead(1, |t| (t.is_ident())) {
|
} else if self.look_ahead(1, |t| (t.is_ident())) {
|
||||||
// macro_rules foo
|
// macro_rules foo
|
||||||
self.struct_span_err(macro_rules_span, "expected `!` after `macro_rules`")
|
self.sess.emit_err(errors::MacroRulesMissingBang {
|
||||||
.span_suggestion(
|
span: macro_rules_span,
|
||||||
macro_rules_span,
|
hi: macro_rules_span.shrink_to_hi(),
|
||||||
"add a `!`",
|
});
|
||||||
"macro_rules!",
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
|
|
||||||
return IsMacroRulesItem::Yes { has_bang: false };
|
return IsMacroRulesItem::Yes { has_bang: false };
|
||||||
}
|
}
|
||||||
|
@ -1903,9 +1869,7 @@ impl<'a> Parser<'a> {
|
||||||
if self.eat(&token::Not) {
|
if self.eat(&token::Not) {
|
||||||
// Handle macro_rules! foo!
|
// Handle macro_rules! foo!
|
||||||
let span = self.prev_token.span;
|
let span = self.prev_token.span;
|
||||||
self.struct_span_err(span, "macro names aren't followed by a `!`")
|
self.sess.emit_err(errors::MacroNameRemoveBang { span });
|
||||||
.span_suggestion(span, "remove the `!`", "", Applicability::MachineApplicable)
|
|
||||||
.emit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let body = self.parse_delim_args()?;
|
let body = self.parse_delim_args()?;
|
||||||
|
@ -1925,25 +1889,9 @@ impl<'a> Parser<'a> {
|
||||||
let vstr = pprust::vis_to_string(vis);
|
let vstr = pprust::vis_to_string(vis);
|
||||||
let vstr = vstr.trim_end();
|
let vstr = vstr.trim_end();
|
||||||
if macro_rules {
|
if macro_rules {
|
||||||
let msg = format!("can't qualify macro_rules invocation with `{vstr}`");
|
self.sess.emit_err(errors::MacroRulesVisibility { span: vis.span, vis: vstr });
|
||||||
self.struct_span_err(vis.span, &msg)
|
|
||||||
.span_suggestion(
|
|
||||||
vis.span,
|
|
||||||
"try exporting the macro",
|
|
||||||
"#[macro_export]",
|
|
||||||
Applicability::MaybeIncorrect, // speculative
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
} else {
|
} else {
|
||||||
self.struct_span_err(vis.span, "can't qualify macro invocation with `pub`")
|
self.sess.emit_err(errors::MacroInvocationVisibility { span: vis.span, vis: vstr });
|
||||||
.span_suggestion(
|
|
||||||
vis.span,
|
|
||||||
"remove the visibility",
|
|
||||||
"",
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
)
|
|
||||||
.help(&format!("try adjusting the macro to put `{vstr}` inside the invocation"))
|
|
||||||
.emit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1989,18 +1937,12 @@ impl<'a> Parser<'a> {
|
||||||
let kw_token = self.token.clone();
|
let kw_token = self.token.clone();
|
||||||
let kw_str = pprust::token_to_string(&kw_token);
|
let kw_str = pprust::token_to_string(&kw_token);
|
||||||
let item = self.parse_item(ForceCollect::No)?;
|
let item = self.parse_item(ForceCollect::No)?;
|
||||||
|
self.sess.emit_err(errors::NestedAdt {
|
||||||
self.struct_span_err(
|
span: kw_token.span,
|
||||||
kw_token.span,
|
item: item.unwrap().span,
|
||||||
&format!("`{kw_str}` definition cannot be nested inside `{keyword}`"),
|
kw_str,
|
||||||
)
|
keyword: keyword.as_str(),
|
||||||
.span_suggestion(
|
});
|
||||||
item.unwrap().span,
|
|
||||||
&format!("consider creating a new `{kw_str}` definition instead of nesting"),
|
|
||||||
"",
|
|
||||||
Applicability::MaybeIncorrect,
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
// We successfully parsed the item but we must inform the caller about nested problem.
|
// We successfully parsed the item but we must inform the caller about nested problem.
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
@ -2139,13 +2081,10 @@ impl<'a> Parser<'a> {
|
||||||
let _ = self.parse_expr()?;
|
let _ = self.parse_expr()?;
|
||||||
self.expect_semi()?; // `;`
|
self.expect_semi()?; // `;`
|
||||||
let span = eq_sp.to(self.prev_token.span);
|
let span = eq_sp.to(self.prev_token.span);
|
||||||
self.struct_span_err(span, "function body cannot be `= expression;`")
|
self.sess.emit_err(errors::FunctionBodyEqualsExpr {
|
||||||
.multipart_suggestion(
|
span,
|
||||||
"surround the expression with `{` and `}` instead of `=` and `;`",
|
sugg: errors::FunctionBodyEqualsExprSugg { eq: eq_sp, semi: self.prev_token.span },
|
||||||
vec![(eq_sp, "{".to_string()), (self.prev_token.span, " }".to_string())],
|
});
|
||||||
Applicability::MachineApplicable,
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
(AttrVec::new(), Some(self.mk_block_err(span)))
|
(AttrVec::new(), Some(self.mk_block_err(span)))
|
||||||
} else {
|
} else {
|
||||||
let expected = if req_body {
|
let expected = if req_body {
|
||||||
|
|
|
@ -43,7 +43,7 @@ use thin_vec::ThinVec;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
use crate::errors::{
|
use crate::errors::{
|
||||||
IncorrectVisibilityRestriction, MismatchedClosingDelimiter, NonStringAbiLiteral,
|
self, IncorrectVisibilityRestriction, MismatchedClosingDelimiter, NonStringAbiLiteral,
|
||||||
};
|
};
|
||||||
|
|
||||||
bitflags::bitflags! {
|
bitflags::bitflags! {
|
||||||
|
@ -663,15 +663,10 @@ impl<'a> Parser<'a> {
|
||||||
if case == Case::Insensitive
|
if case == Case::Insensitive
|
||||||
&& let Some((ident, /* is_raw */ false)) = self.token.ident()
|
&& let Some((ident, /* is_raw */ false)) = self.token.ident()
|
||||||
&& ident.as_str().to_lowercase() == kw.as_str().to_lowercase() {
|
&& ident.as_str().to_lowercase() == kw.as_str().to_lowercase() {
|
||||||
self
|
self.sess.emit_err(errors::KwBadCase {
|
||||||
.struct_span_err(ident.span, format!("keyword `{kw}` is written in a wrong case"))
|
span: ident.span,
|
||||||
.span_suggestion(
|
kw: kw.as_str()
|
||||||
ident.span,
|
});
|
||||||
"write it in the correct case",
|
|
||||||
kw,
|
|
||||||
Applicability::MachineApplicable
|
|
||||||
).emit();
|
|
||||||
|
|
||||||
self.bump();
|
self.bump();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use super::{ForceCollect, Parser, PathStyle, TrailingToken};
|
use super::{ForceCollect, Parser, PathStyle, TrailingToken};
|
||||||
use crate::errors::{
|
use crate::errors::{
|
||||||
AmbiguousRangePattern, DotDotDotForRemainingFields, DotDotDotRangeToPatternNotAllowed,
|
self, AmbiguousRangePattern, DotDotDotForRemainingFields, DotDotDotRangeToPatternNotAllowed,
|
||||||
DotDotDotRestPattern, EnumPatternInsteadOfIdentifier, ExpectedBindingLeftOfAt,
|
DotDotDotRestPattern, EnumPatternInsteadOfIdentifier, ExpectedBindingLeftOfAt,
|
||||||
ExpectedCommaAfterPatternField, InclusiveRangeExtraEquals, InclusiveRangeMatchArrow,
|
ExpectedCommaAfterPatternField, InclusiveRangeExtraEquals, InclusiveRangeMatchArrow,
|
||||||
InclusiveRangeNoEnd, InvalidMutInPattern, PatternOnWrongSideOfAt, RefMutOrderIncorrect,
|
InclusiveRangeNoEnd, InvalidMutInPattern, PatternOnWrongSideOfAt, RefMutOrderIncorrect,
|
||||||
|
@ -908,18 +908,13 @@ impl<'a> Parser<'a> {
|
||||||
let box_span = self.prev_token.span;
|
let box_span = self.prev_token.span;
|
||||||
|
|
||||||
if self.isnt_pattern_start() {
|
if self.isnt_pattern_start() {
|
||||||
self.struct_span_err(
|
let descr = super::token_descr(&self.token);
|
||||||
self.token.span,
|
self.sess.emit_err(errors::BoxNotPat {
|
||||||
format!("expected pattern, found {}", super::token_descr(&self.token)),
|
span: self.token.span,
|
||||||
)
|
kw: box_span,
|
||||||
.span_note(box_span, "`box` is a reserved keyword")
|
lo: box_span.shrink_to_lo(),
|
||||||
.span_suggestion_verbose(
|
descr,
|
||||||
box_span.shrink_to_lo(),
|
});
|
||||||
"escape `box` to use it as an identifier",
|
|
||||||
"r#",
|
|
||||||
Applicability::MaybeIncorrect,
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
|
|
||||||
// We cannot use `parse_pat_ident()` since it will complain `box`
|
// We cannot use `parse_pat_ident()` since it will complain `box`
|
||||||
// is not an identifier.
|
// is not an identifier.
|
||||||
|
|
|
@ -8,7 +8,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, PResult};
|
use rustc_errors::{Applicability, 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;
|
||||||
|
@ -464,23 +464,10 @@ impl<'a> Parser<'a> {
|
||||||
// i.e. no multibyte characters, in this range.
|
// i.e. no multibyte characters, in this range.
|
||||||
let span =
|
let span =
|
||||||
lo.with_hi(lo.lo() + BytePos(snapshot.unmatched_angle_bracket_count));
|
lo.with_hi(lo.lo() + BytePos(snapshot.unmatched_angle_bracket_count));
|
||||||
self.struct_span_err(
|
self.sess.emit_err(errors::UnmatchedAngle {
|
||||||
span,
|
span,
|
||||||
&format!(
|
plural: snapshot.unmatched_angle_bracket_count > 1,
|
||||||
"unmatched angle bracket{}",
|
});
|
||||||
pluralize!(snapshot.unmatched_angle_bracket_count)
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.span_suggestion(
|
|
||||||
span,
|
|
||||||
&format!(
|
|
||||||
"remove extra angle bracket{}",
|
|
||||||
pluralize!(snapshot.unmatched_angle_bracket_count)
|
|
||||||
),
|
|
||||||
"",
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
|
|
||||||
// Try again without unmatched angle bracket characters.
|
// Try again without unmatched angle bracket characters.
|
||||||
self.parse_angle_args(ty_generics)
|
self.parse_angle_args(ty_generics)
|
||||||
|
|
|
@ -588,20 +588,14 @@ impl<'a> Parser<'a> {
|
||||||
// Always parse bounds greedily for better error recovery.
|
// Always parse bounds greedily for better error recovery.
|
||||||
if self.token.is_lifetime() {
|
if self.token.is_lifetime() {
|
||||||
self.look_ahead(1, |t| {
|
self.look_ahead(1, |t| {
|
||||||
if let token::Ident(symname, _) = t.kind {
|
if let token::Ident(sym, _) = t.kind {
|
||||||
// parse pattern with "'a Sized" we're supposed to give suggestion like
|
// parse pattern with "'a Sized" we're supposed to give suggestion like
|
||||||
// "'a + Sized"
|
// "'a + Sized"
|
||||||
self.struct_span_err(
|
self.sess.emit_err(errors::MissingPlusBounds {
|
||||||
self.token.span,
|
span: self.token.span,
|
||||||
&format!("expected `+` between lifetime and {}", symname),
|
hi: self.token.span.shrink_to_hi(),
|
||||||
)
|
sym,
|
||||||
.span_suggestion_verbose(
|
});
|
||||||
self.token.span.shrink_to_hi(),
|
|
||||||
"add `+`",
|
|
||||||
" +",
|
|
||||||
Applicability::MaybeIncorrect,
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -926,14 +920,10 @@ impl<'a> Parser<'a> {
|
||||||
self.parse_remaining_bounds(bounds, true)?;
|
self.parse_remaining_bounds(bounds, true)?;
|
||||||
self.expect(&token::CloseDelim(Delimiter::Parenthesis))?;
|
self.expect(&token::CloseDelim(Delimiter::Parenthesis))?;
|
||||||
let sp = vec![lo, self.prev_token.span];
|
let sp = vec![lo, self.prev_token.span];
|
||||||
let sugg = vec![(lo, String::from(" ")), (self.prev_token.span, String::new())];
|
self.sess.emit_err(errors::IncorrectBracesTraitBounds {
|
||||||
self.struct_span_err(sp, "incorrect braces around trait bounds")
|
span: sp,
|
||||||
.multipart_suggestion(
|
sugg: errors::IncorrectBracesTraitBoundsSugg { l: lo, r: self.prev_token.span },
|
||||||
"remove the parentheses",
|
});
|
||||||
sugg,
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
} else {
|
} else {
|
||||||
self.expect(&token::CloseDelim(Delimiter::Parenthesis))?;
|
self.expect(&token::CloseDelim(Delimiter::Parenthesis))?;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//! Meta-syntax validation logic of attributes for post-expansion.
|
//! Meta-syntax validation logic of attributes for post-expansion.
|
||||||
|
|
||||||
use crate::parse_in;
|
use crate::{errors, parse_in};
|
||||||
|
|
||||||
use rustc_ast::tokenstream::DelimSpan;
|
use rustc_ast::tokenstream::DelimSpan;
|
||||||
use rustc_ast::MetaItemKind;
|
use rustc_ast::MetaItemKind;
|
||||||
|
@ -45,7 +45,7 @@ pub fn parse_meta<'a>(sess: &'a ParseSess, attr: &Attribute) -> PResult<'a, Meta
|
||||||
kind: match &item.args {
|
kind: match &item.args {
|
||||||
AttrArgs::Empty => MetaItemKind::Word,
|
AttrArgs::Empty => MetaItemKind::Word,
|
||||||
AttrArgs::Delimited(DelimArgs { dspan, delim, tokens }) => {
|
AttrArgs::Delimited(DelimArgs { dspan, delim, tokens }) => {
|
||||||
check_meta_bad_delim(sess, *dspan, *delim, "wrong meta list delimiters");
|
check_meta_bad_delim(sess, *dspan, *delim);
|
||||||
let nmis = parse_in(sess, tokens.clone(), "meta list", |p| p.parse_meta_seq_top())?;
|
let nmis = parse_in(sess, tokens.clone(), "meta list", |p| p.parse_meta_seq_top())?;
|
||||||
MetaItemKind::List(nmis)
|
MetaItemKind::List(nmis)
|
||||||
}
|
}
|
||||||
|
@ -84,19 +84,24 @@ pub fn parse_meta<'a>(sess: &'a ParseSess, attr: &Attribute) -> PResult<'a, Meta
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_meta_bad_delim(sess: &ParseSess, span: DelimSpan, delim: MacDelimiter, msg: &str) {
|
pub fn check_meta_bad_delim(sess: &ParseSess, span: DelimSpan, delim: MacDelimiter) {
|
||||||
if let ast::MacDelimiter::Parenthesis = delim {
|
if let ast::MacDelimiter::Parenthesis = delim {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
sess.emit_err(errors::MetaBadDelim {
|
||||||
|
span: span.entire(),
|
||||||
|
sugg: errors::MetaBadDelimSugg { open: span.open, close: span.close },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
sess.span_diagnostic
|
pub fn check_cfg_attr_bad_delim(sess: &ParseSess, span: DelimSpan, delim: MacDelimiter) {
|
||||||
.struct_span_err(span.entire(), msg)
|
if let ast::MacDelimiter::Parenthesis = delim {
|
||||||
.multipart_suggestion(
|
return;
|
||||||
"the delimiters should be `(` and `)`",
|
}
|
||||||
vec![(span.open, "(".to_string()), (span.close, ")".to_string())],
|
sess.emit_err(errors::CfgAttrBadDelim {
|
||||||
Applicability::MachineApplicable,
|
span: span.entire(),
|
||||||
)
|
sugg: errors::MetaBadDelimSugg { open: span.open, close: span.close },
|
||||||
.emit();
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks that the given meta-item is compatible with this `AttributeTemplate`.
|
/// Checks that the given meta-item is compatible with this `AttributeTemplate`.
|
||||||
|
|
|
@ -2,13 +2,23 @@ error: expected `!` after `macro_rules`
|
||||||
--> $DIR/missing-bang-in-decl.rs:5:1
|
--> $DIR/missing-bang-in-decl.rs:5:1
|
||||||
|
|
|
|
||||||
LL | macro_rules foo {
|
LL | macro_rules foo {
|
||||||
| ^^^^^^^^^^^ help: add a `!`: `macro_rules!`
|
| ^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
help: add a `!`
|
||||||
|
|
|
||||||
|
LL | macro_rules! foo {
|
||||||
|
| +
|
||||||
|
|
||||||
error: expected `!` after `macro_rules`
|
error: expected `!` after `macro_rules`
|
||||||
--> $DIR/missing-bang-in-decl.rs:10:1
|
--> $DIR/missing-bang-in-decl.rs:10:1
|
||||||
|
|
|
|
||||||
LL | macro_rules bar! {
|
LL | macro_rules bar! {
|
||||||
| ^^^^^^^^^^^ help: add a `!`: `macro_rules!`
|
| ^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
help: add a `!`
|
||||||
|
|
|
||||||
|
LL | macro_rules! bar! {
|
||||||
|
| +
|
||||||
|
|
||||||
error: macro names aren't followed by a `!`
|
error: macro names aren't followed by a `!`
|
||||||
--> $DIR/missing-bang-in-decl.rs:10:16
|
--> $DIR/missing-bang-in-decl.rs:10:16
|
||||||
|
|
|
@ -4,31 +4,31 @@
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
||||||
use std::ptr::read; //~ ERROR keyword `use` is written in a wrong case
|
use std::ptr::read; //~ ERROR keyword `use` is written in the wrong case
|
||||||
use std::ptr::write; //~ ERROR keyword `use` is written in a wrong case
|
use std::ptr::write; //~ ERROR keyword `use` is written in the wrong case
|
||||||
|
|
||||||
async fn _a() {}
|
async fn _a() {}
|
||||||
//~^ ERROR keyword `fn` is written in a wrong case
|
//~^ ERROR keyword `fn` is written in the wrong case
|
||||||
|
|
||||||
fn _b() {}
|
fn _b() {}
|
||||||
//~^ ERROR keyword `fn` is written in a wrong case
|
//~^ ERROR keyword `fn` is written in the wrong case
|
||||||
|
|
||||||
async fn _c() {}
|
async fn _c() {}
|
||||||
//~^ ERROR keyword `async` is written in a wrong case
|
//~^ ERROR keyword `async` is written in the wrong case
|
||||||
//~| ERROR keyword `fn` is written in a wrong case
|
//~| ERROR keyword `fn` is written in the wrong case
|
||||||
|
|
||||||
async fn _d() {}
|
async fn _d() {}
|
||||||
//~^ ERROR keyword `async` is written in a wrong case
|
//~^ ERROR keyword `async` is written in the wrong case
|
||||||
|
|
||||||
const unsafe fn _e() {}
|
const unsafe fn _e() {}
|
||||||
//~^ ERROR keyword `const` is written in a wrong case
|
//~^ ERROR keyword `const` is written in the wrong case
|
||||||
//~| ERROR keyword `unsafe` is written in a wrong case
|
//~| ERROR keyword `unsafe` is written in the wrong case
|
||||||
//~| ERROR keyword `fn` is written in a wrong case
|
//~| ERROR keyword `fn` is written in the wrong case
|
||||||
|
|
||||||
unsafe extern fn _f() {}
|
unsafe extern fn _f() {}
|
||||||
//~^ ERROR keyword `unsafe` is written in a wrong case
|
//~^ ERROR keyword `unsafe` is written in the wrong case
|
||||||
//~| ERROR keyword `extern` is written in a wrong case
|
//~| ERROR keyword `extern` is written in the wrong case
|
||||||
|
|
||||||
extern "C" fn _g() {}
|
extern "C" fn _g() {}
|
||||||
//~^ ERROR keyword `extern` is written in a wrong case
|
//~^ ERROR keyword `extern` is written in the wrong case
|
||||||
//~| ERROR keyword `fn` is written in a wrong case
|
//~| ERROR keyword `fn` is written in the wrong case
|
||||||
|
|
|
@ -4,31 +4,31 @@
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
||||||
Use std::ptr::read; //~ ERROR keyword `use` is written in a wrong case
|
Use std::ptr::read; //~ ERROR keyword `use` is written in the wrong case
|
||||||
USE std::ptr::write; //~ ERROR keyword `use` is written in a wrong case
|
USE std::ptr::write; //~ ERROR keyword `use` is written in the wrong case
|
||||||
|
|
||||||
async Fn _a() {}
|
async Fn _a() {}
|
||||||
//~^ ERROR keyword `fn` is written in a wrong case
|
//~^ ERROR keyword `fn` is written in the wrong case
|
||||||
|
|
||||||
Fn _b() {}
|
Fn _b() {}
|
||||||
//~^ ERROR keyword `fn` is written in a wrong case
|
//~^ ERROR keyword `fn` is written in the wrong case
|
||||||
|
|
||||||
aSYNC fN _c() {}
|
aSYNC fN _c() {}
|
||||||
//~^ ERROR keyword `async` is written in a wrong case
|
//~^ ERROR keyword `async` is written in the wrong case
|
||||||
//~| ERROR keyword `fn` is written in a wrong case
|
//~| ERROR keyword `fn` is written in the wrong case
|
||||||
|
|
||||||
Async fn _d() {}
|
Async fn _d() {}
|
||||||
//~^ ERROR keyword `async` is written in a wrong case
|
//~^ ERROR keyword `async` is written in the wrong case
|
||||||
|
|
||||||
CONST UNSAFE FN _e() {}
|
CONST UNSAFE FN _e() {}
|
||||||
//~^ ERROR keyword `const` is written in a wrong case
|
//~^ ERROR keyword `const` is written in the wrong case
|
||||||
//~| ERROR keyword `unsafe` is written in a wrong case
|
//~| ERROR keyword `unsafe` is written in the wrong case
|
||||||
//~| ERROR keyword `fn` is written in a wrong case
|
//~| ERROR keyword `fn` is written in the wrong case
|
||||||
|
|
||||||
unSAFE EXTern fn _f() {}
|
unSAFE EXTern fn _f() {}
|
||||||
//~^ ERROR keyword `unsafe` is written in a wrong case
|
//~^ ERROR keyword `unsafe` is written in the wrong case
|
||||||
//~| ERROR keyword `extern` is written in a wrong case
|
//~| ERROR keyword `extern` is written in the wrong case
|
||||||
|
|
||||||
EXTERN "C" FN _g() {}
|
EXTERN "C" FN _g() {}
|
||||||
//~^ ERROR keyword `extern` is written in a wrong case
|
//~^ ERROR keyword `extern` is written in the wrong case
|
||||||
//~| ERROR keyword `fn` is written in a wrong case
|
//~| ERROR keyword `fn` is written in the wrong case
|
||||||
|
|
|
@ -1,82 +1,82 @@
|
||||||
error: keyword `use` is written in a wrong case
|
error: keyword `use` is written in the wrong case
|
||||||
--> $DIR/item-kw-case-mismatch.rs:7:1
|
--> $DIR/item-kw-case-mismatch.rs:7:1
|
||||||
|
|
|
|
||||||
LL | Use std::ptr::read;
|
LL | Use std::ptr::read;
|
||||||
| ^^^ help: write it in the correct case (notice the capitalization): `use`
|
| ^^^ help: write it in the correct case (notice the capitalization): `use`
|
||||||
|
|
||||||
error: keyword `use` is written in a wrong case
|
error: keyword `use` is written in the wrong case
|
||||||
--> $DIR/item-kw-case-mismatch.rs:8:1
|
--> $DIR/item-kw-case-mismatch.rs:8:1
|
||||||
|
|
|
|
||||||
LL | USE std::ptr::write;
|
LL | USE std::ptr::write;
|
||||||
| ^^^ help: write it in the correct case: `use`
|
| ^^^ help: write it in the correct case: `use`
|
||||||
|
|
||||||
error: keyword `fn` is written in a wrong case
|
error: keyword `fn` is written in the wrong case
|
||||||
--> $DIR/item-kw-case-mismatch.rs:10:7
|
--> $DIR/item-kw-case-mismatch.rs:10:7
|
||||||
|
|
|
|
||||||
LL | async Fn _a() {}
|
LL | async Fn _a() {}
|
||||||
| ^^ help: write it in the correct case (notice the capitalization): `fn`
|
| ^^ help: write it in the correct case (notice the capitalization): `fn`
|
||||||
|
|
||||||
error: keyword `fn` is written in a wrong case
|
error: keyword `fn` is written in the wrong case
|
||||||
--> $DIR/item-kw-case-mismatch.rs:13:1
|
--> $DIR/item-kw-case-mismatch.rs:13:1
|
||||||
|
|
|
|
||||||
LL | Fn _b() {}
|
LL | Fn _b() {}
|
||||||
| ^^ help: write it in the correct case (notice the capitalization): `fn`
|
| ^^ help: write it in the correct case (notice the capitalization): `fn`
|
||||||
|
|
||||||
error: keyword `async` is written in a wrong case
|
error: keyword `async` is written in the wrong case
|
||||||
--> $DIR/item-kw-case-mismatch.rs:16:1
|
--> $DIR/item-kw-case-mismatch.rs:16:1
|
||||||
|
|
|
|
||||||
LL | aSYNC fN _c() {}
|
LL | aSYNC fN _c() {}
|
||||||
| ^^^^^ help: write it in the correct case: `async`
|
| ^^^^^ help: write it in the correct case: `async`
|
||||||
|
|
||||||
error: keyword `fn` is written in a wrong case
|
error: keyword `fn` is written in the wrong case
|
||||||
--> $DIR/item-kw-case-mismatch.rs:16:7
|
--> $DIR/item-kw-case-mismatch.rs:16:7
|
||||||
|
|
|
|
||||||
LL | aSYNC fN _c() {}
|
LL | aSYNC fN _c() {}
|
||||||
| ^^ help: write it in the correct case: `fn`
|
| ^^ help: write it in the correct case: `fn`
|
||||||
|
|
||||||
error: keyword `async` is written in a wrong case
|
error: keyword `async` is written in the wrong case
|
||||||
--> $DIR/item-kw-case-mismatch.rs:20:1
|
--> $DIR/item-kw-case-mismatch.rs:20:1
|
||||||
|
|
|
|
||||||
LL | Async fn _d() {}
|
LL | Async fn _d() {}
|
||||||
| ^^^^^ help: write it in the correct case: `async`
|
| ^^^^^ help: write it in the correct case: `async`
|
||||||
|
|
||||||
error: keyword `const` is written in a wrong case
|
error: keyword `const` is written in the wrong case
|
||||||
--> $DIR/item-kw-case-mismatch.rs:23:1
|
--> $DIR/item-kw-case-mismatch.rs:23:1
|
||||||
|
|
|
|
||||||
LL | CONST UNSAFE FN _e() {}
|
LL | CONST UNSAFE FN _e() {}
|
||||||
| ^^^^^ help: write it in the correct case: `const`
|
| ^^^^^ help: write it in the correct case: `const`
|
||||||
|
|
||||||
error: keyword `unsafe` is written in a wrong case
|
error: keyword `unsafe` is written in the wrong case
|
||||||
--> $DIR/item-kw-case-mismatch.rs:23:7
|
--> $DIR/item-kw-case-mismatch.rs:23:7
|
||||||
|
|
|
|
||||||
LL | CONST UNSAFE FN _e() {}
|
LL | CONST UNSAFE FN _e() {}
|
||||||
| ^^^^^^ help: write it in the correct case: `unsafe`
|
| ^^^^^^ help: write it in the correct case: `unsafe`
|
||||||
|
|
||||||
error: keyword `fn` is written in a wrong case
|
error: keyword `fn` is written in the wrong case
|
||||||
--> $DIR/item-kw-case-mismatch.rs:23:14
|
--> $DIR/item-kw-case-mismatch.rs:23:14
|
||||||
|
|
|
|
||||||
LL | CONST UNSAFE FN _e() {}
|
LL | CONST UNSAFE FN _e() {}
|
||||||
| ^^ help: write it in the correct case: `fn`
|
| ^^ help: write it in the correct case: `fn`
|
||||||
|
|
||||||
error: keyword `unsafe` is written in a wrong case
|
error: keyword `unsafe` is written in the wrong case
|
||||||
--> $DIR/item-kw-case-mismatch.rs:28:1
|
--> $DIR/item-kw-case-mismatch.rs:28:1
|
||||||
|
|
|
|
||||||
LL | unSAFE EXTern fn _f() {}
|
LL | unSAFE EXTern fn _f() {}
|
||||||
| ^^^^^^ help: write it in the correct case: `unsafe`
|
| ^^^^^^ help: write it in the correct case: `unsafe`
|
||||||
|
|
||||||
error: keyword `extern` is written in a wrong case
|
error: keyword `extern` is written in the wrong case
|
||||||
--> $DIR/item-kw-case-mismatch.rs:28:8
|
--> $DIR/item-kw-case-mismatch.rs:28:8
|
||||||
|
|
|
|
||||||
LL | unSAFE EXTern fn _f() {}
|
LL | unSAFE EXTern fn _f() {}
|
||||||
| ^^^^^^ help: write it in the correct case: `extern`
|
| ^^^^^^ help: write it in the correct case: `extern`
|
||||||
|
|
||||||
error: keyword `extern` is written in a wrong case
|
error: keyword `extern` is written in the wrong case
|
||||||
--> $DIR/item-kw-case-mismatch.rs:32:1
|
--> $DIR/item-kw-case-mismatch.rs:32:1
|
||||||
|
|
|
|
||||||
LL | EXTERN "C" FN _g() {}
|
LL | EXTERN "C" FN _g() {}
|
||||||
| ^^^^^^ help: write it in the correct case: `extern`
|
| ^^^^^^ help: write it in the correct case: `extern`
|
||||||
|
|
||||||
error: keyword `fn` is written in a wrong case
|
error: keyword `fn` is written in the wrong case
|
||||||
--> $DIR/item-kw-case-mismatch.rs:32:12
|
--> $DIR/item-kw-case-mismatch.rs:32:12
|
||||||
|
|
|
|
||||||
LL | EXTERN "C" FN _g() {}
|
LL | EXTERN "C" FN _g() {}
|
||||||
|
|
|
@ -2,13 +2,17 @@ error: expected a label, found an identifier
|
||||||
--> $DIR/recover-unticked-labels.rs:5:26
|
--> $DIR/recover-unticked-labels.rs:5:26
|
||||||
|
|
|
|
||||||
LL | 'label: loop { break label 0 };
|
LL | 'label: loop { break label 0 };
|
||||||
| ^^^^^ help: labels start with a tick: `'label`
|
| -^^^^
|
||||||
|
| |
|
||||||
|
| help: labels start with a tick
|
||||||
|
|
||||||
error: expected a label, found an identifier
|
error: expected a label, found an identifier
|
||||||
--> $DIR/recover-unticked-labels.rs:6:29
|
--> $DIR/recover-unticked-labels.rs:6:29
|
||||||
|
|
|
|
||||||
LL | 'label: loop { continue label };
|
LL | 'label: loop { continue label };
|
||||||
| ^^^^^ help: labels start with a tick: `'label`
|
| -^^^^
|
||||||
|
| |
|
||||||
|
| help: labels start with a tick
|
||||||
|
|
||||||
error[E0425]: cannot find value `label` in this scope
|
error[E0425]: cannot find value `label` in this scope
|
||||||
--> $DIR/recover-unticked-labels.rs:4:26
|
--> $DIR/recover-unticked-labels.rs:4:26
|
||||||
|
|
|
@ -11,18 +11,24 @@ error: expected `::`, found `:`
|
||||||
|
|
|
|
||||||
LL | use std:fs::File;
|
LL | use std:fs::File;
|
||||||
| ^ help: use double colon
|
| ^ help: use double colon
|
||||||
|
|
|
||||||
|
= note: import paths are delimited using `::`
|
||||||
|
|
||||||
error: expected `::`, found `:`
|
error: expected `::`, found `:`
|
||||||
--> $DIR/use-colon-as-mod-sep.rs:7:8
|
--> $DIR/use-colon-as-mod-sep.rs:7:8
|
||||||
|
|
|
|
||||||
LL | use std:collections:HashMap;
|
LL | use std:collections:HashMap;
|
||||||
| ^ help: use double colon
|
| ^ help: use double colon
|
||||||
|
|
|
||||||
|
= note: import paths are delimited using `::`
|
||||||
|
|
||||||
error: expected `::`, found `:`
|
error: expected `::`, found `:`
|
||||||
--> $DIR/use-colon-as-mod-sep.rs:7:20
|
--> $DIR/use-colon-as-mod-sep.rs:7:20
|
||||||
|
|
|
|
||||||
LL | use std:collections:HashMap;
|
LL | use std:collections:HashMap;
|
||||||
| ^ help: use double colon
|
| ^ help: use double colon
|
||||||
|
|
|
||||||
|
= note: import paths are delimited using `::`
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue