1use rustc_errors::codes::*;
2use rustc_errors::{Diag, EmissionGuarantee, Subdiagnostic};
3use rustc_macros::{Diagnostic, Subdiagnostic};
4use rustc_session::lint::Level;
5use rustc_span::{Span, Symbol};
6
7use crate::fluent_generated as fluent;
8
9#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
OverruledAttribute<'a> where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
OverruledAttribute {
span: __binding_0,
overruled: __binding_1,
lint_level: __binding_2,
lint_source: __binding_3,
sub: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::lint_overruled_attribute);
diag.code(E0453);
;
diag.arg("lint_level", __binding_2);
diag.arg("lint_source", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_1,
crate::fluent_generated::_subdiag::label);
diag.subdiagnostic(__binding_4);
diag
}
}
}
}
};Diagnostic)]
10#[diag(lint_overruled_attribute, code = E0453)]
11pub(crate) struct OverruledAttribute<'a> {
12 #[primary_span]
13 pub span: Span,
14 #[label]
15 pub overruled: Span,
16 pub lint_level: &'a str,
17 pub lint_source: Symbol,
18 #[subdiagnostic]
19 pub sub: OverruledAttributeSub,
20}
21
22pub(crate) enum OverruledAttributeSub {
23 DefaultSource { id: String },
24 NodeSource { span: Span, reason: Option<Symbol> },
25 CommandLineSource,
26}
27
28impl Subdiagnostic for OverruledAttributeSub {
29 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
30 match self {
31 OverruledAttributeSub::DefaultSource { id } => {
32 diag.note(fluent::lint_default_source);
33 diag.arg("id", id);
34 }
35 OverruledAttributeSub::NodeSource { span, reason } => {
36 diag.span_label(span, fluent::lint_node_source);
37 if let Some(rationale) = reason {
38 #[allow(rustc::untranslatable_diagnostic)]
39 diag.note(rationale.to_string());
40 }
41 }
42 OverruledAttributeSub::CommandLineSource => {
43 diag.note(fluent::lint_command_line_source);
44 }
45 }
46 }
47}
48
49#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
MalformedAttribute where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
MalformedAttribute { span: __binding_0, sub: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::lint_malformed_attribute);
diag.code(E0452);
;
diag.span(__binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
50#[diag(lint_malformed_attribute, code = E0452)]
51pub(crate) struct MalformedAttribute {
52 #[primary_span]
53 pub span: Span,
54 #[subdiagnostic]
55 pub sub: MalformedAttributeSub,
56}
57
58#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for MalformedAttributeSub {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
MalformedAttributeSub::BadAttributeArgument(__binding_0) =>
{
diag.store_args();
let __message =
diag.eagerly_translate(crate::fluent_generated::lint_bad_attribute_argument);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
MalformedAttributeSub::ReasonMustBeStringLiteral(__binding_0)
=> {
diag.store_args();
let __message =
diag.eagerly_translate(crate::fluent_generated::lint_reason_must_be_string_literal);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
MalformedAttributeSub::ReasonMustComeLast(__binding_0) => {
diag.store_args();
let __message =
diag.eagerly_translate(crate::fluent_generated::lint_reason_must_come_last);
diag.span_label(__binding_0, __message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
59pub(crate) enum MalformedAttributeSub {
60 #[label(lint_bad_attribute_argument)]
61 BadAttributeArgument(#[primary_span] Span),
62 #[label(lint_reason_must_be_string_literal)]
63 ReasonMustBeStringLiteral(#[primary_span] Span),
64 #[label(lint_reason_must_come_last)]
65 ReasonMustComeLast(#[primary_span] Span),
66}
67
68#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnknownToolInScopedLint where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnknownToolInScopedLint {
span: __binding_0,
tool_name: __binding_1,
lint_name: __binding_2,
is_nightly_build: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::lint_unknown_tool_in_scoped_lint);
diag.code(E0710);
;
diag.arg("tool_name", __binding_1);
diag.arg("lint_name", __binding_2);
if let Some(__binding_0) = __binding_0 {
diag.span(__binding_0);
}
if __binding_3 {
diag.help(crate::fluent_generated::_subdiag::help);
}
diag
}
}
}
}
};Diagnostic)]
69#[diag(lint_unknown_tool_in_scoped_lint, code = E0710)]
70pub(crate) struct UnknownToolInScopedLint {
71 #[primary_span]
72 pub span: Option<Span>,
73 pub tool_name: Symbol,
74 pub lint_name: String,
75 #[help]
76 pub is_nightly_build: bool,
77}
78
79#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BuiltinEllipsisInclusiveRangePatterns where
G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
BuiltinEllipsisInclusiveRangePatterns {
span: __binding_0,
suggestion: __binding_1,
replace: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::lint_builtin_ellipsis_inclusive_range_patterns);
let __code_2 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_2))
})].into_iter();
diag.code(E0783);
;
diag.arg("replace", __binding_2);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_1,
crate::fluent_generated::_subdiag::suggestion, __code_2,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeInline);
diag
}
}
}
}
};Diagnostic)]
80#[diag(lint_builtin_ellipsis_inclusive_range_patterns, code = E0783)]
81pub(crate) struct BuiltinEllipsisInclusiveRangePatterns {
82 #[primary_span]
83 pub span: Span,
84 #[suggestion(style = "short", code = "{replace}", applicability = "machine-applicable")]
85 pub suggestion: Span,
86 pub replace: String,
87}
88
89#[derive(const _: () =
{
impl<'a> rustc_errors::Subdiagnostic for RequestedLevel<'a> {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
RequestedLevel { level: __binding_0, lint_name: __binding_1
} => {
diag.store_args();
diag.arg("level", __binding_0);
diag.arg("lint_name", __binding_1);
let __message =
diag.eagerly_translate(crate::fluent_generated::lint_requested_level);
diag.note(__message);
diag.restore_args();
}
}
}
}
};Subdiagnostic)]
90#[note(lint_requested_level)]
91pub(crate) struct RequestedLevel<'a> {
92 pub level: Level,
93 pub lint_name: &'a str,
94}
95
96#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsupportedGroup where G: rustc_errors::EmissionGuarantee {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
UnsupportedGroup { lint_group: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::lint_unsupported_group);
diag.code(E0602);
;
diag.arg("lint_group", __binding_0);
diag
}
}
}
}
};Diagnostic)]
97#[diag(lint_unsupported_group, code = E0602)]
98pub(crate) struct UnsupportedGroup {
99 pub lint_group: String,
100}
101
102#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
CheckNameUnknownTool<'a> where G: rustc_errors::EmissionGuarantee
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
match self {
CheckNameUnknownTool {
tool_name: __binding_0, sub: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
crate::fluent_generated::lint_check_name_unknown_tool);
diag.code(E0602);
;
diag.arg("tool_name", __binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
103#[diag(lint_check_name_unknown_tool, code = E0602)]
104pub(crate) struct CheckNameUnknownTool<'a> {
105 pub tool_name: Symbol,
106 #[subdiagnostic]
107 pub sub: RequestedLevel<'a>,
108}