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-08-03")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
PointerAuthenticationTypeDiscriminationNotSupportedForTarget<'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 {
PointerAuthenticationTypeDiscriminationNotSupportedForTarget {
target_triple: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function pointer type discrimination is not supported")));
;
diag
}
}
}
}
};Diagnostic)]
385#[diag("function pointer type discrimination is not supported")]
386pub(crate) struct PointerAuthenticationTypeDiscriminationNotSupportedForTarget<'a> {
387 pub(crate) target_triple: &'a TargetTuple,
388}
389
390#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
PointerAuthenticationNotSupportedForTarget<'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 {
PointerAuthenticationNotSupportedForTarget {
target_triple: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Z pointer-authentication` is not supported for target {$target_triple} and will be ignored")));
;
diag.arg("target_triple", __binding_0);
diag
}
}
}
}
};Diagnostic)]
391#[diag(
392 "`-Z pointer-authentication` is not supported for target {$target_triple} and will be ignored"
393)]
394pub(crate) struct PointerAuthenticationNotSupportedForTarget<'a> {
395 pub(crate) target_triple: &'a TargetTuple,
396}
397
398#[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)]
399#[diag(
400 "`-Z small-data-threshold` is not supported for target {$target_triple} and will be ignored"
401)]
402pub(crate) struct SmallDataThresholdNotSupportedForTarget<'a> {
403 pub(crate) target_triple: &'a TargetTuple,
404}
405
406#[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)]
407#[diag("`-Zbranch-protection` is only supported on aarch64")]
408pub(crate) struct BranchProtectionRequiresAArch64;
409
410#[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)]
411#[diag("`-Csplit-debuginfo={$debuginfo}` is unstable on this platform")]
412pub(crate) struct SplitDebugInfoUnstablePlatform {
413 pub(crate) debuginfo: SplitDebuginfo,
414}
415
416#[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)]
417#[diag("output file {$file} is not writeable -- check its permissions")]
418pub(crate) struct FileIsNotWriteable<'a> {
419 pub(crate) file: &'a std::path::Path,
420}
421
422#[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)]
423#[diag("failed to write `{$path}` due to error `{$err}`")]
424pub(crate) struct FileWriteFail<'a> {
425 pub(crate) path: &'a std::path::Path,
426 pub(crate) err: String,
427}
428
429#[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)]
430#[diag("crate name must not be empty")]
431pub(crate) struct CrateNameEmpty {
432 #[primary_span]
433 pub(crate) span: Option<Span>,
434}
435
436#[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,
suggestion: __binding_3 } => {
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.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("crate names may only contain alphanumeric characters or underscores")));
;
diag.arg("character", __binding_1);
diag.arg("crate_name", __binding_2);
if let Some(__binding_0) = __binding_0 {
diag.span(__binding_0);
}
if let Some(__binding_3) = __binding_3 {
diag.subdiagnostic(__binding_3);
}
diag
}
}
}
}
};Diagnostic)]
437#[diag("invalid character {$character} in crate name: `{$crate_name}`")]
438#[note("crate names may only contain alphanumeric characters or underscores")]
439pub(crate) struct InvalidCharacterInCrateName {
440 #[primary_span]
441 pub(crate) span: Option<Span>,
442 pub(crate) character: char,
443 pub(crate) crate_name: Symbol,
444 #[subdiagnostic]
445 pub(crate) suggestion: Option<InvalidCharacterInCrateNameSuggestion>,
446}
447
448#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for
InvalidCharacterInCrateNameSuggestion {
fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
where __G: rustc_errors::EmissionGuarantee {
match self {
InvalidCharacterInCrateNameSuggestion {
suggested_name: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("suggested_name".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("you might have meant to use `--crate-name={$suggested_name}`")),
&sub_args);
diag.help(__message);
}
}
}
}
};Subdiagnostic)]
449#[help("you might have meant to use `--crate-name={$suggested_name}`")]
450pub(crate) struct InvalidCharacterInCrateNameSuggestion {
451 pub(crate) suggested_name: String,
452}
453
454#[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)]
455#[multipart_suggestion(
456 "parentheses are required to parse this as an expression",
457 applicability = "machine-applicable"
458)]
459pub struct ExprParenthesesNeeded {
460 #[suggestion_part(code = "(")]
461 left: Span,
462 #[suggestion_part(code = ")")]
463 right: Span,
464}
465
466impl ExprParenthesesNeeded {
467 pub fn surrounding(s: Span) -> Self {
468 ExprParenthesesNeeded { left: s.shrink_to_lo(), right: s.shrink_to_hi() }
469 }
470}
471
472#[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)]
473#[diag("skipping const checks")]
474pub(crate) struct SkippingConstChecks {
475 #[subdiagnostic]
476 pub(crate) unleashed_features: Vec<UnleashedFeatureHelp>,
477}
478
479#[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)]
480pub(crate) enum UnleashedFeatureHelp {
481 #[help("skipping check for `{$gate}` feature")]
482 Named {
483 #[primary_span]
484 span: Span,
485 gate: Symbol,
486 },
487 #[help("skipping check that does not even have a feature gate")]
488 Unnamed {
489 #[primary_span]
490 span: Span,
491 },
492}
493
494#[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)]
495#[diag("suffixes on {$kind} literals are invalid")]
496struct InvalidLiteralSuffix<'a> {
497 #[primary_span]
498 #[label("invalid suffix `{$suffix}`")]
499 span: Span,
500 kind: &'a str,
502 suffix: Symbol,
503}
504
505#[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)]
506#[diag("invalid width `{$width}` for integer literal")]
507#[help("valid widths are 8, 16, 32, 64 and 128")]
508struct InvalidIntLiteralWidth {
509 #[primary_span]
510 span: Span,
511 width: String,
512}
513
514#[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)]
515#[diag("invalid base prefix for number literal")]
516#[note("base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase")]
517struct InvalidNumLiteralBasePrefix {
518 #[primary_span]
519 #[suggestion(
520 "try making the prefix lowercase",
521 applicability = "maybe-incorrect",
522 code = "{fixed}"
523 )]
524 span: Span,
525 fixed: String,
526}
527
528#[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)]
529#[diag("invalid suffix `{$suffix}` for number literal")]
530#[help("the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)")]
531struct InvalidNumLiteralSuffix {
532 #[primary_span]
533 #[label("invalid suffix `{$suffix}`")]
534 span: Span,
535 suffix: String,
536}
537
538#[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)]
539#[diag("invalid width `{$width}` for float literal")]
540#[help("valid widths are 32 and 64")]
541struct InvalidFloatLiteralWidth {
542 #[primary_span]
543 span: Span,
544 width: String,
545}
546
547#[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)]
548#[diag("invalid suffix `{$suffix}` for float literal")]
549#[help("valid suffixes are `f32` and `f64`")]
550struct InvalidFloatLiteralSuffix {
551 #[primary_span]
552 #[label("invalid suffix `{$suffix}`")]
553 span: Span,
554 suffix: String,
555}
556
557#[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)]
558#[diag("integer literal is too large")]
559#[note("value exceeds limit of `{$limit}`")]
560struct IntLiteralTooLarge {
561 #[primary_span]
562 span: Span,
563 limit: String,
564}
565
566#[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)]
567#[diag("hexadecimal float literal is not supported")]
568struct HexadecimalFloatLiteralNotSupported {
569 #[primary_span]
570 #[label("not supported")]
571 span: Span,
572}
573
574#[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)]
575#[diag("octal float literal is not supported")]
576struct OctalFloatLiteralNotSupported {
577 #[primary_span]
578 #[label("not supported")]
579 span: Span,
580}
581
582#[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)]
583#[diag("binary float literal is not supported")]
584struct BinaryFloatLiteralNotSupported {
585 #[primary_span]
586 #[label("not supported")]
587 span: Span,
588}
589
590pub fn report_lit_error(
591 psess: &ParseSess,
592 err: LitError,
593 lit: token::Lit,
594 span: Span,
595) -> ErrorGuaranteed {
596 create_lit_error(psess, err, lit, span).emit()
597}
598
599pub fn create_lit_error(psess: &ParseSess, err: LitError, lit: token::Lit, span: Span) -> Diag<'_> {
600 fn looks_like_width_suffix(first_chars: &[char], s: &str) -> bool {
602 s.len() > 1 && s.starts_with(first_chars) && s[1..].chars().all(|c| c.is_ascii_digit())
603 }
604
605 fn fix_base_capitalisation(prefix: &str, suffix: &str) -> Option<String> {
607 let mut chars = suffix.chars();
608
609 let base_char = chars.next().unwrap();
610 let base = match base_char {
611 'B' => 2,
612 'O' => 8,
613 'X' => 16,
614 _ => return None,
615 };
616
617 let valid = prefix == "0"
619 && chars
620 .filter(|c| *c != '_')
621 .take_while(|c| *c != 'i' && *c != 'u')
622 .all(|c| c.to_digit(base).is_some());
623
624 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..]))
625 }
626
627 let dcx = psess.dcx();
628 match err {
629 LitError::InvalidSuffix(suffix) => {
630 dcx.create_err(InvalidLiteralSuffix { span, kind: lit.kind.descr(), suffix })
631 }
632 LitError::InvalidIntSuffix(suffix) => {
633 let suf = suffix.as_str();
634 if looks_like_width_suffix(&['i', 'u'], suf) {
635 dcx.create_err(InvalidIntLiteralWidth { span, width: suf[1..].into() })
637 } else if let Some(fixed) = fix_base_capitalisation(lit.symbol.as_str(), suf) {
638 dcx.create_err(InvalidNumLiteralBasePrefix { span, fixed })
639 } else {
640 dcx.create_err(InvalidNumLiteralSuffix { span, suffix: suf.to_string() })
641 }
642 }
643 LitError::InvalidFloatSuffix(suffix) => {
644 let suf = suffix.as_str();
645 if looks_like_width_suffix(&['f'], suf) {
646 dcx.create_err(InvalidFloatLiteralWidth { span, width: suf[1..].to_string() })
648 } else {
649 dcx.create_err(InvalidFloatLiteralSuffix { span, suffix: suf.to_string() })
650 }
651 }
652 LitError::NonDecimalFloat(base) => match base {
653 16 => dcx.create_err(HexadecimalFloatLiteralNotSupported { span }),
654 8 => dcx.create_err(OctalFloatLiteralNotSupported { span }),
655 2 => dcx.create_err(BinaryFloatLiteralNotSupported { span }),
656 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
657 },
658 LitError::IntTooLarge(base) => {
659 let max = u128::MAX;
660 let limit = match base {
661 2 => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#b}", max))
})format!("{max:#b}"),
662 8 => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#o}", max))
})format!("{max:#o}"),
663 16 => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:#x}", max))
})format!("{max:#x}"),
664 _ => ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}", max))
})format!("{max}"),
665 };
666 dcx.create_err(IntLiteralTooLarge { span, limit })
667 }
668 }
669}
670
671#[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)]
672#[diag("linker flavor `{$flavor}` is incompatible with the current target")]
673#[note("compatible flavors are: {$compatible_list}")]
674pub(crate) struct IncompatibleLinkerFlavor {
675 pub(crate) flavor: &'static str,
676 pub(crate) compatible_list: String,
677}
678
679#[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)]
680#[diag("`-Zfunction-return` (except `keep`) is only supported on x86 and x86_64")]
681pub(crate) struct FunctionReturnRequiresX86OrX8664;
682
683#[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)]
684#[diag("`-Zfunction-return=thunk-extern` is only supported on non-large code models")]
685pub(crate) struct FunctionReturnThunkExternRequiresNonLargeCodeModel;
686
687#[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)]
688#[diag("`-Zindirect-branch-cs-prefix` is only supported on x86 and x86_64")]
689pub(crate) struct IndirectBranchCsPrefixRequiresX86OrX8664;
690
691#[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)]
692#[diag("`-Zregparm={$regparm}` is unsupported (valid values 0-3)")]
693pub(crate) struct UnsupportedRegparm {
694 pub(crate) regparm: u32,
695}
696
697#[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)]
698#[diag("`-Zregparm=N` is only supported on x86")]
699pub(crate) struct UnsupportedRegparmArch;
700
701#[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)]
702#[diag("`-Zreg-struct-return` is only supported on x86")]
703pub(crate) struct UnsupportedRegStructReturnArch;
704
705#[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)]
706#[diag("failed to create profiler: {$err}")]
707pub(crate) struct FailedToCreateProfiler {
708 pub(crate) err: String,
709}
710
711#[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)]
712#[diag("unexpected `--cfg {$cfg}` flag")]
713#[note("config `{$cfg_name}` is only supposed to be controlled by `{$controlled_by}`")]
714#[note("manually setting a built-in cfg can and does create incoherent behaviors")]
715pub(crate) struct UnexpectedBuiltinCfg {
716 pub(crate) cfg: String,
717 pub(crate) cfg_name: Symbol,
718 pub(crate) controlled_by: &'static str,
719}
720
721#[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)]
722#[diag("ThinLTO is not supported by the codegen backend, using fat LTO instead")]
723pub(crate) struct ThinLtoNotSupportedByBackend;
724
725#[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)]
726#[diag("`-Zpacked-stack` is only supported on s390x")]
727pub(crate) struct UnsupportedPackedStack;
728
729#[derive(const _: () =
{
impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
NativeTargetCpuNotAllowed<'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 {
NativeTargetCpuNotAllowed {
target_triple: __binding_0, need_explicit_cpu: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Ctarget-cpu=native` is not allowed for target `{$target_triple}`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this target requires consistent `-Ctarget-cpu` values across all crates")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("specify the target CPU explicitly {$need_explicit_cpu ->\n [false] or leave it blank to use the default\n *[other] {\"\"}\n }")));
;
diag.arg("target_triple", __binding_0);
diag.arg("need_explicit_cpu", __binding_1);
diag
}
}
}
}
};Diagnostic)]
730#[diag("`-Ctarget-cpu=native` is not allowed for target `{$target_triple}`")]
731#[note("this target requires consistent `-Ctarget-cpu` values across all crates")]
732#[help(
733 "specify the target CPU explicitly {$need_explicit_cpu ->
734 [false] or leave it blank to use the default
735 *[other] {\"\"}
736 }"
737)]
738pub(crate) struct NativeTargetCpuNotAllowed<'a> {
739 pub(crate) target_triple: &'a TargetTuple,
740 pub(crate) need_explicit_cpu: bool,
741}