summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_passes/src/errors.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_passes/src/errors.rs')
-rw-r--r--compiler/rustc_passes/src/errors.rs205
1 files changed, 145 insertions, 60 deletions
diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs
index 9c6519ea4..9f1c0b5a0 100644
--- a/compiler/rustc_passes/src/errors.rs
+++ b/compiler/rustc_passes/src/errors.rs
@@ -3,6 +3,7 @@ use std::{
path::{Path, PathBuf},
};
+use crate::fluent_generated as fluent;
use rustc_ast::Label;
use rustc_errors::{
error_code, Applicability, DiagnosticSymbolList, ErrorGuaranteed, IntoDiagnostic, MultiSpan,
@@ -12,6 +13,7 @@ use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_middle::ty::{MainDefinition, Ty};
use rustc_span::{Span, Symbol, DUMMY_SP};
+use crate::check_attr::ProcMacroKind;
use crate::lang_items::Duplicate;
#[derive(Diagnostic)]
@@ -260,7 +262,7 @@ pub struct DocKeywordConflict {
pub struct DocInlineOnlyUse {
#[label]
pub attr_span: Span,
- #[label(not_a_use_item_label)]
+ #[label(passes_not_a_use_item_label)]
pub item_span: Option<Span>,
}
@@ -299,7 +301,7 @@ pub struct DocTestUnknownAny {
#[derive(LintDiagnostic)]
#[diag(passes_doc_test_unknown_spotlight)]
#[note]
-#[note(no_op_note)]
+#[note(passes_no_op_note)]
pub struct DocTestUnknownSpotlight {
pub path: String,
#[suggestion(style = "short", applicability = "machine-applicable", code = "notable_trait")]
@@ -347,6 +349,34 @@ pub struct HasIncoherentInherentImpl {
pub span: Span,
}
+#[derive(Diagnostic)]
+#[diag(passes_both_ffi_const_and_pure, code = "E0757")]
+pub struct BothFfiConstAndPure {
+ #[primary_span]
+ pub attr_span: Span,
+}
+
+#[derive(Diagnostic)]
+#[diag(passes_ffi_pure_invalid_target, code = "E0755")]
+pub struct FfiPureInvalidTarget {
+ #[primary_span]
+ pub attr_span: Span,
+}
+
+#[derive(Diagnostic)]
+#[diag(passes_ffi_const_invalid_target, code = "E0756")]
+pub struct FfiConstInvalidTarget {
+ #[primary_span]
+ pub attr_span: Span,
+}
+
+#[derive(Diagnostic)]
+#[diag(passes_ffi_returns_twice_invalid_target, code = "E0724")]
+pub struct FfiReturnsTwiceInvalidTarget {
+ #[primary_span]
+ pub attr_span: Span,
+}
+
#[derive(LintDiagnostic)]
#[diag(passes_must_use_async)]
pub struct MustUseAsync {
@@ -544,9 +574,9 @@ pub struct DebugVisualizerPlacement {
#[derive(Diagnostic)]
#[diag(passes_debug_visualizer_invalid)]
-#[note(note_1)]
-#[note(note_2)]
-#[note(note_3)]
+#[note(passes_note_1)]
+#[note(passes_note_2)]
+#[note(passes_note_3)]
pub struct DebugVisualizerInvalid {
#[primary_span]
pub span: Span,
@@ -611,8 +641,16 @@ pub struct MacroUse {
}
#[derive(LintDiagnostic)]
-#[diag(passes_macro_export)]
-pub struct MacroExport;
+pub enum MacroExport {
+ #[diag(passes_macro_export)]
+ Normal,
+
+ #[diag(passes_invalid_macro_export_arguments)]
+ UnknownItem { name: Symbol },
+
+ #[diag(passes_invalid_macro_export_arguments_too_many_items)]
+ TooManyItems,
+}
#[derive(LintDiagnostic)]
#[diag(passes_plugin_registrar)]
@@ -753,7 +791,7 @@ impl IntoDiagnostic<'_> for InvalidAttrAtCrateLevel {
self,
handler: &'_ rustc_errors::Handler,
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
- let mut diag = handler.struct_err(rustc_errors::fluent::passes_invalid_attr_at_crate_level);
+ let mut diag = handler.struct_err(fluent::passes_invalid_attr_at_crate_level);
diag.set_span(self.span);
diag.set_arg("name", self.name);
// Only emit an error with a suggestion if we can create a string out
@@ -762,7 +800,7 @@ impl IntoDiagnostic<'_> for InvalidAttrAtCrateLevel {
let replacement = src.replace("#!", "#");
diag.span_suggestion_verbose(
self.span,
- rustc_errors::fluent::suggestion,
+ fluent::passes_suggestion,
replacement,
rustc_errors::Applicability::MachineApplicable,
);
@@ -772,22 +810,16 @@ impl IntoDiagnostic<'_> for InvalidAttrAtCrateLevel {
}
#[derive(Diagnostic)]
-#[diag(passes_duplicate_diagnostic_item)]
-pub struct DuplicateDiagnosticItem {
- #[primary_span]
- pub span: Span,
- pub name: Symbol,
-}
-
-#[derive(Diagnostic)]
#[diag(passes_duplicate_diagnostic_item_in_crate)]
pub struct DuplicateDiagnosticItemInCrate {
+ #[primary_span]
+ pub duplicate_span: Option<Span>,
#[note(passes_diagnostic_item_first_defined)]
- pub span: Option<Span>,
- pub orig_crate_name: Symbol,
+ pub orig_span: Option<Span>,
#[note]
- pub have_orig_crate_name: Option<()>,
+ pub different_crates: Option<()>,
pub crate_name: Symbol,
+ pub orig_crate_name: Symbol,
pub name: Symbol,
}
@@ -888,17 +920,17 @@ impl<'a> IntoDiagnostic<'_> for BreakNonLoop<'a> {
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut diag = handler.struct_span_err_with_code(
self.span,
- rustc_errors::fluent::passes_break_non_loop,
+ fluent::passes_break_non_loop,
error_code!(E0571),
);
diag.set_arg("kind", self.kind);
- diag.span_label(self.span, rustc_errors::fluent::label);
+ diag.span_label(self.span, fluent::passes_label);
if let Some(head) = self.head {
- diag.span_label(head, rustc_errors::fluent::label2);
+ diag.span_label(head, fluent::passes_label2);
}
diag.span_suggestion(
self.span,
- rustc_errors::fluent::suggestion,
+ fluent::passes_suggestion,
self.suggestion,
Applicability::MaybeIncorrect,
);
@@ -916,7 +948,7 @@ impl<'a> IntoDiagnostic<'_> for BreakNonLoop<'a> {
_ => {
diag.span_suggestion(
self.break_expr_span,
- rustc_errors::fluent::break_expr_suggestion,
+ fluent::passes_break_expr_suggestion,
label.ident,
Applicability::MaybeIncorrect,
);
@@ -933,7 +965,7 @@ pub struct ContinueLabeledBlock {
#[primary_span]
#[label]
pub span: Span,
- #[label(block_label)]
+ #[label(passes_block_label)]
pub block_span: Span,
}
@@ -943,7 +975,7 @@ pub struct BreakInsideClosure<'a> {
#[primary_span]
#[label]
pub span: Span,
- #[label(closure_label)]
+ #[label(passes_closure_label)]
pub closure_span: Span,
pub name: &'a str,
}
@@ -954,7 +986,7 @@ pub struct BreakInsideAsyncBlock<'a> {
#[primary_span]
#[label]
pub span: Span,
- #[label(async_block_label)]
+ #[label(passes_async_block_label)]
pub closure_span: Span,
pub name: &'a str,
}
@@ -1027,14 +1059,14 @@ impl IntoDiagnostic<'_> for NakedFunctionsAsmBlock {
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut diag = handler.struct_span_err_with_code(
self.span,
- rustc_errors::fluent::passes_naked_functions_asm_block,
+ fluent::passes_naked_functions_asm_block,
error_code!(E0787),
);
for span in self.multiple_asms.iter() {
- diag.span_label(*span, rustc_errors::fluent::label_multiple_asm);
+ diag.span_label(*span, fluent::passes_label_multiple_asm);
}
for span in self.non_asms.iter() {
- diag.span_label(*span, rustc_errors::fluent::label_non_asm);
+ diag.span_label(*span, fluent::passes_label_non_asm);
}
diag
}
@@ -1093,9 +1125,9 @@ pub struct AttrOnlyInFunctions {
pub struct MultipleRustcMain {
#[primary_span]
pub span: Span,
- #[label(first)]
+ #[label(passes_first)]
pub first: Span,
- #[label(additional)]
+ #[label(passes_additional)]
pub additional: Span,
}
@@ -1106,7 +1138,7 @@ pub struct MultipleStartFunctions {
pub span: Span,
#[label]
pub labeled: Span,
- #[label(previous)]
+ #[label(passes_previous)]
pub previous: Span,
}
@@ -1151,7 +1183,7 @@ impl<'a> IntoDiagnostic<'a> for NoMainErr {
) -> rustc_errors::DiagnosticBuilder<'a, ErrorGuaranteed> {
let mut diag = handler.struct_span_err_with_code(
DUMMY_SP,
- rustc_errors::fluent::passes_no_main_function,
+ fluent::passes_no_main_function,
error_code!(E0601),
);
diag.set_arg("crate_name", self.crate_name);
@@ -1159,16 +1191,16 @@ impl<'a> IntoDiagnostic<'a> for NoMainErr {
diag.set_arg("has_filename", self.has_filename);
let note = if !self.non_main_fns.is_empty() {
for &span in &self.non_main_fns {
- diag.span_note(span, rustc_errors::fluent::here_is_main);
+ diag.span_note(span, fluent::passes_here_is_main);
}
- diag.note(rustc_errors::fluent::one_or_more_possible_main);
- diag.help(rustc_errors::fluent::consider_moving_main);
+ diag.note(fluent::passes_one_or_more_possible_main);
+ diag.help(fluent::passes_consider_moving_main);
// There were some functions named `main` though. Try to give the user a hint.
- rustc_errors::fluent::main_must_be_defined_at_crate
+ fluent::passes_main_must_be_defined_at_crate
} else if self.has_filename {
- rustc_errors::fluent::consider_adding_main_to_file
+ fluent::passes_consider_adding_main_to_file
} else {
- rustc_errors::fluent::consider_adding_main_at_crate
+ fluent::passes_consider_adding_main_at_crate
};
if self.file_empty {
diag.note(note);
@@ -1179,11 +1211,11 @@ impl<'a> IntoDiagnostic<'a> for NoMainErr {
if let Some(main_def) = self.main_def_opt && main_def.opt_fn_def_id().is_none(){
// There is something at `crate::main`, but it is not a function definition.
- diag.span_label(main_def.span, rustc_errors::fluent::non_function_main);
+ diag.span_label(main_def.span, fluent::passes_non_function_main);
}
if self.add_teach_note {
- diag.note(rustc_errors::fluent::teach_note);
+ diag.note(fluent::passes_teach_note);
}
diag
}
@@ -1212,12 +1244,9 @@ impl IntoDiagnostic<'_> for DuplicateLangItem {
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut diag = handler.struct_err_with_code(
match self.duplicate {
- Duplicate::Plain => rustc_errors::fluent::passes_duplicate_lang_item,
-
- Duplicate::Crate => rustc_errors::fluent::passes_duplicate_lang_item_crate,
- Duplicate::CrateDepends => {
- rustc_errors::fluent::passes_duplicate_lang_item_crate_depends
- }
+ Duplicate::Plain => fluent::passes_duplicate_lang_item,
+ Duplicate::Crate => fluent::passes_duplicate_lang_item_crate,
+ Duplicate::CrateDepends => fluent::passes_duplicate_lang_item_crate_depends,
},
error_code!(E0152),
);
@@ -1232,24 +1261,24 @@ impl IntoDiagnostic<'_> for DuplicateLangItem {
diag.set_span(span);
}
if let Some(span) = self.first_defined_span {
- diag.span_note(span, rustc_errors::fluent::first_defined_span);
+ diag.span_note(span, fluent::passes_first_defined_span);
} else {
if self.orig_dependency_of.is_empty() {
- diag.note(rustc_errors::fluent::first_defined_crate);
+ diag.note(fluent::passes_first_defined_crate);
} else {
- diag.note(rustc_errors::fluent::first_defined_crate_depends);
+ diag.note(fluent::passes_first_defined_crate_depends);
}
if self.orig_is_local {
- diag.note(rustc_errors::fluent::first_definition_local);
+ diag.note(fluent::passes_first_definition_local);
} else {
- diag.note(rustc_errors::fluent::first_definition_path);
+ diag.note(fluent::passes_first_definition_path);
}
if self.is_local {
- diag.note(rustc_errors::fluent::second_definition_local);
+ diag.note(fluent::passes_second_definition_local);
} else {
- diag.note(rustc_errors::fluent::second_definition_path);
+ diag.note(fluent::passes_second_definition_path);
}
}
diag
@@ -1360,7 +1389,7 @@ pub struct UselessStability {
#[primary_span]
#[label]
pub span: Span,
- #[label(item)]
+ #[label(passes_item)]
pub item_sp: Span,
}
@@ -1370,7 +1399,7 @@ pub struct InvalidStability {
#[primary_span]
#[label]
pub span: Span,
- #[label(item)]
+ #[label(passes_item)]
pub item_sp: Span,
}
@@ -1380,7 +1409,7 @@ pub struct CannotStabilizeDeprecated {
#[primary_span]
#[label]
pub span: Span,
- #[label(item)]
+ #[label(passes_item)]
pub item_sp: Span,
}
@@ -1390,7 +1419,7 @@ pub struct InvalidDeprecationVersion {
#[primary_span]
#[label]
pub span: Span,
- #[label(item)]
+ #[label(passes_item)]
pub item_sp: Span,
}
@@ -1515,3 +1544,59 @@ pub struct ChangeFieldsToBeOfUnitType {
#[suggestion_part(code = "()")]
pub spans: Vec<Span>,
}
+
+#[derive(Diagnostic)]
+#[diag(passes_proc_macro_typeerror)]
+#[note]
+pub(crate) struct ProcMacroTypeError<'tcx> {
+ #[primary_span]
+ #[label]
+ pub span: Span,
+ pub found: Ty<'tcx>,
+ pub kind: ProcMacroKind,
+ pub expected_signature: &'static str,
+}
+
+#[derive(Diagnostic)]
+#[diag(passes_proc_macro_diff_arg_count)]
+pub(crate) struct ProcMacroDiffArguments {
+ #[primary_span]
+ #[label]
+ pub span: Span,
+ pub count: usize,
+ pub kind: ProcMacroKind,
+ pub expected_signature: &'static str,
+}
+
+#[derive(Diagnostic)]
+#[diag(passes_proc_macro_missing_args)]
+pub(crate) struct ProcMacroMissingArguments {
+ #[primary_span]
+ #[label]
+ pub span: Span,
+ pub expected_input_count: usize,
+ pub kind: ProcMacroKind,
+ pub expected_signature: &'static str,
+}
+
+#[derive(Diagnostic)]
+#[diag(passes_proc_macro_invalid_abi)]
+pub(crate) struct ProcMacroInvalidAbi {
+ #[primary_span]
+ pub span: Span,
+ pub abi: &'static str,
+}
+
+#[derive(Diagnostic)]
+#[diag(passes_proc_macro_unsafe)]
+pub(crate) struct ProcMacroUnsafe {
+ #[primary_span]
+ pub span: Span,
+}
+
+#[derive(Diagnostic)]
+#[diag(passes_skipping_const_checks)]
+pub struct SkippingConstChecks {
+ #[primary_span]
+ pub span: Span,
+}