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