diff options
Diffstat (limited to 'compiler/rustc_passes/src/errors.rs')
| -rw-r--r-- | compiler/rustc_passes/src/errors.rs | 180 |
1 files changed, 1 insertions, 179 deletions
diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 00682a9c7a7..74ce92624bd 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -1,13 +1,12 @@ use std::io::Error; use std::path::{Path, PathBuf}; -use rustc_ast::Label; use rustc_errors::codes::*; use rustc_errors::{ Applicability, Diag, DiagCtxtHandle, DiagSymbolList, Diagnostic, EmissionGuarantee, Level, MultiSpan, Subdiagnostic, }; -use rustc_hir::{self as hir, ExprKind, Target}; +use rustc_hir::Target; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; use rustc_middle::ty::{MainDefinition, Ty}; use rustc_span::{DUMMY_SP, Span, Symbol}; @@ -1071,176 +1070,6 @@ pub(crate) struct FeaturePreviouslyDeclared<'a> { pub prev_declared: &'a str, } -pub(crate) struct BreakNonLoop<'a> { - pub span: Span, - pub head: Option<Span>, - pub kind: &'a str, - pub suggestion: String, - pub loop_label: Option<Label>, - pub break_label: Option<Label>, - pub break_expr_kind: &'a ExprKind<'a>, - pub break_expr_span: Span, -} - -impl<'a, G: EmissionGuarantee> Diagnostic<'_, G> for BreakNonLoop<'a> { - #[track_caller] - fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { - let mut diag = Diag::new(dcx, level, fluent::passes_break_non_loop); - diag.span(self.span); - diag.code(E0571); - diag.arg("kind", self.kind); - diag.span_label(self.span, fluent::passes_label); - if let Some(head) = self.head { - diag.span_label(head, fluent::passes_label2); - } - diag.span_suggestion( - self.span, - fluent::passes_suggestion, - self.suggestion, - Applicability::MaybeIncorrect, - ); - if let (Some(label), None) = (self.loop_label, self.break_label) { - match self.break_expr_kind { - ExprKind::Path(hir::QPath::Resolved( - None, - hir::Path { segments: [segment], res: hir::def::Res::Err, .. }, - )) if label.ident.to_string() == format!("'{}", segment.ident) => { - // This error is redundant, we will have already emitted a - // suggestion to use the label when `segment` wasn't found - // (hence the `Res::Err` check). - diag.downgrade_to_delayed_bug(); - } - _ => { - diag.span_suggestion( - self.break_expr_span, - fluent::passes_break_expr_suggestion, - label.ident, - Applicability::MaybeIncorrect, - ); - } - } - } - diag - } -} - -#[derive(Diagnostic)] -#[diag(passes_continue_labeled_block, code = E0696)] -pub(crate) struct ContinueLabeledBlock { - #[primary_span] - #[label] - pub span: Span, - #[label(passes_block_label)] - pub block_span: Span, -} - -#[derive(Diagnostic)] -#[diag(passes_break_inside_closure, code = E0267)] -pub(crate) struct BreakInsideClosure<'a> { - #[primary_span] - #[label] - pub span: Span, - #[label(passes_closure_label)] - pub closure_span: Span, - pub name: &'a str, -} - -#[derive(Diagnostic)] -#[diag(passes_break_inside_coroutine, code = E0267)] -pub(crate) struct BreakInsideCoroutine<'a> { - #[primary_span] - #[label] - pub span: Span, - #[label(passes_coroutine_label)] - pub coroutine_span: Span, - pub name: &'a str, - pub kind: &'a str, - pub source: &'a str, -} - -#[derive(Diagnostic)] -#[diag(passes_outside_loop, code = E0268)] -pub(crate) struct OutsideLoop<'a> { - #[primary_span] - #[label] - pub spans: Vec<Span>, - pub name: &'a str, - pub is_break: bool, - #[subdiagnostic] - pub suggestion: Option<OutsideLoopSuggestion>, -} -#[derive(Subdiagnostic)] -#[multipart_suggestion(passes_outside_loop_suggestion, applicability = "maybe-incorrect")] -pub(crate) struct OutsideLoopSuggestion { - #[suggestion_part(code = "'block: ")] - pub block_span: Span, - #[suggestion_part(code = " 'block")] - pub break_spans: Vec<Span>, -} - -#[derive(Diagnostic)] -#[diag(passes_unlabeled_in_labeled_block, code = E0695)] -pub(crate) struct UnlabeledInLabeledBlock<'a> { - #[primary_span] - #[label] - pub span: Span, - pub cf_type: &'a str, -} - -#[derive(Diagnostic)] -#[diag(passes_unlabeled_cf_in_while_condition, code = E0590)] -pub(crate) struct UnlabeledCfInWhileCondition<'a> { - #[primary_span] - #[label] - pub span: Span, - pub cf_type: &'a str, -} - -#[derive(Diagnostic)] -#[diag(passes_no_patterns)] -pub(crate) struct NoPatterns { - #[primary_span] - pub span: Span, -} - -#[derive(Diagnostic)] -#[diag(passes_params_not_allowed)] -#[help] -pub(crate) struct ParamsNotAllowed { - #[primary_span] - pub span: Span, -} - -pub(crate) struct NakedFunctionsAsmBlock { - pub span: Span, - pub multiple_asms: Vec<Span>, - pub non_asms: Vec<Span>, -} - -impl<G: EmissionGuarantee> Diagnostic<'_, G> for NakedFunctionsAsmBlock { - #[track_caller] - fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { - let mut diag = Diag::new(dcx, level, fluent::passes_naked_functions_asm_block); - diag.span(self.span); - diag.code(E0787); - for span in self.multiple_asms.iter() { - diag.span_label(*span, fluent::passes_label_multiple_asm); - } - for span in self.non_asms.iter() { - diag.span_label(*span, fluent::passes_label_non_asm); - } - diag - } -} - -#[derive(Diagnostic)] -#[diag(passes_naked_functions_must_naked_asm, code = E0787)] -pub(crate) struct NakedFunctionsMustNakedAsm { - #[primary_span] - #[label] - pub span: Span, -} - #[derive(Diagnostic)] #[diag(passes_naked_functions_incompatible_attribute, code = E0736)] pub(crate) struct NakedFunctionIncompatibleAttribute { @@ -1253,13 +1082,6 @@ pub(crate) struct NakedFunctionIncompatibleAttribute { } #[derive(Diagnostic)] -#[diag(passes_naked_asm_outside_naked_fn)] -pub(crate) struct NakedAsmOutsideNakedFn { - #[primary_span] - pub span: Span, -} - -#[derive(Diagnostic)] #[diag(passes_attr_only_in_functions)] pub(crate) struct AttrOnlyInFunctions { #[primary_span] |
