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, StashKey,
9};
10use rustc_feature::{GateIssue, find_feature_issue};
11use rustc_macros::{Diagnostic, Subdiagnostic};
12use rustc_span::{Span, Symbol, sym};
13use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTuple};
14
15use crate::Session;
16use crate::lint::builtin::UNSTABLE_SYNTAX_PRE_EXPANSION;
17use crate::parse::ParseSess;
18
19#[track_caller]
22pub fn feature_err(
23 sess: &Session,
24 feature: Symbol,
25 span: impl Into<MultiSpan>,
26 explain: impl Into<DiagMessage>,
27) -> Diag<'_> {
28 feature_err_issue(sess, feature, span, GateIssue::Language, explain)
29}
30
31#[track_caller]
36pub fn feature_err_issue(
37 sess: &Session,
38 feature: Symbol,
39 span: impl Into<MultiSpan>,
40 issue: GateIssue,
41 explain: impl Into<DiagMessage>,
42) -> Diag<'_> {
43 let span = span.into();
44
45 if let Some(span) = span.primary_span()
47 && let Some(err) = sess.dcx().steal_non_err(span, StashKey::EarlySyntaxWarning)
48 {
49 err.cancel()
50 }
51
52 let mut err = sess.dcx().create_err(FeatureGateError { span, explain: explain.into() });
53 add_feature_diagnostics_for_issue(&mut err, sess, feature, issue, false, None);
54 err
55}
56
57#[track_caller]
61pub fn feature_warn(sess: &Session, feature: Symbol, span: Span, explain: &'static str) {
62 feature_warn_issue(sess, feature, span, GateIssue::Language, explain);
63}
64
65#[track_caller]
72pub fn feature_warn_issue(
73 sess: &Session,
74 feature: Symbol,
75 span: Span,
76 issue: GateIssue,
77 explain: &'static str,
78) {
79 let mut err = sess.dcx().struct_span_warn(span, explain);
80 add_feature_diagnostics_for_issue(&mut err, sess, feature, issue, false, None);
81
82 let lint = UNSTABLE_SYNTAX_PRE_EXPANSION;
84 let future_incompatible = lint.future_incompatible.as_ref().unwrap();
85 err.is_lint(
86 lint.name_lower(),
87 false,
88 None,
89 );
90 err.warn(lint.desc);
91 err.note(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("for more information, see {0}",
future_incompatible.reason.reference()))
})format!("for more information, see {}", future_incompatible.reason.reference()));
92
93 err.stash(span, StashKey::EarlySyntaxWarning);
95}
96
97pub fn add_feature_diagnostics<G: EmissionGuarantee>(
100 err: &mut Diag<'_, G>,
101 sess: &Session,
102 feature: Symbol,
103) {
104 add_feature_diagnostics_for_issue(err, sess, feature, GateIssue::Language, false, None);
105}
106
107pub fn add_feature_diagnostics_for_issue<G: EmissionGuarantee>(
113 err: &mut Diag<'_, G>,
114 sess: &Session,
115 feature: Symbol,
116 issue: GateIssue,
117 feature_from_cli: bool,
118 inject_span: Option<Span>,
119) {
120 if let Some(n) = find_feature_issue(feature, issue) {
121 err.subdiagnostic(FeatureDiagnosticForIssue { n });
122 }
123
124 if sess.unstable_features.is_nightly_build() {
126 if feature_from_cli {
127 err.subdiagnostic(CliFeatureDiagnosticHelp { feature });
128 } else if let Some(span) = inject_span {
129 err.subdiagnostic(FeatureDiagnosticSuggestion { feature, span });
130 } else {
131 err.subdiagnostic(FeatureDiagnosticHelp { feature });
132 }
133 if feature == sym::rustc_attrs {
134 } else if sess.opts.unstable_opts.ui_testing {
138 err.subdiagnostic(SuggestUpgradeCompiler::ui_testing());
139 } else if let Some(suggestion) = SuggestUpgradeCompiler::new() {
140 err.subdiagnostic(suggestion);
141 }
142 }
143}
144
145#[track_caller]
151pub fn feature_err_unstable_feature_bound(
152 sess: &Session,
153 feature: Symbol,
154 span: impl Into<MultiSpan>,
155 explain: impl Into<DiagMessage>,
156) -> Diag<'_> {
157 let span = span.into();
158
159 if let Some(span) = span.primary_span() {
161 if let Some(err) = sess.dcx().steal_non_err(span, StashKey::EarlySyntaxWarning) {
162 err.cancel()
163 }
164 }
165
166 let mut err = sess.dcx().create_err(FeatureGateError { span, explain: explain.into() });
167
168 if sess.unstable_features.is_nightly_build() {
170 err.subdiagnostic(FeatureDiagnosticHelp { feature });
171
172 if feature == sym::rustc_attrs {
173 } else if sess.opts.unstable_opts.ui_testing {
177 err.subdiagnostic(SuggestUpgradeCompiler::ui_testing());
178 } else if let Some(suggestion) = SuggestUpgradeCompiler::new() {
179 err.subdiagnostic(suggestion);
180 }
181 }
182 err
183}
184
185#[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)]
186pub(crate) enum AppleDeploymentTarget {
187 #[diag("failed to parse deployment target specified in {$env_var}: {$error}")]
188 Invalid { env_var: &'static str, error: ParseIntError },
189 #[diag(
190 "deployment target in {$env_var} was set to {$version}, but the minimum supported by `rustc` is {$os_min}"
191 )]
192 TooLow { env_var: &'static str, version: String, os_min: String },
193}
194
195pub(crate) struct FeatureGateError {
196 pub(crate) span: MultiSpan,
197 pub(crate) explain: DiagMessage,
198}
199
200impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for FeatureGateError {
201 #[track_caller]
202 fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
203 Diag::new(dcx, level, self.explain).with_span(self.span).with_code(E0658)
204 }
205}
206
207#[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)]
208#[note("see issue #{$n} <https://github.com/rust-lang/rust/issues/{$n}> for more information")]
209pub(crate) struct FeatureDiagnosticForIssue {
210 pub(crate) n: NonZero<u32>,
211}
212
213#[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)]
214#[note("this compiler was built on {$date}; consider upgrading it if it is out of date")]
215pub(crate) struct SuggestUpgradeCompiler {
216 date: &'static str,
217}
218
219impl SuggestUpgradeCompiler {
220 pub(crate) fn ui_testing() -> Self {
221 Self { date: "YYYY-MM-DD" }
222 }
223
224 pub(crate) fn new() -> Option<Self> {
225 let date = ::core::option::Option::Some("2026-07-06")option_env!("CFG_VER_DATE")?;
226
227 Some(Self { date })
228 }
229}
230
231#[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)]
232#[help("add `#![feature({$feature})]` to the crate attributes to enable")]
233pub(crate) struct FeatureDiagnosticHelp {
234 pub(crate) feature: Symbol,
235}
236
237#[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)]
238#[suggestion(
239 "add `#![feature({$feature})]` to the crate attributes to enable",
240 applicability = "maybe-incorrect",
241 code = "#![feature({feature})]\n"
242)]
243pub(crate) struct FeatureDiagnosticSuggestion {
244 pub feature: Symbol,
245 #[primary_span]
246 pub span: Span,
247}
248
249#[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)]
250#[help("add `-Zcrate-attr=\"feature({$feature})\"` to the command-line options to enable")]
251pub(crate) struct CliFeatureDiagnosticHelp {
252 pub(crate) feature: Symbol,
253}
254
255#[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)]
256#[diag(
257 "`-Zunleash-the-miri-inside-of-you` may not be used to circumvent feature gates, except when testing error paths in the CTFE engine"
258)]
259pub(crate) struct NotCircumventFeature;
260
261#[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)]
262#[diag(
263 "linker plugin based LTO is not supported together with `-C prefer-dynamic` when targeting Windows-like targets"
264)]
265pub(crate) struct LinkerPluginToWindowsNotSupported;
266
267#[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)]
268#[diag("file `{$path}` passed to `-C profile-use` does not exist")]
269pub(crate) struct ProfileUseFileDoesNotExist<'a> {
270 pub(crate) path: &'a std::path::Path,
271}
272
273#[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)]
274#[diag("file `{$path}` passed to `-C profile-sample-use` does not exist")]
275pub(crate) struct ProfileSampleUseFileDoesNotExist<'a> {
276 pub(crate) path: &'a std::path::Path,
277}
278
279#[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)]
280#[diag("target requires unwind tables, they cannot be disabled with `-C force-unwind-tables=no`")]
281pub(crate) struct TargetRequiresUnwindTables;
282
283#[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)]
284#[diag("{$us} instrumentation is not supported for this target")]
285pub(crate) struct InstrumentationNotSupported {
286 pub(crate) us: String,
287}
288
289#[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)]
290#[diag("{$us} sanitizer is not supported for this target")]
291pub(crate) struct SanitizerNotSupported {
292 pub(crate) us: String,
293}
294
295#[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)]
296#[diag("{$us} sanitizers are not supported for this target")]
297pub(crate) struct SanitizersNotSupported {
298 pub(crate) us: String,
299}
300
301#[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)]
302#[diag("`-Zsanitizer={$first}` is incompatible with `-Zsanitizer={$second}`")]
303pub(crate) struct CannotMixAndMatchSanitizers {
304 pub(crate) first: String,
305 pub(crate) second: String,
306}
307
308#[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)]
309#[diag(
310 "sanitizer is incompatible with statically linked libc, disable it using `-C target-feature=-crt-static`"
311)]
312pub(crate) struct CannotEnableCrtStaticLinux;
313
314#[derive(const _: () =
{
impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
CannotEnableCrtStaticPointerAuth 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 {
CannotEnableCrtStaticPointerAuth => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("pointer authentication requires dynamic linking. Statically linked libc is incompatible, disable it using `-C target-feature=-crt-static`")));
;
diag
}
}
}
}
};Diagnostic)]
315#[diag(
316 "pointer authentication requires dynamic linking. Statically linked libc is incompatible, disable it using `-C target-feature=-crt-static`"
317)]
318pub(crate) struct CannotEnableCrtStaticPointerAuth;
319
320#[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)]
321#[diag("`-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto`")]
322pub(crate) struct SanitizerCfiRequiresLto;
323
324#[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)]
325#[diag("`-Zsanitizer=cfi` with `-Clto` requires `-Ccodegen-units=1`")]
326pub(crate) struct SanitizerCfiRequiresSingleCodegenUnit;
327
328#[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)]
329#[diag("`-Zsanitizer-cfi-canonical-jump-tables` requires `-Zsanitizer=cfi`")]
330pub(crate) struct SanitizerCfiCanonicalJumpTablesRequiresCfi;
331
332#[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)]
333#[diag("`-Zsanitizer-cfi-generalize-pointers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi`")]
334pub(crate) struct SanitizerCfiGeneralizePointersRequiresCfi;
335
336#[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)]
337#[diag("`-Zsanitizer-cfi-normalize-integers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi`")]
338pub(crate) struct SanitizerCfiNormalizeIntegersRequiresCfi;
339
340#[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)]
341#[diag("`-Zsanitizer-kcfi-arity` requires `-Zsanitizer=kcfi`")]
342pub(crate) struct SanitizerKcfiArityRequiresKcfi;
343
344#[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)]
345#[diag("`-Z sanitizer=kcfi` requires `-C panic=abort`")]
346pub(crate) struct SanitizerKcfiRequiresPanicAbort;
347
348#[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)]
349#[diag("`-Zsplit-lto-unit` requires `-Clto`, `-Clto=thin`, or `-Clinker-plugin-lto`")]
350pub(crate) struct SplitLtoUnitRequiresLto;
351
352#[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)]
353#[diag("`-Zvirtual-function-elimination` requires `-Clto`")]
354pub(crate) struct UnstableVirtualFunctionElimination;
355
356#[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)]
357#[diag("requested DWARF version {$dwarf_version} is not supported")]
358#[help("supported DWARF versions are 2, 3, 4 and 5")]
359pub(crate) struct UnsupportedDwarfVersion {
360 pub(crate) dwarf_version: u32,
361}
362
363#[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)]
364#[diag(
365 "`-Zembed-source=y` requires at least `-Z dwarf-version=5` but DWARF version is {$dwarf_version}"
366)]
367pub(crate) struct EmbedSourceInsufficientDwarfVersion {
368 pub(crate) dwarf_version: u32,
369}
370
371#[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)]
372#[diag("`-Zembed-source=y` requires debug information to be enabled")]
373pub(crate) struct EmbedSourceRequiresDebugInfo;
374
375#[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)]
376#[diag(
377 "`-Z stack-protector={$stack_protector}` is not supported for target {$target_triple} and will be ignored"
378)]
379pub(crate) struct StackProtectorNotSupportedForTarget<'a> {
380 pub(crate) stack_protector: StackProtector,
381 pub(crate) target_triple: &'a TargetTuple,
382}
383
384#[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)]
385#[diag(
386 "`-Z small-data-threshold` is not supported for target {$target_triple} and will be ignored"
387)]
388pub(crate) struct SmallDataThresholdNotSupportedForTarget<'a> {
389 pub(crate) target_triple: &'a TargetTuple,
390}
391
392#[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)]
393#[diag("`-Zbranch-protection` is only supported on aarch64")]
394pub(crate) struct BranchProtectionRequiresAArch64;
395
396#[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)]
397#[diag("`-Csplit-debuginfo={$debuginfo}` is unstable on this platform")]
398pub(crate) struct SplitDebugInfoUnstablePlatform {
399 pub(crate) debuginfo: SplitDebuginfo,
400}
401
402#[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)]
403#[diag("output file {$file} is not writeable -- check its permissions")]
404pub(crate) struct FileIsNotWriteable<'a> {
405 pub(crate) file: &'a std::path::Path,
406}
407
408#[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)]
409#[diag("failed to write `{$path}` due to error `{$err}`")]
410pub(crate) struct FileWriteFail<'a> {
411 pub(crate) path: &'a std::path::Path,
412 pub(crate) err: String,
413}
414
415#[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)]
416#[diag("crate name must not be empty")]
417pub(crate) struct CrateNameEmpty {
418 #[primary_span]
419 pub(crate) span: Option<Span>,
420}
421
422#[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)]
423#[diag("invalid character {$character} in crate name: `{$crate_name}`")]
424pub(crate) struct InvalidCharacterInCrateName {
425 #[primary_span]
426 pub(crate) span: Option<Span>,
427 pub(crate) character: char,
428 pub(crate) crate_name: Symbol,
429}
430
431#[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)]
432#[multipart_suggestion(
433 "parentheses are required to parse this as an expression",
434 applicability = "machine-applicable"
435)]
436pub struct ExprParenthesesNeeded {
437 #[suggestion_part(code = "(")]
438 left: Span,
439 #[suggestion_part(code = ")")]
440 right: Span,
441}
442
443impl ExprParenthesesNeeded {
444 pub fn surrounding(s: Span) -> Self {
445 ExprParenthesesNeeded { left: s.shrink_to_lo(), right: s.shrink_to_hi() }
446 }
447}
448
449#[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)]
450#[diag("skipping const checks")]
451pub(crate) struct SkippingConstChecks {
452 #[subdiagnostic]
453 pub(crate) unleashed_features: Vec<UnleashedFeatureHelp>,
454}
455
456#[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)]
457pub(crate) enum UnleashedFeatureHelp {
458 #[help("skipping check for `{$gate}` feature")]
459 Named {
460 #[primary_span]
461 span: Span,
462 gate: Symbol,
463 },
464 #[help("skipping check that does not even have a feature gate")]
465 Unnamed {
466 #[primary_span]
467 span: Span,
468 },
469}
470
471#[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)]
472#[diag("suffixes on {$kind} literals are invalid")]
473struct InvalidLiteralSuffix<'a> {
474 #[primary_span]
475 #[label("invalid suffix `{$suffix}`")]
476 span: Span,
477 kind: &'a str,
479 suffix: Symbol,
480}
481
482#[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)]
483#[diag("invalid width `{$width}` for integer literal")]
484#[help("valid widths are 8, 16, 32, 64 and 128")]
485struct InvalidIntLiteralWidth {
486 #[primary_span]
487 span: Span,
488 width: String,
489}
490
491#[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.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)]
492#[diag("invalid base prefix for number literal")]
493#[note("base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase")]
494struct InvalidNumLiteralBasePrefix {
495 #[primary_span]
496 #[suggestion(
497 "try making the prefix lowercase",
498 applicability = "maybe-incorrect",
499 code = "{fixed}"
500 )]
501 span: Span,
502 fixed: String,
503}
504
505#[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)]
506#[diag("invalid suffix `{$suffix}` for number literal")]
507#[help("the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)")]
508struct InvalidNumLiteralSuffix {
509 #[primary_span]
510 #[label("invalid suffix `{$suffix}`")]
511 span: Span,
512 suffix: String,
513}
514
515#[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)]
516#[diag("invalid width `{$width}` for float literal")]
517#[help("valid widths are 32 and 64")]
518struct InvalidFloatLiteralWidth {
519 #[primary_span]
520 span: Span,
521 width: String,
522}
523
524#[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)]
525#[diag("invalid suffix `{$suffix}` for float literal")]
526#[help("valid suffixes are `f32` and `f64`")]
527struct InvalidFloatLiteralSuffix {
528 #[primary_span]
529 #[label("invalid suffix `{$suffix}`")]
530 span: Span,
531 suffix: String,
532}
533
534#[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)]
535#[diag("integer literal is too large")]
536#[note("value exceeds limit of `{$limit}`")]
537struct IntLiteralTooLarge {
538 #[primary_span]
539 span: Span,
540 limit: String,
541}
542
543#[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)]
544#[diag("hexadecimal float literal is not supported")]
545struct HexadecimalFloatLiteralNotSupported {
546 #[primary_span]
547 #[label("not supported")]
548 span: Span,
549}
550
551#[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)]
552#[diag("octal float literal is not supported")]
553struct OctalFloatLiteralNotSupported {
554 #[primary_span]
555 #[label("not supported")]
556 span: Span,
557}
558
559#[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)]
560#[diag("binary float literal is not supported")]
561struct BinaryFloatLiteralNotSupported {
562 #[primary_span]
563 #[label("not supported")]
564 span: Span,
565}
566
567pub fn report_lit_error(
568 psess: &ParseSess,
569 err: LitError,
570 lit: token::Lit,
571 span: Span,
572) -> ErrorGuaranteed {
573 create_lit_error(psess, err, lit, span).emit()
574}
575
576pub fn create_lit_error(psess: &ParseSess, err: LitError, lit: token::Lit, span: Span) -> Diag<'_> {
577 fn looks_like_width_suffix(first_chars: &[char], s: &str) -> bool {
579 s.len() > 1 && s.starts_with(first_chars) && s[1..].chars().all(|c| c.is_ascii_digit())
580 }
581
582 fn fix_base_capitalisation(prefix: &str, suffix: &str) -> Option<String> {
584 let mut chars = suffix.chars();
585
586 let base_char = chars.next().unwrap();
587 let base = match base_char {
588 'B' => 2,
589 'O' => 8,
590 'X' => 16,
591 _ => return None,
592 };
593
594 let valid = prefix == "0"
596 && chars
597 .filter(|c| *c != '_')
598 .take_while(|c| *c != 'i' && *c != 'u')
599 .all(|c| c.to_digit(base).is_some());
600
601 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..]))
602 }
603
604 let dcx = psess.dcx();
605 match err {
606 LitError::InvalidSuffix(suffix) => {
607 dcx.create_err(InvalidLiteralSuffix { span, kind: lit.kind.descr(), suffix })
608 }
609 LitError::InvalidIntSuffix(suffix) => {
610 let suf = suffix.as_str();
611 if looks_like_width_suffix(&['i', 'u'], suf) {
612 dcx.create_err(InvalidIntLiteralWidth { span, width: suf[1..].into() })
614 } else if let Some(fixed) = fix_base_capitalisation(lit.symbol.as_str(), suf) {
615 dcx.create_err(InvalidNumLiteralBasePrefix { span, fixed })
616 } else {
617 dcx.create_err(InvalidNumLiteralSuffix { span, suffix: suf.to_string() })
618 }
619 }
620 LitError::InvalidFloatSuffix(suffix) => {
621 let suf = suffix.as_str();
622 if looks_like_width_suffix(&['f'], suf) {
623 dcx.create_err(InvalidFloatLiteralWidth { span, width: suf[1..].to_string() })
625 } else {
626 dcx.create_err(InvalidFloatLiteralSuffix { span, suffix: suf.to_string() })
627 }
628 }
629 LitError::NonDecimalFloat(base) => match base {
630 16 => dcx.create_err(HexadecimalFloatLiteralNotSupported { span }),
631 8 => dcx.create_err(OctalFloatLiteralNotSupported { span }),
632 2 => dcx.create_err(BinaryFloatLiteralNotSupported { span }),
633 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
634 },
635 LitError::IntTooLarge(base) => {
636 let max = u128::MAX;
637 let limit = match base {
638 2 => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#b}", max))
})format!("{max:#b}"),
639 8 => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#o}", max))
})format!("{max:#o}"),
640 16 => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#x}", max))
})format!("{max:#x}"),
641 _ => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", max))
})format!("{max}"),
642 };
643 dcx.create_err(IntLiteralTooLarge { span, limit })
644 }
645 }
646}
647
648#[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)]
649#[diag("linker flavor `{$flavor}` is incompatible with the current target")]
650#[note("compatible flavors are: {$compatible_list}")]
651pub(crate) struct IncompatibleLinkerFlavor {
652 pub(crate) flavor: &'static str,
653 pub(crate) compatible_list: String,
654}
655
656#[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)]
657#[diag("`-Zfunction-return` (except `keep`) is only supported on x86 and x86_64")]
658pub(crate) struct FunctionReturnRequiresX86OrX8664;
659
660#[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)]
661#[diag("`-Zfunction-return=thunk-extern` is only supported on non-large code models")]
662pub(crate) struct FunctionReturnThunkExternRequiresNonLargeCodeModel;
663
664#[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)]
665#[diag("`-Zindirect-branch-cs-prefix` is only supported on x86 and x86_64")]
666pub(crate) struct IndirectBranchCsPrefixRequiresX86OrX8664;
667
668#[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)]
669#[diag("`-Zregparm={$regparm}` is unsupported (valid values 0-3)")]
670pub(crate) struct UnsupportedRegparm {
671 pub(crate) regparm: u32,
672}
673
674#[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)]
675#[diag("`-Zregparm=N` is only supported on x86")]
676pub(crate) struct UnsupportedRegparmArch;
677
678#[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)]
679#[diag("`-Zreg-struct-return` is only supported on x86")]
680pub(crate) struct UnsupportedRegStructReturnArch;
681
682#[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)]
683#[diag("failed to create profiler: {$err}")]
684pub(crate) struct FailedToCreateProfiler {
685 pub(crate) err: String,
686}
687
688#[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)]
689#[diag("unexpected `--cfg {$cfg}` flag")]
690#[note("config `{$cfg_name}` is only supposed to be controlled by `{$controlled_by}`")]
691#[note("manually setting a built-in cfg can and does create incoherent behaviors")]
692pub(crate) struct UnexpectedBuiltinCfg {
693 pub(crate) cfg: String,
694 pub(crate) cfg_name: Symbol,
695 pub(crate) controlled_by: &'static str,
696}
697
698#[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)]
699#[diag("ThinLTO is not supported by the codegen backend, using fat LTO instead")]
700pub(crate) struct ThinLtoNotSupportedByBackend;
701
702#[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)]
703#[diag("`-Zpacked-stack` is only supported on s390x")]
704pub(crate) struct UnsupportedPackedStack;