1use std::io::Error;
2use std::path::{Path, PathBuf};
3
4use rustc_errors::codes::*;
5use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, Level, msg};
6use rustc_macros::{Diagnostic, Subdiagnostic};
7use rustc_span::{Span, Symbol, sym};
8use rustc_target::spec::{PanicStrategy, TargetTuple};
9
10use crate::locator::CrateFlavor;
11
12#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for RlibRequired {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
RlibRequired { crate_name: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("crate `{$crate_name}` required to be available in rlib format, but was not found in this form")));
;
diag.arg("crate_name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
13#[diag(
14 "crate `{$crate_name}` required to be available in rlib format, but was not found in this form"
15)]
16pub(crate) struct RlibRequired {
17 pub crate_name: Symbol,
18}
19
20#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for LibRequired<'a>
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
LibRequired { crate_name: __binding_0, kind: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("crate `{$crate_name}` required to be available in {$kind} format, but was not found in this form")));
;
diag.arg("crate_name", __binding_0);
diag.arg("kind", __binding_1);
diag
}
}
}
}
};Diagnostic)]
21#[diag(
22 "crate `{$crate_name}` required to be available in {$kind} format, but was not found in this form"
23)]
24pub(crate) struct LibRequired<'a> {
25 pub crate_name: Symbol,
26 pub kind: &'a str,
27}
28
29#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
RustcLibRequired<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
RustcLibRequired {
crate_name: __binding_0, kind: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("crate `{$crate_name}` required to be available in {$kind} format, but was not found in this form")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try adding `extern crate rustc_driver;` at the top level of this crate")));
;
diag.arg("crate_name", __binding_0);
diag.arg("kind", __binding_1);
diag
}
}
}
}
};Diagnostic)]
30#[diag(
31 "crate `{$crate_name}` required to be available in {$kind} format, but was not found in this form"
32)]
33#[help("try adding `extern crate rustc_driver;` at the top level of this crate")]
34pub(crate) struct RustcLibRequired<'a> {
35 pub crate_name: Symbol,
36 pub kind: &'a str,
37}
38
39#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for CrateDepMultiple {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CrateDepMultiple {
crate_name: __binding_0,
non_static_deps: __binding_1,
rustc_driver_help: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot satisfy dependencies so `{$crate_name}` only shows up once")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("having upstream crates all available in one format will likely make this go away")));
;
diag.arg("crate_name", __binding_0);
for __binding_1 in __binding_1 {
diag.subdiagnostic(__binding_1);
}
if __binding_2 {
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`feature(rustc_private)` is needed to link to the compiler's `rustc_driver` library")));
}
diag
}
}
}
}
};Diagnostic)]
40#[diag("cannot satisfy dependencies so `{$crate_name}` only shows up once")]
41#[help("having upstream crates all available in one format will likely make this go away")]
42pub(crate) struct CrateDepMultiple {
43 pub crate_name: Symbol,
44 #[subdiagnostic]
45 pub non_static_deps: Vec<NonStaticCrateDep>,
46 #[help("`feature(rustc_private)` is needed to link to the compiler's `rustc_driver` library")]
47 pub rustc_driver_help: bool,
48}
49
50#[derive(const _: () =
{
impl rustc_errors::Subdiagnostic for NonStaticCrateDep {
fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) {
match self {
NonStaticCrateDep { sub_crate_name: __binding_0 } => {
let mut sub_args = rustc_errors::DiagArgMap::default();
sub_args.insert("sub_crate_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("`{$sub_crate_name}` was unavailable as a static crate, preventing fully static linking")),
&sub_args);
diag.note(__message);
}
}
}
}
};Subdiagnostic)]
51#[note("`{$sub_crate_name}` was unavailable as a static crate, preventing fully static linking")]
52pub(crate) struct NonStaticCrateDep {
53 pub sub_crate_name: Symbol,
55}
56
57#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for TwoPanicRuntimes {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
TwoPanicRuntimes {
prev_name: __binding_0, cur_name: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot link together two panic runtimes: {$prev_name} and {$cur_name}")));
;
diag.arg("prev_name", __binding_0);
diag.arg("cur_name", __binding_1);
diag
}
}
}
}
};Diagnostic)]
58#[diag("cannot link together two panic runtimes: {$prev_name} and {$cur_name}")]
59pub(crate) struct TwoPanicRuntimes {
60 pub prev_name: Symbol,
61 pub cur_name: Symbol,
62}
63
64#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for BadPanicStrategy {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
BadPanicStrategy {
runtime: __binding_0, strategy: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the linked panic runtime `{$runtime}` is not compiled with this crate's panic strategy `{$strategy}`")));
;
diag.arg("runtime", __binding_0);
diag.arg("strategy", __binding_1);
diag
}
}
}
}
};Diagnostic)]
65#[diag(
66 "the linked panic runtime `{$runtime}` is not compiled with this crate's panic strategy `{$strategy}`"
67)]
68pub(crate) struct BadPanicStrategy {
69 pub runtime: Symbol,
70 pub strategy: PanicStrategy,
71}
72
73#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
RequiredPanicStrategy {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
RequiredPanicStrategy {
crate_name: __binding_0,
found_strategy: __binding_1,
desired_strategy: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the crate `{$crate_name}` requires panic strategy `{$found_strategy}` which is incompatible with this crate's strategy of `{$desired_strategy}`")));
;
diag.arg("crate_name", __binding_0);
diag.arg("found_strategy", __binding_1);
diag.arg("desired_strategy", __binding_2);
diag
}
}
}
}
};Diagnostic)]
74#[diag(
75 "the crate `{$crate_name}` requires panic strategy `{$found_strategy}` which is incompatible \
76 with this crate's strategy of `{$desired_strategy}`"
77)]
78pub(crate) struct RequiredPanicStrategy {
79 pub crate_name: Symbol,
80 pub found_strategy: PanicStrategy,
81 pub desired_strategy: PanicStrategy,
82}
83
84#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
IncompatibleWithImmediateAbort {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
IncompatibleWithImmediateAbort { crate_name: __binding_0 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the crate `{$crate_name}` was compiled with a panic strategy which is incompatible with `immediate-abort`")));
;
diag.arg("crate_name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
85#[diag(
86 "the crate `{$crate_name}` was compiled with a panic strategy which is incompatible with \
87 `immediate-abort`"
88)]
89pub(crate) struct IncompatibleWithImmediateAbort {
90 pub crate_name: Symbol,
91}
92
93#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
IncompatibleWithImmediateAbortCore {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
IncompatibleWithImmediateAbortCore => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the crate `core` was compiled with a panic strategy which is incompatible with `immediate-abort`")));
;
diag
}
}
}
}
};Diagnostic)]
94#[diag(
95 "the crate `core` was compiled with a panic strategy which is incompatible with \
96 `immediate-abort`"
97)]
98pub(crate) struct IncompatibleWithImmediateAbortCore;
99
100#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
IncompatiblePanicInDropStrategy {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
IncompatiblePanicInDropStrategy {
crate_name: __binding_0,
found_strategy: __binding_1,
desired_strategy: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the crate `{$crate_name}` is compiled with the panic-in-drop strategy `{$found_strategy}` which is incompatible with this crate's strategy of `{$desired_strategy}`")));
;
diag.arg("crate_name", __binding_0);
diag.arg("found_strategy", __binding_1);
diag.arg("desired_strategy", __binding_2);
diag
}
}
}
}
};Diagnostic)]
101#[diag(
102 "the crate `{$crate_name}` is compiled with the panic-in-drop strategy `{$found_strategy}` \
103 which is incompatible with this crate's strategy of `{$desired_strategy}`"
104)]
105pub(crate) struct IncompatiblePanicInDropStrategy {
106 pub crate_name: Symbol,
107 pub found_strategy: PanicStrategy,
108 pub desired_strategy: PanicStrategy,
109}
110
111#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for LinkOrdinalRawDylib
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
LinkOrdinalRawDylib { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[link_ordinal]` is only supported if link kind is `raw-dylib`")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
112#[diag("`#[link_ordinal]` is only supported if link kind is `raw-dylib`")]
113pub(crate) struct LinkOrdinalRawDylib {
114 #[primary_span]
115 pub span: Span,
116}
117
118#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for LibFrameworkApple {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
LibFrameworkApple => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("library kind `framework` is only supported on Apple targets")));
;
diag
}
}
}
}
};Diagnostic)]
119#[diag("library kind `framework` is only supported on Apple targets")]
120pub(crate) struct LibFrameworkApple;
121
122#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
EmptyRenamingTarget<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
EmptyRenamingTarget { lib_name: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("an empty renaming target was specified for library `{$lib_name}`")));
;
diag.arg("lib_name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
123#[diag("an empty renaming target was specified for library `{$lib_name}`")]
124pub(crate) struct EmptyRenamingTarget<'a> {
125 pub lib_name: &'a str,
126}
127
128#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
RenamingNoLink<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
RenamingNoLink { lib_name: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("renaming of the library `{$lib_name}` was specified, however this crate contains no `#[link(...)]` attributes referencing this library")));
;
diag.arg("lib_name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
129#[diag(
130 "renaming of the library `{$lib_name}` was specified, however this crate contains no \
131 `#[link(...)]` attributes referencing this library"
132)]
133pub(crate) struct RenamingNoLink<'a> {
134 pub lib_name: &'a str,
135}
136
137#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
MultipleRenamings<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MultipleRenamings { lib_name: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("multiple renamings were specified for library `{$lib_name}`")));
;
diag.arg("lib_name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
138#[diag("multiple renamings were specified for library `{$lib_name}`")]
139pub(crate) struct MultipleRenamings<'a> {
140 pub lib_name: &'a str,
141}
142
143#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for NoLinkModOverride {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
NoLinkModOverride { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("overriding linking modifiers from command line is not supported")));
;
if let Some(__binding_0) = __binding_0 {
diag.span(__binding_0);
}
diag
}
}
}
}
};Diagnostic)]
144#[diag("overriding linking modifiers from command line is not supported")]
145pub(crate) struct NoLinkModOverride {
146 #[primary_span]
147 pub span: Option<Span>,
148}
149
150#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
RawDylibUnsupportedAbi {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
RawDylibUnsupportedAbi { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ABI not supported by `#[link(kind = \"raw-dylib\")]` on this architecture")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
151#[diag("ABI not supported by `#[link(kind = \"raw-dylib\")]` on this architecture")]
152pub(crate) struct RawDylibUnsupportedAbi {
153 #[primary_span]
154 pub span: Span,
155}
156
157#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
FailCreateFileEncoder {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
FailCreateFileEncoder { err: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to create file encoder: {$err}")));
;
diag.arg("err", __binding_0);
diag
}
}
}
}
};Diagnostic)]
158#[diag("failed to create file encoder: {$err}")]
159pub(crate) struct FailCreateFileEncoder {
160 pub err: Error,
161}
162
163#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
FailWriteFile<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
FailWriteFile { 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 to `{$path}`: {$err}")));
;
diag.arg("path", __binding_0);
diag.arg("err", __binding_1);
diag
}
}
}
}
};Diagnostic)]
164#[diag("failed to write to `{$path}`: {$err}")]
165pub(crate) struct FailWriteFile<'a> {
166 pub path: &'a Path,
167 pub err: Error,
168}
169
170#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for CrateNotPanicRuntime
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CrateNotPanicRuntime { crate_name: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the crate `{$crate_name}` is not a panic runtime")));
;
diag.arg("crate_name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
171#[diag("the crate `{$crate_name}` is not a panic runtime")]
172pub(crate) struct CrateNotPanicRuntime {
173 pub crate_name: Symbol,
174}
175
176#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
CrateNotCompilerBuiltins {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CrateNotCompilerBuiltins { crate_name: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the crate `{$crate_name}` resolved as `compiler_builtins` but is not `#![compiler_builtins]`")));
;
diag.arg("crate_name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
177#[diag(
178 "the crate `{$crate_name}` resolved as `compiler_builtins` but is not `#![compiler_builtins]`"
179)]
180pub(crate) struct CrateNotCompilerBuiltins {
181 pub crate_name: Symbol,
182}
183
184#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for NoPanicStrategy {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
NoPanicStrategy {
crate_name: __binding_0, strategy: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the crate `{$crate_name}` does not have the panic strategy `{$strategy}`")));
;
diag.arg("crate_name", __binding_0);
diag.arg("strategy", __binding_1);
diag
}
}
}
}
};Diagnostic)]
185#[diag("the crate `{$crate_name}` does not have the panic strategy `{$strategy}`")]
186pub(crate) struct NoPanicStrategy {
187 pub crate_name: Symbol,
188 pub strategy: PanicStrategy,
189}
190
191#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for NotProfilerRuntime {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
NotProfilerRuntime { crate_name: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the crate `{$crate_name}` is not a profiler runtime")));
;
diag.arg("crate_name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
192#[diag("the crate `{$crate_name}` is not a profiler runtime")]
193pub(crate) struct NotProfilerRuntime {
194 pub crate_name: Symbol,
195}
196
197#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
NoMultipleGlobalAlloc {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
NoMultipleGlobalAlloc {
span2: __binding_0, span1: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot define multiple global allocators")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot define a new global allocator")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("previous global allocator defined here")));
diag
}
}
}
}
};Diagnostic)]
198#[diag("cannot define multiple global allocators")]
199pub(crate) struct NoMultipleGlobalAlloc {
200 #[primary_span]
201 #[label("cannot define a new global allocator")]
202 pub span2: Span,
203 #[label("previous global allocator defined here")]
204 pub span1: Span,
205}
206
207#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
NoMultipleAllocErrorHandler {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
NoMultipleAllocErrorHandler {
span2: __binding_0, span1: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot define multiple allocation error handlers")));
;
diag.span(__binding_0);
diag.span_label(__binding_0,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot define a new allocation error handler")));
diag.span_label(__binding_1,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("previous allocation error handler defined here")));
diag
}
}
}
}
};Diagnostic)]
208#[diag("cannot define multiple allocation error handlers")]
209pub(crate) struct NoMultipleAllocErrorHandler {
210 #[primary_span]
211 #[label("cannot define a new allocation error handler")]
212 pub span2: Span,
213 #[label("previous allocation error handler defined here")]
214 pub span1: Span,
215}
216
217#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ConflictingGlobalAlloc {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ConflictingGlobalAlloc {
crate_name: __binding_0,
other_crate_name: __binding_1,
this_crate: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `#[global_allocator]` in {$this_crate ->\n [true] this crate\n *[false] `{$other_crate_name}`\n } conflicts with global allocator in `{$crate_name}`")));
;
diag.arg("crate_name", __binding_0);
diag.arg("other_crate_name", __binding_1);
diag.arg("this_crate", __binding_2);
diag
}
}
}
}
};Diagnostic)]
218#[diag(
219 "the `#[global_allocator]` in {$this_crate ->
220 [true] this crate
221 *[false] `{$other_crate_name}`
222 } conflicts with global allocator in `{$crate_name}`"
223)]
224pub(crate) struct ConflictingGlobalAlloc {
225 pub crate_name: Symbol,
226 pub other_crate_name: Symbol,
227 pub this_crate: bool,
228}
229
230#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
ConflictingAllocErrorHandler {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ConflictingAllocErrorHandler {
crate_name: __binding_0, other_crate_name: __binding_1 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `#[alloc_error_handler]` in `{$other_crate_name}` conflicts with allocation error handler in `{$crate_name}`")));
;
diag.arg("crate_name", __binding_0);
diag.arg("other_crate_name", __binding_1);
diag
}
}
}
}
};Diagnostic)]
231#[diag(
232 "the `#[alloc_error_handler]` in `{$other_crate_name}` conflicts with allocation error handler \
233 in `{$crate_name}`"
234)]
235pub(crate) struct ConflictingAllocErrorHandler {
236 pub crate_name: Symbol,
237 pub other_crate_name: Symbol,
238}
239
240#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for GlobalAllocRequired
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
GlobalAllocRequired => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("no global memory allocator found but one is required")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("link to std or add `#[global_allocator]` to a static item that implements the `GlobalAlloc` trait")));
;
diag
}
}
}
}
};Diagnostic)]
241#[diag("no global memory allocator found but one is required")]
242#[help(
243 "link to std or add `#[global_allocator]` to a static item that implements the `GlobalAlloc` \
244 trait"
245)]
246pub(crate) struct GlobalAllocRequired;
247
248#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for FailedWriteError {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
FailedWriteError { filename: __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 `{$filename}`: {$err}")));
;
diag.arg("filename", __binding_0);
diag.arg("err", __binding_1);
diag
}
}
}
}
};Diagnostic)]
249#[diag("failed to write `{$filename}`: {$err}")]
250pub(crate) struct FailedWriteError {
251 pub filename: PathBuf,
252 pub err: Error,
253}
254
255#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for FailedCopyToStdout {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
FailedCopyToStdout { filename: __binding_0, err: __binding_1
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to copy `{$filename}` to stdout: {$err}")));
;
diag.arg("filename", __binding_0);
diag.arg("err", __binding_1);
diag
}
}
}
}
};Diagnostic)]
256#[diag("failed to copy `{$filename}` to stdout: {$err}")]
257pub(crate) struct FailedCopyToStdout {
258 pub filename: PathBuf,
259 pub err: Error,
260}
261
262#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for BinaryOutputToTty {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
BinaryOutputToTty => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("option `-o` or `--emit` is used to write binary output type `metadata` to stdout, but stdout is a tty")));
;
diag
}
}
}
}
};Diagnostic)]
263#[diag(
264 "option `-o` or `--emit` is used to write binary output type `metadata` to stdout, but stdout \
265 is a tty"
266)]
267pub(crate) struct BinaryOutputToTty;
268
269#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for FailedCreateTempdir
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
FailedCreateTempdir { err: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("couldn't create a temp dir: {$err}")));
;
diag.arg("err", __binding_0);
diag
}
}
}
}
};Diagnostic)]
270#[diag("couldn't create a temp dir: {$err}")]
271pub(crate) struct FailedCreateTempdir {
272 pub err: Error,
273}
274
275#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
FailedCreateFile<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
FailedCreateFile { filename: __binding_0, err: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to create the file `{$filename}`: {$err}")));
;
diag.arg("filename", __binding_0);
diag.arg("err", __binding_1);
diag
}
}
}
}
};Diagnostic)]
276#[diag("failed to create the file `{$filename}`: {$err}")]
277pub(crate) struct FailedCreateFile<'a> {
278 pub filename: &'a Path,
279 pub err: Error,
280}
281
282#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
FailedCreateEncodedMetadata {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
FailedCreateEncodedMetadata { err: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to create encoded metadata from file: {$err}")));
;
diag.arg("err", __binding_0);
diag
}
}
}
}
};Diagnostic)]
283#[diag("failed to create encoded metadata from file: {$err}")]
284pub(crate) struct FailedCreateEncodedMetadata {
285 pub err: Error,
286}
287
288#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for NonAsciiName {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
NonAsciiName { span: __binding_0, crate_name: __binding_1 }
=> {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot load a crate with a non-ascii name `{$crate_name}`")));
;
diag.arg("crate_name", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
289#[diag("cannot load a crate with a non-ascii name `{$crate_name}`")]
290pub(crate) struct NonAsciiName {
291 #[primary_span]
292 pub span: Span,
293 pub crate_name: Symbol,
294}
295
296#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
ExternLocationNotExist<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ExternLocationNotExist {
span: __binding_0,
crate_name: __binding_1,
location: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("extern location for `{$crate_name}` does not exist at `{$location}`")));
;
diag.arg("crate_name", __binding_1);
diag.arg("location", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
297#[diag("extern location for `{$crate_name}` does not exist at `{$location}`")]
298pub(crate) struct ExternLocationNotExist<'a> {
299 #[primary_span]
300 pub span: Span,
301 pub crate_name: Symbol,
302 pub location: &'a Path,
303}
304
305#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
ExternLocationNotFile<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
ExternLocationNotFile {
span: __binding_0,
crate_name: __binding_1,
location: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("extern location for `{$crate_name}` is not a file: `{$location}`")));
;
diag.arg("crate_name", __binding_1);
diag.arg("location", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
306#[diag("extern location for `{$crate_name}` is not a file: `{$location}`")]
307pub(crate) struct ExternLocationNotFile<'a> {
308 #[primary_span]
309 pub span: Span,
310 pub crate_name: Symbol,
311 pub location: &'a Path,
312}
313
314pub(crate) struct MultipleCandidates {
315 pub span: Span,
316 pub flavor: CrateFlavor,
317 pub crate_name: Symbol,
318 pub candidates: Vec<PathBuf>,
319}
320
321impl Diagnostic<'_> for MultipleCandidates {
322 fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> {
323 let mut diag = Diag::new(
324 dcx,
325 level,
326 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("multiple candidates for `{$flavor}` dependency `{$crate_name}` found"))msg!("multiple candidates for `{$flavor}` dependency `{$crate_name}` found"),
327 );
328 diag.arg("crate_name", self.crate_name);
329 diag.arg("flavor", self.flavor);
330 diag.code(E0464);
331 diag.span(self.span);
332 for (i, candidate) in self.candidates.iter().enumerate() {
333 diag.note(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("candidate #{0}: {1}", i + 1,
candidate.display()))
})format!("candidate #{}: {}", i + 1, candidate.display()));
334 }
335 diag
336 }
337}
338
339#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for FullMetadataNotFound
{
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
FullMetadataNotFound {
span: __binding_0,
flavor: __binding_1,
crate_name: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only metadata stub found for `{$flavor}` dependency `{$crate_name}`")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("provide path to the corresponding `.rmeta` file with full metadata")));
;
diag.arg("flavor", __binding_1);
diag.arg("crate_name", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
340#[diag("only metadata stub found for `{$flavor}` dependency `{$crate_name}`")]
341#[help("provide path to the corresponding `.rmeta` file with full metadata")]
342pub(crate) struct FullMetadataNotFound {
343 #[primary_span]
344 pub span: Span,
345 pub flavor: CrateFlavor,
346 pub crate_name: Symbol,
347}
348
349#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
SymbolConflictsCurrent {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
SymbolConflictsCurrent {
span: __binding_0, crate_name: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the current crate is indistinguishable from one of its dependencies")));
diag.code(E0519);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("it has the same name `{$crate_name}` and was compiled with the same `-C metadata` arguments, so this will result in symbol conflicts between the two")));
;
diag.arg("crate_name", __binding_1);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
350#[diag("the current crate is indistinguishable from one of its dependencies", code = E0519)]
351#[note(
352 "it has the same name `{$crate_name}` and was compiled with the same `-C metadata` arguments, \
353 so this will result in symbol conflicts between the two"
354)]
355pub(crate) struct SymbolConflictsCurrent {
356 #[primary_span]
357 pub span: Span,
358 pub crate_name: Symbol,
359}
360
361#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
StableCrateIdCollision {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
StableCrateIdCollision {
span: __binding_0,
crate_name0: __binding_1,
crate_name1: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found crates `{$crate_name0}` and `{$crate_name1}` with colliding `StableCrateId` values")));
;
diag.arg("crate_name0", __binding_1);
diag.arg("crate_name1", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
362#[diag("found crates `{$crate_name0}` and `{$crate_name1}` with colliding `StableCrateId` values")]
363pub(crate) struct StableCrateIdCollision {
364 #[primary_span]
365 pub span: Span,
366 pub crate_name0: Symbol,
367 pub crate_name1: Symbol,
368}
369
370#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for DlError {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
DlError {
span: __binding_0, path: __binding_1, err: __binding_2 } =>
{
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$path}{$err}")));
;
diag.arg("path", __binding_1);
diag.arg("err", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
371#[diag("{$path}{$err}")]
372pub(crate) struct DlError {
373 #[primary_span]
374 pub span: Span,
375 pub path: String,
376 pub err: String,
377}
378
379#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for NewerCrateVersion {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
NewerCrateVersion {
span: __binding_0,
crate_name: __binding_1,
add_info: __binding_2,
found_crates: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found possibly newer version of crate `{$crate_name}`{$add_info}")));
diag.code(E0460);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("perhaps that crate needs to be recompiled?")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the following crate versions were found:{$found_crates}")));
;
diag.arg("crate_name", __binding_1);
diag.arg("add_info", __binding_2);
diag.arg("found_crates", __binding_3);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
380#[diag("found possibly newer version of crate `{$crate_name}`{$add_info}", code = E0460)]
381#[note("perhaps that crate needs to be recompiled?")]
382#[note("the following crate versions were found:{$found_crates}")]
383pub(crate) struct NewerCrateVersion {
384 #[primary_span]
385 pub span: Span,
386 pub crate_name: Symbol,
387 pub add_info: String,
388 pub found_crates: String,
389}
390
391#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
NoCrateWithTriple<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
NoCrateWithTriple {
span: __binding_0,
crate_name: __binding_1,
locator_triple: __binding_2,
add_info: __binding_3,
found_crates: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("couldn't find crate `{$crate_name}` with expected target triple {$locator_triple}{$add_info}")));
diag.code(E0461);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the following crate versions were found:{$found_crates}")));
;
diag.arg("crate_name", __binding_1);
diag.arg("locator_triple", __binding_2);
diag.arg("add_info", __binding_3);
diag.arg("found_crates", __binding_4);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
392#[diag(
393 "couldn't find crate `{$crate_name}` with expected target triple {$locator_triple}{$add_info}",
394 code = E0461
395)]
396#[note("the following crate versions were found:{$found_crates}")]
397pub(crate) struct NoCrateWithTriple<'a> {
398 #[primary_span]
399 pub span: Span,
400 pub crate_name: Symbol,
401 pub locator_triple: &'a str,
402 pub add_info: String,
403 pub found_crates: String,
404}
405
406#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for FoundStaticlib {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
FoundStaticlib {
span: __binding_0,
crate_name: __binding_1,
add_info: __binding_2,
found_crates: __binding_3 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found staticlib `{$crate_name}` instead of `rlib` or `dylib`{$add_info}")));
diag.code(E0462);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the following crate versions were found:{$found_crates}")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("please recompile that crate using `--crate-type lib`")));
;
diag.arg("crate_name", __binding_1);
diag.arg("add_info", __binding_2);
diag.arg("found_crates", __binding_3);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
407#[diag("found staticlib `{$crate_name}` instead of `rlib` or `dylib`{$add_info}", code = E0462)]
408#[note("the following crate versions were found:{$found_crates}")]
409#[help("please recompile that crate using `--crate-type lib`")]
410pub(crate) struct FoundStaticlib {
411 #[primary_span]
412 pub span: Span,
413 pub crate_name: Symbol,
414 pub add_info: String,
415 pub found_crates: String,
416}
417
418#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for IncompatibleRustc {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
IncompatibleRustc {
span: __binding_0,
crate_name: __binding_1,
add_info: __binding_2,
found_crates: __binding_3,
rustc_version: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found crate `{$crate_name}` compiled by an incompatible version of rustc{$add_info}")));
diag.code(E0514);
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the following crate versions were found:{$found_crates}")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("please recompile that crate using this compiler ({$rustc_version}) (consider running `cargo clean` first)")));
;
diag.arg("crate_name", __binding_1);
diag.arg("add_info", __binding_2);
diag.arg("found_crates", __binding_3);
diag.arg("rustc_version", __binding_4);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
419#[diag(
420 "found crate `{$crate_name}` compiled by an incompatible version of rustc{$add_info}",
421 code = E0514
422)]
423#[note("the following crate versions were found:{$found_crates}")]
424#[help(
425 "please recompile that crate using this compiler ({$rustc_version}) \
426 (consider running `cargo clean` first)"
427)]
428pub(crate) struct IncompatibleRustc {
429 #[primary_span]
430 pub span: Span,
431 pub crate_name: Symbol,
432 pub add_info: String,
433 pub found_crates: String,
434 pub rustc_version: String,
435}
436
437pub(crate) struct InvalidMetadataFiles {
438 pub span: Span,
439 pub crate_name: Symbol,
440 pub add_info: String,
441 pub crate_rejections: Vec<String>,
442}
443
444impl Diagnostic<'_> for InvalidMetadataFiles {
445 #[track_caller]
446 fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> {
447 let mut diag = Diag::new(
448 dcx,
449 level,
450 rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found invalid metadata files for crate `{$crate_name}`{$add_info}"))msg!("found invalid metadata files for crate `{$crate_name}`{$add_info}"),
451 );
452 diag.arg("crate_name", self.crate_name);
453 diag.arg("add_info", self.add_info);
454 diag.code(E0786);
455 diag.span(self.span);
456 for crate_rejection in self.crate_rejections {
457 diag.note(crate_rejection);
458 }
459 diag
460 }
461}
462
463pub(crate) struct CannotFindCrate {
464 pub span: Span,
465 pub crate_name: Symbol,
466 pub add_info: String,
467 pub missing_core: bool,
468 pub current_crate: String,
469 pub is_nightly_build: bool,
470 pub profiler_runtime: Symbol,
471 pub locator_triple: TargetTuple,
472 pub is_ui_testing: bool,
473 pub is_tier_3: bool,
474}
475
476impl Diagnostic<'_> for CannotFindCrate {
477 #[track_caller]
478 fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> {
479 let mut diag =
480 Diag::new(dcx, level, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't find crate for `{$crate_name}`{$add_info}"))msg!("can't find crate for `{$crate_name}`{$add_info}"));
481 diag.arg("crate_name", self.crate_name);
482 diag.arg("current_crate", self.current_crate);
483 diag.arg("add_info", self.add_info);
484 diag.arg("locator_triple", self.locator_triple.tuple());
485 diag.code(E0463);
486 diag.span(self.span);
487 if self.crate_name == sym::std || self.crate_name == sym::core {
488 if self.missing_core {
489 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `{$locator_triple}` target may not be installed"))msg!("the `{$locator_triple}` target may not be installed"));
490 } else {
491 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `{$locator_triple}` target may not support the standard library"))msg!(
492 "the `{$locator_triple}` target may not support the standard library"
493 ));
494 }
495
496 let has_precompiled_std = !self.is_tier_3;
497
498 if self.missing_core {
499 if "nightly"env!("CFG_RELEASE_CHANNEL") == "dev" && !self.is_ui_testing {
500 diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider adding the standard library to the sysroot with `x build library --target {$locator_triple}`"))msg!(
502 "consider adding the standard library to the sysroot with \
503 `x build library --target {$locator_triple}`"
504 ));
505 } else if has_precompiled_std {
506 diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider downloading the target with `rustup target add {$locator_triple}`"))msg!(
510 "consider downloading the target with `rustup target add {$locator_triple}`"
511 ));
512 }
513 }
514
515 if !self.missing_core && self.span.is_dummy() {
520 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`std` is required by `{$current_crate}` because it does not declare `#![no_std]`"))msg!(
521 "`std` is required by `{$current_crate}` because it does not declare \
522 `#![no_std]`"
523 ));
524 }
525 if self.is_nightly_build || !has_precompiled_std {
528 if self.crate_name == sym::core && self.missing_core {
529 diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider building the `core` library from source with `cargo build -Zbuild-std=core`"))msg!(
530 "consider building the `core` library from source with \
531 `cargo build -Zbuild-std=core`"
532 ));
533 } else {
534 diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider building the standard library from source with `cargo build -Zbuild-std`"))msg!(
535 "consider building the standard library from source with \
536 `cargo build -Zbuild-std`"
537 ));
538 }
539 }
540 } else if self.crate_name == self.profiler_runtime {
541 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the compiler may have been built without the profiler runtime"))msg!("the compiler may have been built without the profiler runtime"));
542 } else if self.crate_name.as_str().starts_with("rustc_") {
543 diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`"))msg!(
544 "maybe you need to install the missing components with: \
545 `rustup component add rust-src rustc-dev llvm-tools-preview`"
546 ));
547 } else if rustc_session::utils::was_invoked_from_cargo() {
548 diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("check the `[dependencies]` section in `Cargo.toml` for the missing crate or use `cargo add {$crate_name}` to add it to your `Cargo.toml`"))msg!(
549 "check the `[dependencies]` section in `Cargo.toml` for the missing crate or use \
550 `cargo add {$crate_name}` to add it to your `Cargo.toml`"
551 ));
552 }
553 diag.span_label(self.span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't find crate"))msg!("can't find crate"));
554 diag
555 }
556}
557
558#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
CrateLocationUnknownType<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
CrateLocationUnknownType {
span: __binding_0,
path: __binding_1,
crate_name: __binding_2,
dll_prefix: __binding_3,
dll_suffix: __binding_4 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("extern location for `{$crate_name}` is of an unknown type at `{$path}`")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("file name should be `lib*.rlib` or `{$dll_prefix}*{$dll_suffix}`")));
;
diag.arg("path", __binding_1);
diag.arg("crate_name", __binding_2);
diag.arg("dll_prefix", __binding_3);
diag.arg("dll_suffix", __binding_4);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
559#[diag("extern location for `{$crate_name}` is of an unknown type at `{$path}`")]
560#[help("file name should be `lib*.rlib` or `{$dll_prefix}*{$dll_suffix}`")]
561pub(crate) struct CrateLocationUnknownType<'a> {
562 #[primary_span]
563 pub span: Span,
564 pub path: &'a Path,
565 pub crate_name: Symbol,
566 pub dll_prefix: &'a str,
567 pub dll_suffix: &'a str,
568}
569
570#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for WasmCAbi {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
WasmCAbi { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("older versions of the `wasm-bindgen` crate are incompatible with current versions of Rust; please update to `wasm-bindgen` v0.2.88")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
571#[diag(
572 "older versions of the `wasm-bindgen` crate are incompatible with current versions of Rust; \
573 please update to `wasm-bindgen` v0.2.88"
574)]
575pub(crate) struct WasmCAbi {
576 #[primary_span]
577 pub span: Span,
578}
579
580#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
UnknownTargetModifierUnsafeAllowed {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnknownTargetModifierUnsafeAllowed { flag_name: __binding_0
} => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown target modifier `{$flag_name}`, requested by `-Cunsafe-allow-abi-mismatch={$flag_name}`")));
;
diag.arg("flag_name", __binding_0);
diag
}
}
}
}
};Diagnostic)]
581#[diag(
582 "unknown target modifier `{$flag_name}`, requested by \
583 `-Cunsafe-allow-abi-mismatch={$flag_name}`"
584)]
585pub(crate) struct UnknownTargetModifierUnsafeAllowed {
586 pub flag_name: String,
587}
588
589#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
AsyncDropTypesInDependency {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
AsyncDropTypesInDependency {
span: __binding_0,
extern_crate: __binding_1,
local_crate: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found async drop types in dependency `{$extern_crate}`, but `async_drop` feature is disabled for `{$local_crate}`")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if async drop type will be dropped in a crate without `feature(async_drop)`, sync `Drop` will be used")));
;
diag.arg("extern_crate", __binding_1);
diag.arg("local_crate", __binding_2);
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
590#[diag(
591 "found async drop types in dependency `{$extern_crate}`, but `async_drop` feature is disabled \
592 for `{$local_crate}`"
593)]
594#[help(
595 "if async drop type will be dropped in a crate without `feature(async_drop)`, sync `Drop` will \
596 be used"
597)]
598pub(crate) struct AsyncDropTypesInDependency {
599 #[primary_span]
600 pub span: Span,
601 pub extern_crate: Symbol,
602 pub local_crate: Symbol,
603}
604
605#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for RawDylibMalformed {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
RawDylibMalformed { span: __binding_0 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("link name must be well-formed if link kind is `raw-dylib`")));
;
diag.span(__binding_0);
diag
}
}
}
}
};Diagnostic)]
606#[diag("link name must be well-formed if link kind is `raw-dylib`")]
607pub(crate) struct RawDylibMalformed {
608 #[primary_span]
609 pub span: Span,
610}
611
612#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
UnusedCrateDependency {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
UnusedCrateDependency {
extern_crate: __binding_0, local_crate: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("extern crate `{$extern_crate}` is unused in crate `{$local_crate}`")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the dependency or add `use {$extern_crate} as _;` to the crate root")));
;
diag.arg("extern_crate", __binding_0);
diag.arg("local_crate", __binding_1);
diag
}
}
}
}
};Diagnostic)]
613#[diag("extern crate `{$extern_crate}` is unused in crate `{$local_crate}`")]
614#[help("remove the dependency or add `use {$extern_crate} as _;` to the crate root")]
615pub(crate) struct UnusedCrateDependency {
616 pub extern_crate: Symbol,
617 pub local_crate: Symbol,
618}
619
620#[derive(const _: () =
{
impl<'_sess> rustc_errors::Diagnostic<'_sess> for
MitigationLessStrictInDependency {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
MitigationLessStrictInDependency {
mitigation_name: __binding_0,
mitigation_level: __binding_1,
extern_crate: __binding_2 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("your program uses the crate `{$extern_crate}`, that is not compiled with `{$mitigation_name}{$mitigation_level}` enabled")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("recompile `{$extern_crate}` with `{$mitigation_name}{$mitigation_level}` enabled, or use `-Z allow-partial-mitigations={$mitigation_name}` to allow creating an artifact that has the mitigation partially enabled")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("it is possible to disable `-Z allow-partial-mitigations={$mitigation_name}` via `-Z deny-partial-mitigations={$mitigation_name}`")));
;
diag.arg("mitigation_name", __binding_0);
diag.arg("mitigation_level", __binding_1);
diag.arg("extern_crate", __binding_2);
diag
}
}
}
}
};Diagnostic)]
621#[diag(
622 "your program uses the crate `{$extern_crate}`, that is not compiled with \
623 `{$mitigation_name}{$mitigation_level}` enabled"
624)]
625#[note(
626 "recompile `{$extern_crate}` with `{$mitigation_name}{$mitigation_level}` enabled, or use \
627 `-Z allow-partial-mitigations={$mitigation_name}` to allow creating an artifact that has the \
628 mitigation partially enabled"
629)]
630#[help(
631 "it is possible to disable `-Z allow-partial-mitigations={$mitigation_name}` via \
632 `-Z deny-partial-mitigations={$mitigation_name}`"
633)]
634pub(crate) struct MitigationLessStrictInDependency {
635 pub mitigation_name: String,
636 pub mitigation_level: String,
637 pub extern_crate: Symbol,
638}
639
640#[derive(const _: () =
{
impl<'_sess, 'a> rustc_errors::Diagnostic<'_sess> for
StaticLinkingNotSupported<'a> {
#[track_caller]
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
level: rustc_errors::Level) -> rustc_errors::Diag<'_sess> {
match self {
StaticLinkingNotSupported::UserRequested {
lib_name: __binding_0, target: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("static linking of `{$lib_name}` is not supported on `{$target}`")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using dynamic linking instead")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove `kind = \"static\"` and ensure a shared library is available")));
;
diag.arg("lib_name", __binding_0);
diag.arg("target", __binding_1);
diag
}
StaticLinkingNotSupported::FromDependency {
lib_name: __binding_0, target: __binding_1 } => {
let mut diag =
rustc_errors::Diag::new(dcx, level,
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("library `{$lib_name}` is linked statically by a dependency, but `{$target}` requires dynamic linking")));
diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using dynamic linking instead")));
diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ensure a shared library is available")));
;
diag.arg("lib_name", __binding_0);
diag.arg("target", __binding_1);
diag
}
}
}
}
};Diagnostic)]
641pub(crate) enum StaticLinkingNotSupported<'a> {
642 #[diag("static linking of `{$lib_name}` is not supported on `{$target}`")]
643 #[note("using dynamic linking instead")]
644 #[help("remove `kind = \"static\"` and ensure a shared library is available")]
645 UserRequested { lib_name: Symbol, target: &'a str },
646
647 #[diag(
648 "library `{$lib_name}` is linked statically by a dependency, but `{$target}` requires \
649 dynamic linking"
650 )]
651 #[note("using dynamic linking instead")]
652 #[help("ensure a shared library is available")]
653 FromDependency { lib_name: Symbol, target: &'a str },
654}