diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:50 +0000 |
commit | 9835e2ae736235810b4ea1c162ca5e65c547e770 (patch) | |
tree | 3fcebf40ed70e581d776a8a4c65923e8ec20e026 /compiler/rustc_passes/src/errors.rs | |
parent | Releasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff) | |
download | rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip |
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_passes/src/errors.rs')
-rw-r--r-- | compiler/rustc_passes/src/errors.rs | 164 |
1 files changed, 161 insertions, 3 deletions
diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 139ba8c96..99fc69d1b 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -6,7 +6,8 @@ use std::{ use crate::fluent_generated as fluent; use rustc_ast::Label; use rustc_errors::{ - error_code, Applicability, DiagnosticSymbolList, ErrorGuaranteed, IntoDiagnostic, MultiSpan, + error_code, AddToDiagnostic, Applicability, Diagnostic, DiagnosticSymbolList, ErrorGuaranteed, + IntoDiagnostic, MultiSpan, }; use rustc_hir::{self as hir, ExprKind, Target}; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; @@ -1355,8 +1356,8 @@ pub enum AttrApplication { #[label] span: Span, }, - #[diag(passes_attr_application_struct_enum_function_union, code = "E0517")] - StructEnumFunctionUnion { + #[diag(passes_attr_application_struct_enum_function_method_union, code = "E0517")] + StructEnumFunctionMethodUnion { #[primary_span] hint_span: Span, #[label] @@ -1555,3 +1556,160 @@ pub struct SkippingConstChecks { #[primary_span] pub span: Span, } + +#[derive(LintDiagnostic)] +#[diag(passes_unreachable_due_to_uninhabited)] +pub struct UnreachableDueToUninhabited<'desc, 'tcx> { + pub descr: &'desc str, + #[label] + pub expr: Span, + #[label(passes_label_orig)] + #[note] + pub orig: Span, + pub ty: Ty<'tcx>, +} + +#[derive(LintDiagnostic)] +#[diag(passes_unused_var_maybe_capture_ref)] +#[help] +pub struct UnusedVarMaybeCaptureRef { + pub name: String, +} + +#[derive(LintDiagnostic)] +#[diag(passes_unused_capture_maybe_capture_ref)] +#[help] +pub struct UnusedCaptureMaybeCaptureRef { + pub name: String, +} + +#[derive(LintDiagnostic)] +#[diag(passes_unused_var_remove_field)] +pub struct UnusedVarRemoveField { + pub name: String, + #[subdiagnostic] + pub sugg: UnusedVarRemoveFieldSugg, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion( + passes_unused_var_remove_field_suggestion, + applicability = "machine-applicable" +)] +pub struct UnusedVarRemoveFieldSugg { + #[suggestion_part(code = "")] + pub spans: Vec<Span>, +} + +#[derive(LintDiagnostic)] +#[diag(passes_unused_var_assigned_only)] +#[note] +pub struct UnusedVarAssignedOnly { + pub name: String, +} + +#[derive(LintDiagnostic)] +#[diag(passes_unnecessary_stable_feature)] +pub struct UnnecessaryStableFeature { + pub feature: Symbol, + pub since: Symbol, +} + +#[derive(LintDiagnostic)] +#[diag(passes_unnecessary_partial_stable_feature)] +pub struct UnnecessaryPartialStableFeature { + #[suggestion(code = "{implies}", applicability = "maybe-incorrect")] + pub span: Span, + #[suggestion(passes_suggestion_remove, code = "", applicability = "maybe-incorrect")] + pub line: Span, + pub feature: Symbol, + pub since: Symbol, + pub implies: Symbol, +} + +#[derive(LintDiagnostic)] +#[diag(passes_ineffective_unstable_impl)] +#[note] +pub struct IneffectiveUnstableImpl; + +#[derive(LintDiagnostic)] +#[diag(passes_unused_assign)] +#[help] +pub struct UnusedAssign { + pub name: String, +} + +#[derive(LintDiagnostic)] +#[diag(passes_unused_assign_passed)] +#[help] +pub struct UnusedAssignPassed { + pub name: String, +} + +#[derive(LintDiagnostic)] +#[diag(passes_unused_variable_try_prefix)] +pub struct UnusedVariableTryPrefix { + #[label] + pub label: Option<Span>, + #[subdiagnostic] + pub string_interp: Vec<UnusedVariableStringInterp>, + #[subdiagnostic] + pub sugg: UnusedVariableTryPrefixSugg, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(passes_suggestion, applicability = "machine-applicable")] +pub struct UnusedVariableTryPrefixSugg { + #[suggestion_part(code = "_{name}")] + pub spans: Vec<Span>, + pub name: String, +} + +pub struct UnusedVariableStringInterp { + pub lit: Span, + pub lo: Span, + pub hi: Span, +} + +impl AddToDiagnostic for UnusedVariableStringInterp { + fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F) { + diag.span_label(self.lit, crate::fluent_generated::passes_maybe_string_interpolation); + diag.multipart_suggestion( + crate::fluent_generated::passes_string_interpolation_only_works, + vec![(self.lo, String::from("format!(")), (self.hi, String::from(")"))], + Applicability::MachineApplicable, + ); + } +} + +#[derive(LintDiagnostic)] +#[diag(passes_unused_variable_try_ignore)] +pub struct UnusedVarTryIgnore { + #[subdiagnostic] + pub sugg: UnusedVarTryIgnoreSugg, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(passes_suggestion, applicability = "machine-applicable")] +pub struct UnusedVarTryIgnoreSugg { + #[suggestion_part(code = "{name}: _")] + pub shorthands: Vec<Span>, + #[suggestion_part(code = "_")] + pub non_shorthands: Vec<Span>, + pub name: String, +} + +#[derive(LintDiagnostic)] +#[diag(passes_attr_crate_level)] +#[note] +pub struct AttrCrateLevelOnly { + #[subdiagnostic] + pub sugg: Option<AttrCrateLevelOnlySugg>, +} + +#[derive(Subdiagnostic)] +#[suggestion(passes_suggestion, applicability = "maybe-incorrect", code = "!", style = "verbose")] +pub struct AttrCrateLevelOnlySugg { + #[primary_span] + pub attr: Span, +} |