1use std::num::{NonZero, ParseIntError};
2
3use rustc_ast::token;
4use rustc_ast::util::literal::LitError;
5use rustc_errors::codes::*;
6use rustc_errors::{
7 Diag, DiagCtxtHandle, DiagMessage, Diagnostic, EmissionGuarantee, ErrorGuaranteed, Level,
8 MultiSpan,
9};
10use rustc_macros::{Diagnostic, Subdiagnostic};
11use rustc_span::{Span, Symbol};
12use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTuple};
13
14use crate::parse::ParseSess;
15
16#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
AppleDeploymentTarget 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 {
AppleDeploymentTarget::Invalid {
env_var: __binding_0, error: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to parse deployment target specified in {$env_var}: {$error}")));
;
diag.arg("env_var", __binding_0);
diag.arg("error", __binding_1);
diag
}
AppleDeploymentTarget::TooLow {
env_var: __binding_0,
version: __binding_1,
os_min: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("deployment target in {$env_var} was set to {$version}, but the minimum supported by `rustc` is {$os_min}")));
;
diag.arg("env_var", __binding_0);
diag.arg("version", __binding_1);
diag.arg("os_min", __binding_2);
diag
}
}
}
}
};Diagnostic)]
17pub(crate) enum AppleDeploymentTarget {
18 #[diag("failed to parse deployment target specified in {$env_var}: {$error}")]
19 Invalid { env_var: &'static str, error: ParseIntError },
20 #[diag(
21 "deployment target in {$env_var} was set to {$version}, but the minimum supported by `rustc` is {$os_min}"
22 )]
23 TooLow { env_var: &'static str, version: String, os_min: String },
24}
25
26pub(crate) struct FeatureGateError {
27 pub(crate) span: MultiSpan,
28 pub(crate) explain: DiagMessage,
29}
30
31impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for FeatureGateError {
32 #[track_caller]
33 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
34 Diag::new(dcx, level, self.explain).with_span(self.span).with_code(E0658)
35 }
36}
37
38#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for FeatureDiagnosticForIssue {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
FeatureDiagnosticForIssue { n: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("n".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see issue #{$n} <https://github.com/rust-lang/rust/issues/{$n}> for more information")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
39#[note("see issue #{$n} <https://github.com/rust-lang/rust/issues/{$n}> for more information")]
40pub(crate) struct FeatureDiagnosticForIssue {
41 pub(crate) n: NonZero<u32>,
42}
43
44#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for SuggestUpgradeCompiler {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
SuggestUpgradeCompiler { date: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("date".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this compiler was built on {$date}; consider upgrading it if it is out of date")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
45#[note("this compiler was built on {$date}; consider upgrading it if it is out of date")]
46pub(crate) struct SuggestUpgradeCompiler {
47 date: &'static str,
48}
49
50impl SuggestUpgradeCompiler {
51 pub(crate) fn ui_testing() -> Self {
52 Self { date: "YYYY-MM-DD" }
53 }
54
55 pub(crate) fn new() -> Option<Self> {
56 let date = ::core::option::Option::Some("2026-04-16")option_env!("CFG_VER_DATE")?;
57
58 Some(Self { date })
59 }
60}
61
62#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for FeatureDiagnosticHelp {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
FeatureDiagnosticHelp { feature: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("feature".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#![feature({$feature})]` to the crate attributes to enable")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
63#[help("add `#![feature({$feature})]` to the crate attributes to enable")]
64pub(crate) struct FeatureDiagnosticHelp {
65 pub(crate) feature: Symbol,
66}
67
68#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for FeatureDiagnosticSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
FeatureDiagnosticSuggestion {
feature: __binding_0, span: __binding_1 } => {
let __code_0 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("#![feature({0})]\n",
__binding_0))
})].into_iter();
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("feature".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#![feature({$feature})]` to the crate attributes to enable")),
&sub_args);
diag.span_suggestions_with_style(__binding_1, __message,
__code_0, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
69#[suggestion(
70 "add `#![feature({$feature})]` to the crate attributes to enable",
71 applicability = "maybe-incorrect",
72 code = "#![feature({feature})]\n"
73)]
74pub(crate) struct FeatureDiagnosticSuggestion {
75 pub feature: Symbol,
76 #[primary_span]
77 pub span: Span,
78}
79
80#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for CliFeatureDiagnosticHelp {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
CliFeatureDiagnosticHelp { feature: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("feature".into(),
rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
&mut diag.long_ty_path));
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `-Zcrate-attr=\"feature({$feature})\"` to the command-line options to enable")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
81#[help("add `-Zcrate-attr=\"feature({$feature})\"` to the command-line options to enable")]
82pub(crate) struct CliFeatureDiagnosticHelp {
83 pub(crate) feature: Symbol,
84}
85
86#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
NotCircumventFeature 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 {
NotCircumventFeature => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zunleash-the-miri-inside-of-you` may not be used to circumvent feature gates, except when testing error paths in the CTFE engine")));
;
diag
}
}
}
}
};Diagnostic)]
87#[diag(
88 "`-Zunleash-the-miri-inside-of-you` may not be used to circumvent feature gates, except when testing error paths in the CTFE engine"
89)]
90pub(crate) struct NotCircumventFeature;
91
92#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
LinkerPluginToWindowsNotSupported 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 {
LinkerPluginToWindowsNotSupported => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("linker plugin based LTO is not supported together with `-C prefer-dynamic` when targeting Windows-like targets")));
;
diag
}
}
}
}
};Diagnostic)]
93#[diag(
94 "linker plugin based LTO is not supported together with `-C prefer-dynamic` when targeting Windows-like targets"
95)]
96pub(crate) struct LinkerPluginToWindowsNotSupported;
97
98#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
ProfileUseFileDoesNotExist<'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 {
ProfileUseFileDoesNotExist { path: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("file `{$path}` passed to `-C profile-use` does not exist")));
;
diag.arg("path", __binding_0);
diag
}
}
}
}
};Diagnostic)]
99#[diag("file `{$path}` passed to `-C profile-use` does not exist")]
100pub(crate) struct ProfileUseFileDoesNotExist<'a> {
101 pub(crate) path: &'a std::path::Path,
102}
103
104#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
ProfileSampleUseFileDoesNotExist<'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 {
ProfileSampleUseFileDoesNotExist { path: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("file `{$path}` passed to `-C profile-sample-use` does not exist")));
;
diag.arg("path", __binding_0);
diag
}
}
}
}
};Diagnostic)]
105#[diag("file `{$path}` passed to `-C profile-sample-use` does not exist")]
106pub(crate) struct ProfileSampleUseFileDoesNotExist<'a> {
107 pub(crate) path: &'a std::path::Path,
108}
109
110#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
TargetRequiresUnwindTables 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 {
TargetRequiresUnwindTables => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("target requires unwind tables, they cannot be disabled with `-C force-unwind-tables=no`")));
;
diag
}
}
}
}
};Diagnostic)]
111#[diag("target requires unwind tables, they cannot be disabled with `-C force-unwind-tables=no`")]
112pub(crate) struct TargetRequiresUnwindTables;
113
114#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InstrumentationNotSupported 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 {
InstrumentationNotSupported { us: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$us} instrumentation is not supported for this target")));
;
diag.arg("us", __binding_0);
diag
}
}
}
}
};Diagnostic)]
115#[diag("{$us} instrumentation is not supported for this target")]
116pub(crate) struct InstrumentationNotSupported {
117 pub(crate) us: String,
118}
119
120#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SanitizerNotSupported 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 {
SanitizerNotSupported { us: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$us} sanitizer is not supported for this target")));
;
diag.arg("us", __binding_0);
diag
}
}
}
}
};Diagnostic)]
121#[diag("{$us} sanitizer is not supported for this target")]
122pub(crate) struct SanitizerNotSupported {
123 pub(crate) us: String,
124}
125
126#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SanitizersNotSupported 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 {
SanitizersNotSupported { us: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$us} sanitizers are not supported for this target")));
;
diag.arg("us", __binding_0);
diag
}
}
}
}
};Diagnostic)]
127#[diag("{$us} sanitizers are not supported for this target")]
128pub(crate) struct SanitizersNotSupported {
129 pub(crate) us: String,
130}
131
132#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CannotMixAndMatchSanitizers 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 {
CannotMixAndMatchSanitizers {
first: __binding_0, second: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zsanitizer={$first}` is incompatible with `-Zsanitizer={$second}`")));
;
diag.arg("first", __binding_0);
diag.arg("second", __binding_1);
diag
}
}
}
}
};Diagnostic)]
133#[diag("`-Zsanitizer={$first}` is incompatible with `-Zsanitizer={$second}`")]
134pub(crate) struct CannotMixAndMatchSanitizers {
135 pub(crate) first: String,
136 pub(crate) second: String,
137}
138
139#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CannotEnableCrtStaticLinux 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 {
CannotEnableCrtStaticLinux => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("sanitizer is incompatible with statically linked libc, disable it using `-C target-feature=-crt-static`")));
;
diag
}
}
}
}
};Diagnostic)]
140#[diag(
141 "sanitizer is incompatible with statically linked libc, disable it using `-C target-feature=-crt-static`"
142)]
143pub(crate) struct CannotEnableCrtStaticLinux;
144
145#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SanitizerCfiRequiresLto 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 {
SanitizerCfiRequiresLto => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto`")));
;
diag
}
}
}
}
};Diagnostic)]
146#[diag("`-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto`")]
147pub(crate) struct SanitizerCfiRequiresLto;
148
149#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SanitizerCfiRequiresSingleCodegenUnit 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 {
SanitizerCfiRequiresSingleCodegenUnit => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zsanitizer=cfi` with `-Clto` requires `-Ccodegen-units=1`")));
;
diag
}
}
}
}
};Diagnostic)]
150#[diag("`-Zsanitizer=cfi` with `-Clto` requires `-Ccodegen-units=1`")]
151pub(crate) struct SanitizerCfiRequiresSingleCodegenUnit;
152
153#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SanitizerCfiCanonicalJumpTablesRequiresCfi 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 {
SanitizerCfiCanonicalJumpTablesRequiresCfi => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zsanitizer-cfi-canonical-jump-tables` requires `-Zsanitizer=cfi`")));
;
diag
}
}
}
}
};Diagnostic)]
154#[diag("`-Zsanitizer-cfi-canonical-jump-tables` requires `-Zsanitizer=cfi`")]
155pub(crate) struct SanitizerCfiCanonicalJumpTablesRequiresCfi;
156
157#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SanitizerCfiGeneralizePointersRequiresCfi 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 {
SanitizerCfiGeneralizePointersRequiresCfi => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zsanitizer-cfi-generalize-pointers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi`")));
;
diag
}
}
}
}
};Diagnostic)]
158#[diag("`-Zsanitizer-cfi-generalize-pointers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi`")]
159pub(crate) struct SanitizerCfiGeneralizePointersRequiresCfi;
160
161#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SanitizerCfiNormalizeIntegersRequiresCfi 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 {
SanitizerCfiNormalizeIntegersRequiresCfi => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zsanitizer-cfi-normalize-integers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi`")));
;
diag
}
}
}
}
};Diagnostic)]
162#[diag("`-Zsanitizer-cfi-normalize-integers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi`")]
163pub(crate) struct SanitizerCfiNormalizeIntegersRequiresCfi;
164
165#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SanitizerKcfiArityRequiresKcfi 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 {
SanitizerKcfiArityRequiresKcfi => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zsanitizer-kcfi-arity` requires `-Zsanitizer=kcfi`")));
;
diag
}
}
}
}
};Diagnostic)]
166#[diag("`-Zsanitizer-kcfi-arity` requires `-Zsanitizer=kcfi`")]
167pub(crate) struct SanitizerKcfiArityRequiresKcfi;
168
169#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SanitizerKcfiRequiresPanicAbort 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 {
SanitizerKcfiRequiresPanicAbort => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Z sanitizer=kcfi` requires `-C panic=abort`")));
;
diag
}
}
}
}
};Diagnostic)]
170#[diag("`-Z sanitizer=kcfi` requires `-C panic=abort`")]
171pub(crate) struct SanitizerKcfiRequiresPanicAbort;
172
173#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SplitLtoUnitRequiresLto 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 {
SplitLtoUnitRequiresLto => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zsplit-lto-unit` requires `-Clto`, `-Clto=thin`, or `-Clinker-plugin-lto`")));
;
diag
}
}
}
}
};Diagnostic)]
174#[diag("`-Zsplit-lto-unit` requires `-Clto`, `-Clto=thin`, or `-Clinker-plugin-lto`")]
175pub(crate) struct SplitLtoUnitRequiresLto;
176
177#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnstableVirtualFunctionElimination 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 {
UnstableVirtualFunctionElimination => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zvirtual-function-elimination` requires `-Clto`")));
;
diag
}
}
}
}
};Diagnostic)]
178#[diag("`-Zvirtual-function-elimination` requires `-Clto`")]
179pub(crate) struct UnstableVirtualFunctionElimination;
180
181#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsupportedDwarfVersion 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 {
UnsupportedDwarfVersion { dwarf_version: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("requested DWARF version {$dwarf_version} is not supported")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("supported DWARF versions are 2, 3, 4 and 5")));
;
diag.arg("dwarf_version", __binding_0);
diag
}
}
}
}
};Diagnostic)]
182#[diag("requested DWARF version {$dwarf_version} is not supported")]
183#[help("supported DWARF versions are 2, 3, 4 and 5")]
184pub(crate) struct UnsupportedDwarfVersion {
185 pub(crate) dwarf_version: u32,
186}
187
188#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
EmbedSourceInsufficientDwarfVersion 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 {
EmbedSourceInsufficientDwarfVersion {
dwarf_version: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zembed-source=y` requires at least `-Z dwarf-version=5` but DWARF version is {$dwarf_version}")));
;
diag.arg("dwarf_version", __binding_0);
diag
}
}
}
}
};Diagnostic)]
189#[diag(
190 "`-Zembed-source=y` requires at least `-Z dwarf-version=5` but DWARF version is {$dwarf_version}"
191)]
192pub(crate) struct EmbedSourceInsufficientDwarfVersion {
193 pub(crate) dwarf_version: u32,
194}
195
196#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
EmbedSourceRequiresDebugInfo 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 {
EmbedSourceRequiresDebugInfo => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zembed-source=y` requires debug information to be enabled")));
;
diag
}
}
}
}
};Diagnostic)]
197#[diag("`-Zembed-source=y` requires debug information to be enabled")]
198pub(crate) struct EmbedSourceRequiresDebugInfo;
199
200#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
StackProtectorNotSupportedForTarget<'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 {
StackProtectorNotSupportedForTarget {
stack_protector: __binding_0, target_triple: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Z stack-protector={$stack_protector}` is not supported for target {$target_triple} and will be ignored")));
;
diag.arg("stack_protector", __binding_0);
diag.arg("target_triple", __binding_1);
diag
}
}
}
}
};Diagnostic)]
201#[diag(
202 "`-Z stack-protector={$stack_protector}` is not supported for target {$target_triple} and will be ignored"
203)]
204pub(crate) struct StackProtectorNotSupportedForTarget<'a> {
205 pub(crate) stack_protector: StackProtector,
206 pub(crate) target_triple: &'a TargetTuple,
207}
208
209#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
SmallDataThresholdNotSupportedForTarget<'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 {
SmallDataThresholdNotSupportedForTarget {
target_triple: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Z small-data-threshold` is not supported for target {$target_triple} and will be ignored")));
;
diag.arg("target_triple", __binding_0);
diag
}
}
}
}
};Diagnostic)]
210#[diag(
211 "`-Z small-data-threshold` is not supported for target {$target_triple} and will be ignored"
212)]
213pub(crate) struct SmallDataThresholdNotSupportedForTarget<'a> {
214 pub(crate) target_triple: &'a TargetTuple,
215}
216
217#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BranchProtectionRequiresAArch64 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 {
BranchProtectionRequiresAArch64 => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zbranch-protection` is only supported on aarch64")));
;
diag
}
}
}
}
};Diagnostic)]
218#[diag("`-Zbranch-protection` is only supported on aarch64")]
219pub(crate) struct BranchProtectionRequiresAArch64;
220
221#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SplitDebugInfoUnstablePlatform 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 {
SplitDebugInfoUnstablePlatform { debuginfo: __binding_0 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Csplit-debuginfo={$debuginfo}` is unstable on this platform")));
;
diag.arg("debuginfo", __binding_0);
diag
}
}
}
}
};Diagnostic)]
222#[diag("`-Csplit-debuginfo={$debuginfo}` is unstable on this platform")]
223pub(crate) struct SplitDebugInfoUnstablePlatform {
224 pub(crate) debuginfo: SplitDebuginfo,
225}
226
227#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
FileIsNotWriteable<'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 {
FileIsNotWriteable { file: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("output file {$file} is not writeable -- check its permissions")));
;
diag.arg("file", __binding_0);
diag
}
}
}
}
};Diagnostic)]
228#[diag("output file {$file} is not writeable -- check its permissions")]
229pub(crate) struct FileIsNotWriteable<'a> {
230 pub(crate) file: &'a std::path::Path,
231}
232
233#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
FileWriteFail<'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 {
FileWriteFail { path: __binding_0, err: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to write `{$path}` due to error `{$err}`")));
;
diag.arg("path", __binding_0);
diag.arg("err", __binding_1);
diag
}
}
}
}
};Diagnostic)]
234#[diag("failed to write `{$path}` due to error `{$err}`")]
235pub(crate) struct FileWriteFail<'a> {
236 pub(crate) path: &'a std::path::Path,
237 pub(crate) err: String,
238}
239
240#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for CrateNameEmpty
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 {
CrateNameEmpty { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("crate name must not be empty")));
;
if let Some(__binding_0) = __binding_0 {
diag.span(__binding_0);
}
diag
}
}
}
}
};Diagnostic)]
241#[diag("crate name must not be empty")]
242pub(crate) struct CrateNameEmpty {
243 #[primary_span]
244 pub(crate) span: Option<Span>,
245}
246
247#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidCharacterInCrateName 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 {
InvalidCharacterInCrateName {
span: __binding_0,
character: __binding_1,
crate_name: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid character {$character} in crate name: `{$crate_name}`")));
;
diag.arg("character", __binding_1);
diag.arg("crate_name", __binding_2);
if let Some(__binding_0) = __binding_0 {
diag.span(__binding_0);
}
diag
}
}
}
}
};Diagnostic)]
248#[diag("invalid character {$character} in crate name: `{$crate_name}`")]
249pub(crate) struct InvalidCharacterInCrateName {
250 #[primary_span]
251 pub(crate) span: Option<Span>,
252 pub(crate) character: char,
253 pub(crate) crate_name: Symbol,
254}
255
256#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for ExprParenthesesNeeded {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
ExprParenthesesNeeded {
left: __binding_0, right: __binding_1 } => {
let mut suggestions = Vec::new();
let __code_1 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("("))
});
let __code_2 =
::alloc::__export::must_use({
::alloc::fmt::format(format_args!(")"))
});
suggestions.push((__binding_0, __code_1));
suggestions.push((__binding_1, __code_2));
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("parentheses are required to parse this as an expression")),
&sub_args);
diag.multipart_suggestion_with_style(__message, suggestions,
rustc_errors::Applicability::MachineApplicable,
rustc_errors::SuggestionStyle::ShowCode);
}
}
}
}
};Subdiagnostic)]
257#[multipart_suggestion(
258 "parentheses are required to parse this as an expression",
259 applicability = "machine-applicable"
260)]
261pub struct ExprParenthesesNeeded {
262 #[suggestion_part(code = "(")]
263 left: Span,
264 #[suggestion_part(code = ")")]
265 right: Span,
266}
267
268impl ExprParenthesesNeeded {
269 pub fn surrounding(s: Span) -> Self {
270 ExprParenthesesNeeded { left: s.shrink_to_lo(), right: s.shrink_to_hi() }
271 }
272}
273
274#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
SkippingConstChecks 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 {
SkippingConstChecks { unleashed_features: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("skipping const checks")));
;
for __binding_0 in __binding_0 {
diag.subdiagnostic(__binding_0);
}
diag
}
}
}
}
};Diagnostic)]
275#[diag("skipping const checks")]
276pub(crate) struct SkippingConstChecks {
277 #[subdiagnostic]
278 pub(crate) unleashed_features: Vec<UnleashedFeatureHelp>,
279}
280
281#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for UnleashedFeatureHelp {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
UnleashedFeatureHelp::Named {
span: __binding_0, gate: __binding_1 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("gate".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("skipping check for `{$gate}` feature")),
&sub_args);
diag.span_help(__binding_0, __message);
}
UnleashedFeatureHelp::Unnamed { span: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
let __message =
rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("skipping check that does not even have a feature gate")),
&sub_args);
diag.span_help(__binding_0, __message);
}
}
}
}
};Subdiagnostic)]
282pub(crate) enum UnleashedFeatureHelp {
283 #[help("skipping check for `{$gate}` feature")]
284 Named {
285 #[primary_span]
286 span: Span,
287 gate: Symbol,
288 },
289 #[help("skipping check that does not even have a feature gate")]
290 Unnamed {
291 #[primary_span]
292 span: Span,
293 },
294}
295
296#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidLiteralSuffix<'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 {
InvalidLiteralSuffix {
span: __binding_0, kind: __binding_1, suffix: __binding_2 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("suffixes on {$kind} literals are invalid")));
;
diag.arg("kind", __binding_1);
diag.arg("suffix", __binding_2);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid suffix `{$suffix}`")));
diag
}
}
}
}
};Diagnostic)]
297#[diag("suffixes on {$kind} literals are invalid")]
298struct InvalidLiteralSuffix<'a> {
299 #[primary_span]
300 #[label("invalid suffix `{$suffix}`")]
301 span: Span,
302 kind: &'a str,
304 suffix: Symbol,
305}
306
307#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidIntLiteralWidth 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 {
InvalidIntLiteralWidth {
span: __binding_0, width: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid width `{$width}` for integer literal")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("valid widths are 8, 16, 32, 64 and 128")));
;
diag.arg("width", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
308#[diag("invalid width `{$width}` for integer literal")]
309#[help("valid widths are 8, 16, 32, 64 and 128")]
310struct InvalidIntLiteralWidth {
311 #[primary_span]
312 span: Span,
313 width: String,
314}
315
316#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidNumLiteralBasePrefix 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 {
InvalidNumLiteralBasePrefix {
span: __binding_0, fixed: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid base prefix for number literal")));
let __code_3 =
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", __binding_1))
})].into_iter();
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase")));
;
diag.arg("fixed", __binding_1);
diag.span(__binding_0);
diag.span_suggestions_with_style(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try making the prefix lowercase")),
__code_3, rustc_errors::Applicability::MaybeIncorrect,
rustc_errors::SuggestionStyle::ShowCode);
diag
}
}
}
}
};Diagnostic)]
317#[diag("invalid base prefix for number literal")]
318#[note("base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase")]
319struct InvalidNumLiteralBasePrefix {
320 #[primary_span]
321 #[suggestion(
322 "try making the prefix lowercase",
323 applicability = "maybe-incorrect",
324 code = "{fixed}"
325 )]
326 span: Span,
327 fixed: String,
328}
329
330#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidNumLiteralSuffix 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 {
InvalidNumLiteralSuffix {
span: __binding_0, suffix: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid suffix `{$suffix}` for number literal")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)")));
;
diag.arg("suffix", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid suffix `{$suffix}`")));
diag
}
}
}
}
};Diagnostic)]
331#[diag("invalid suffix `{$suffix}` for number literal")]
332#[help("the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)")]
333struct InvalidNumLiteralSuffix {
334 #[primary_span]
335 #[label("invalid suffix `{$suffix}`")]
336 span: Span,
337 suffix: String,
338}
339
340#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidFloatLiteralWidth 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 {
InvalidFloatLiteralWidth {
span: __binding_0, width: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid width `{$width}` for float literal")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("valid widths are 32 and 64")));
;
diag.arg("width", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
341#[diag("invalid width `{$width}` for float literal")]
342#[help("valid widths are 32 and 64")]
343struct InvalidFloatLiteralWidth {
344 #[primary_span]
345 span: Span,
346 width: String,
347}
348
349#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
InvalidFloatLiteralSuffix 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 {
InvalidFloatLiteralSuffix {
span: __binding_0, suffix: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid suffix `{$suffix}` for float literal")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("valid suffixes are `f32` and `f64`")));
;
diag.arg("suffix", __binding_1);
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid suffix `{$suffix}`")));
diag
}
}
}
}
};Diagnostic)]
350#[diag("invalid suffix `{$suffix}` for float literal")]
351#[help("valid suffixes are `f32` and `f64`")]
352struct InvalidFloatLiteralSuffix {
353 #[primary_span]
354 #[label("invalid suffix `{$suffix}`")]
355 span: Span,
356 suffix: String,
357}
358
359#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IntLiteralTooLarge 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 {
IntLiteralTooLarge { span: __binding_0, limit: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("integer literal is too large")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("value exceeds limit of `{$limit}`")));
;
diag.arg("limit", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
360#[diag("integer literal is too large")]
361#[note("value exceeds limit of `{$limit}`")]
362struct IntLiteralTooLarge {
363 #[primary_span]
364 span: Span,
365 limit: String,
366}
367
368#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
HexadecimalFloatLiteralNotSupported 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 {
HexadecimalFloatLiteralNotSupported { span: __binding_0 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("hexadecimal float literal is not supported")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not supported")));
diag
}
}
}
}
};Diagnostic)]
369#[diag("hexadecimal float literal is not supported")]
370struct HexadecimalFloatLiteralNotSupported {
371 #[primary_span]
372 #[label("not supported")]
373 span: Span,
374}
375
376#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
OctalFloatLiteralNotSupported 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 {
OctalFloatLiteralNotSupported { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("octal float literal is not supported")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not supported")));
diag
}
}
}
}
};Diagnostic)]
377#[diag("octal float literal is not supported")]
378struct OctalFloatLiteralNotSupported {
379 #[primary_span]
380 #[label("not supported")]
381 span: Span,
382}
383
384#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
BinaryFloatLiteralNotSupported 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 {
BinaryFloatLiteralNotSupported { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("binary float literal is not supported")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not supported")));
diag
}
}
}
}
};Diagnostic)]
385#[diag("binary float literal is not supported")]
386struct BinaryFloatLiteralNotSupported {
387 #[primary_span]
388 #[label("not supported")]
389 span: Span,
390}
391
392pub fn report_lit_error(
393 psess: &ParseSess,
394 err: LitError,
395 lit: token::Lit,
396 span: Span,
397) -> ErrorGuaranteed {
398 create_lit_error(psess, err, lit, span).emit()
399}
400
401pub fn create_lit_error(psess: &ParseSess, err: LitError, lit: token::Lit, span: Span) -> Diag<'_> {
402 fn looks_like_width_suffix(first_chars: &[char], s: &str) -> bool {
404 s.len() > 1 && s.starts_with(first_chars) && s[1..].chars().all(|c| c.is_ascii_digit())
405 }
406
407 fn fix_base_capitalisation(prefix: &str, suffix: &str) -> Option<String> {
409 let mut chars = suffix.chars();
410
411 let base_char = chars.next().unwrap();
412 let base = match base_char {
413 'B' => 2,
414 'O' => 8,
415 'X' => 16,
416 _ => return None,
417 };
418
419 let valid = prefix == "0"
421 && chars
422 .filter(|c| *c != '_')
423 .take_while(|c| *c != 'i' && *c != 'u')
424 .all(|c| c.to_digit(base).is_some());
425
426 valid.then(|| ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("0{0}{1}",
base_char.to_ascii_lowercase(), &suffix[1..]))
})format!("0{}{}", base_char.to_ascii_lowercase(), &suffix[1..]))
427 }
428
429 let dcx = psess.dcx();
430 match err {
431 LitError::InvalidSuffix(suffix) => {
432 dcx.create_err(InvalidLiteralSuffix { span, kind: lit.kind.descr(), suffix })
433 }
434 LitError::InvalidIntSuffix(suffix) => {
435 let suf = suffix.as_str();
436 if looks_like_width_suffix(&['i', 'u'], suf) {
437 dcx.create_err(InvalidIntLiteralWidth { span, width: suf[1..].into() })
439 } else if let Some(fixed) = fix_base_capitalisation(lit.symbol.as_str(), suf) {
440 dcx.create_err(InvalidNumLiteralBasePrefix { span, fixed })
441 } else {
442 dcx.create_err(InvalidNumLiteralSuffix { span, suffix: suf.to_string() })
443 }
444 }
445 LitError::InvalidFloatSuffix(suffix) => {
446 let suf = suffix.as_str();
447 if looks_like_width_suffix(&['f'], suf) {
448 dcx.create_err(InvalidFloatLiteralWidth { span, width: suf[1..].to_string() })
450 } else {
451 dcx.create_err(InvalidFloatLiteralSuffix { span, suffix: suf.to_string() })
452 }
453 }
454 LitError::NonDecimalFloat(base) => match base {
455 16 => dcx.create_err(HexadecimalFloatLiteralNotSupported { span }),
456 8 => dcx.create_err(OctalFloatLiteralNotSupported { span }),
457 2 => dcx.create_err(BinaryFloatLiteralNotSupported { span }),
458 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
459 },
460 LitError::IntTooLarge(base) => {
461 let max = u128::MAX;
462 let limit = match base {
463 2 => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#b}", max))
})format!("{max:#b}"),
464 8 => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#o}", max))
})format!("{max:#o}"),
465 16 => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#x}", max))
})format!("{max:#x}"),
466 _ => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", max))
})format!("{max}"),
467 };
468 dcx.create_err(IntLiteralTooLarge { span, limit })
469 }
470 }
471}
472
473#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IncompatibleLinkerFlavor 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 {
IncompatibleLinkerFlavor {
flavor: __binding_0, compatible_list: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("linker flavor `{$flavor}` is incompatible with the current target")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("compatible flavors are: {$compatible_list}")));
;
diag.arg("flavor", __binding_0);
diag.arg("compatible_list", __binding_1);
diag
}
}
}
}
};Diagnostic)]
474#[diag("linker flavor `{$flavor}` is incompatible with the current target")]
475#[note("compatible flavors are: {$compatible_list}")]
476pub(crate) struct IncompatibleLinkerFlavor {
477 pub(crate) flavor: &'static str,
478 pub(crate) compatible_list: String,
479}
480
481#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FunctionReturnRequiresX86OrX8664 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 {
FunctionReturnRequiresX86OrX8664 => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zfunction-return` (except `keep`) is only supported on x86 and x86_64")));
;
diag
}
}
}
}
};Diagnostic)]
482#[diag("`-Zfunction-return` (except `keep`) is only supported on x86 and x86_64")]
483pub(crate) struct FunctionReturnRequiresX86OrX8664;
484
485#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FunctionReturnThunkExternRequiresNonLargeCodeModel 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 {
FunctionReturnThunkExternRequiresNonLargeCodeModel => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zfunction-return=thunk-extern` is only supported on non-large code models")));
;
diag
}
}
}
}
};Diagnostic)]
486#[diag("`-Zfunction-return=thunk-extern` is only supported on non-large code models")]
487pub(crate) struct FunctionReturnThunkExternRequiresNonLargeCodeModel;
488
489#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
IndirectBranchCsPrefixRequiresX86OrX8664 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 {
IndirectBranchCsPrefixRequiresX86OrX8664 => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zindirect-branch-cs-prefix` is only supported on x86 and x86_64")));
;
diag
}
}
}
}
};Diagnostic)]
490#[diag("`-Zindirect-branch-cs-prefix` is only supported on x86 and x86_64")]
491pub(crate) struct IndirectBranchCsPrefixRequiresX86OrX8664;
492
493#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsupportedRegparm 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 {
UnsupportedRegparm { regparm: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zregparm={$regparm}` is unsupported (valid values 0-3)")));
;
diag.arg("regparm", __binding_0);
diag
}
}
}
}
};Diagnostic)]
494#[diag("`-Zregparm={$regparm}` is unsupported (valid values 0-3)")]
495pub(crate) struct UnsupportedRegparm {
496 pub(crate) regparm: u32,
497}
498
499#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsupportedRegparmArch 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 {
UnsupportedRegparmArch => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zregparm=N` is only supported on x86")));
;
diag
}
}
}
}
};Diagnostic)]
500#[diag("`-Zregparm=N` is only supported on x86")]
501pub(crate) struct UnsupportedRegparmArch;
502
503#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsupportedRegStructReturnArch 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 {
UnsupportedRegStructReturnArch => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zreg-struct-return` is only supported on x86")));
;
diag
}
}
}
}
};Diagnostic)]
504#[diag("`-Zreg-struct-return` is only supported on x86")]
505pub(crate) struct UnsupportedRegStructReturnArch;
506
507#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
FailedToCreateProfiler 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 {
FailedToCreateProfiler { err: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to create profiler: {$err}")));
;
diag.arg("err", __binding_0);
diag
}
}
}
}
};Diagnostic)]
508#[diag("failed to create profiler: {$err}")]
509pub(crate) struct FailedToCreateProfiler {
510 pub(crate) err: String,
511}
512
513#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnexpectedBuiltinCfg 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 {
UnexpectedBuiltinCfg {
cfg: __binding_0,
cfg_name: __binding_1,
controlled_by: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `--cfg {$cfg}` flag")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("config `{$cfg_name}` is only supposed to be controlled by `{$controlled_by}`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("manually setting a built-in cfg can and does create incoherent behaviors")));
;
diag.arg("cfg", __binding_0);
diag.arg("cfg_name", __binding_1);
diag.arg("controlled_by", __binding_2);
diag
}
}
}
}
};Diagnostic)]
514#[diag("unexpected `--cfg {$cfg}` flag")]
515#[note("config `{$cfg_name}` is only supposed to be controlled by `{$controlled_by}`")]
516#[note("manually setting a built-in cfg can and does create incoherent behaviors")]
517pub(crate) struct UnexpectedBuiltinCfg {
518 pub(crate) cfg: String,
519 pub(crate) cfg_name: Symbol,
520 pub(crate) controlled_by: &'static str,
521}
522
523#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
ThinLtoNotSupportedByBackend 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 {
ThinLtoNotSupportedByBackend => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ThinLTO is not supported by the codegen backend, using fat LTO instead")));
;
diag
}
}
}
}
};Diagnostic)]
524#[diag("ThinLTO is not supported by the codegen backend, using fat LTO instead")]
525pub(crate) struct ThinLtoNotSupportedByBackend;
526
527#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
UnsupportedPackedStack 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 {
UnsupportedPackedStack => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zpacked-stack` is only supported on s390x")));
;
diag
}
}
}
}
};Diagnostic)]
528#[diag("`-Zpacked-stack` is only supported on s390x")]
529pub(crate) struct UnsupportedPackedStack;