1use rustc_errors::codes::*;
2use rustc_errors::{Diag, EmissionGuarantee, Subdiagnostic, msg};
3use rustc_macros::{Diagnostic, Subdiagnostic};
4use rustc_session::lint::Level;
5use rustc_span::{Span, Symbol};
6
7#[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,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$lint_level}({$lint_source}) incompatible with previous forbid")));
diag.code(E0453);
;
diag.arg("lint_level", __binding_2);
diag.arg("lint_source", __binding_3);
diag.span(__binding_0);
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("overruled by previous forbid")));
diag.subdiagnostic(__binding_4);
diag
}
}
}
}
};Diagnostic)]
8#[diag("{$lint_level}({$lint_source}) incompatible with previous forbid", code = E0453)]
9pub(crate) struct OverruledAttribute<'a> {
10 #[primary_span]
11 pub span: Span,
12 #[label("overruled by previous forbid")]
13 pub overruled: Span,
14 pub lint_level: &'a str,
15 pub lint_source: Symbol,
16 #[subdiagnostic]
17 pub sub: OverruledAttributeSub,
18}
19
20pub(crate) enum OverruledAttributeSub {
21 DefaultSource { id: String },
22 NodeSource { span: Span, reason: Option<Symbol> },
23 CommandLineSource { id: Symbol },
24}
25
26impl Subdiagnostic for OverruledAttributeSub {
27 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
28 match self {
29 OverruledAttributeSub::DefaultSource { id } => {
30 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`forbid` lint level is the default for {$id}"))msg!("`forbid` lint level is the default for {$id}"));
31 diag.arg("id", id);
32 }
33 OverruledAttributeSub::NodeSource { span, reason } => {
34 diag.span_label(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`forbid` level set here"))msg!("`forbid` level set here"));
35 if let Some(rationale) = reason {
36 diag.note(rationale.to_string());
37 }
38 }
39 OverruledAttributeSub::CommandLineSource { id } => {
40 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`forbid` lint level was set on command line (`-F {$id}`)"))msg!("`forbid` lint level was set on command line (`-F {$id}`)"));
41 diag.arg("id", id);
42 }
43 }
44 }
45}
46
47#[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,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`...` range patterns are deprecated")));
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,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `..=` for an inclusive range")),
__code_2, rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::HideCodeInline);
diag
}
}
}
}
};Diagnostic)]
48#[diag("`...` range patterns are deprecated", code = E0783)]
49pub(crate) struct BuiltinEllipsisInclusiveRangePatterns {
50 #[primary_span]
51 pub span: Span,
52 #[suggestion(
53 "use `..=` for an inclusive range",
54 style = "short",
55 code = "{replace}",
56 applicability = "machine-applicable"
57 )]
58 pub suggestion: Span,
59 pub replace: String,
60}
61
62#[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
} => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("level".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
sub_args.insert("lint_name".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("requested on the command line with `{$level} {$lint_name}`")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
63#[note("requested on the command line with `{$level} {$lint_name}`")]
64pub(crate) struct RequestedLevel<'a> {
65 pub level: Level,
66 pub lint_name: &'a str,
67}
68
69#[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,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$lint_group}` lint group is not supported with ´--force-warn´")));
diag.code(E0602);
;
diag.arg("lint_group", __binding_0);
diag
}
}
}
}
};Diagnostic)]
70#[diag("`{$lint_group}` lint group is not supported with ´--force-warn´", code = E0602)]
71pub(crate) struct UnsupportedGroup {
72 pub lint_group: String,
73}
74
75#[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,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown lint tool: `{$tool_name}`")));
diag.code(E0602);
;
diag.arg("tool_name", __binding_0);
diag.subdiagnostic(__binding_1);
diag
}
}
}
}
};Diagnostic)]
76#[diag("unknown lint tool: `{$tool_name}`", code = E0602)]
77pub(crate) struct CheckNameUnknownTool<'a> {
78 pub tool_name: Symbol,
79 #[subdiagnostic]
80 pub sub: RequestedLevel<'a>,
81}