1use std::collections::btree_map::{
5 Iter as BTreeMapIter, Keys as BTreeMapKeysIter, Values as BTreeMapValuesIter,
6};
7use std::collections::{BTreeMap, BTreeSet};
8use std::ffi::OsStr;
9use std::hash::Hash;
10use std::path::{Path, PathBuf};
11use std::str::{self, FromStr};
12use std::sync::LazyLock;
13use std::{cmp, fs, iter};
14
15use externs::{ExternOpt, split_extern_opt};
16use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
17use rustc_data_structures::stable_hash::{StableHasher, StableOrd};
18use rustc_errors::emitter::HumanReadableErrorType;
19use rustc_errors::{ColorConfig, DiagCtxtFlags};
20use rustc_feature::UnstableFeatures;
21use rustc_hashes::Hash64;
22use rustc_macros::{BlobDecodable, Decodable, Encodable, StableHash};
23use rustc_span::edition::{DEFAULT_EDITION, EDITION_NAME_LIST, Edition, LATEST_STABLE_EDITION};
24use rustc_span::source_map::FilePathMapping;
25use rustc_span::{
26 FileName, RealFileName, RemapPathScopeComponents, SourceFileHashAlgorithm, Symbol, sym,
27};
28use rustc_target::spec::{
29 FramePointer, LinkSelfContainedComponents, LinkerFeatures, PanicStrategy, SplitDebuginfo,
30 Target, TargetTuple,
31};
32use tracing::debug;
33
34pub use crate::config::cfg::{Cfg, CheckCfg, ExpectedValues};
35use crate::config::native_libs::parse_native_libs;
36pub use crate::config::print_request::{PrintKind, PrintRequest};
37use crate::diagnostics::FileWriteFail;
38pub use crate::options::*;
39use crate::search_paths::SearchPath;
40use crate::utils::CanonicalizedPath;
41use crate::{EarlyDiagCtxt, Session, filesearch, lint};
42
43mod cfg;
44mod externs;
45mod native_libs;
46mod print_request;
47pub mod sigpipe;
48
49#[derive(#[automatically_derived]
impl ::core::clone::Clone for Strip {
#[inline]
fn clone(&self) -> Strip { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Strip { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for Strip {
#[inline]
fn eq(&self, other: &Strip) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for Strip {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for Strip {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
Strip::None => "None",
Strip::Debuginfo => "Debuginfo",
Strip::Symbols => "Symbols",
})
}
}Debug)]
51pub enum Strip {
52 None,
54
55 Debuginfo,
57
58 Symbols,
60}
61
62#[derive(#[automatically_derived]
impl ::core::clone::Clone for CFGuard {
#[inline]
fn clone(&self) -> CFGuard { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for CFGuard { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for CFGuard {
#[inline]
fn eq(&self, other: &CFGuard) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for CFGuard {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for CFGuard {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
CFGuard::Disabled => "Disabled",
CFGuard::NoChecks => "NoChecks",
CFGuard::Checks => "Checks",
})
}
}Debug)]
64pub enum CFGuard {
65 Disabled,
67
68 NoChecks,
70
71 Checks,
73}
74
75#[derive(#[automatically_derived]
impl ::core::clone::Clone for CFProtection {
#[inline]
fn clone(&self) -> CFProtection { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for CFProtection { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for CFProtection {
#[inline]
fn eq(&self, other: &CFProtection) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for CFProtection {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for CFProtection {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
CFProtection::None => "None",
CFProtection::Branch => "Branch",
CFProtection::Return => "Return",
CFProtection::Full => "Full",
})
}
}Debug)]
77pub enum CFProtection {
78 None,
80
81 Branch,
83
84 Return,
86
87 Full,
89}
90
91#[derive(#[automatically_derived]
impl ::core::clone::Clone for OptLevel {
#[inline]
fn clone(&self) -> OptLevel { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for OptLevel { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for OptLevel {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
OptLevel::No => "No",
OptLevel::Less => "Less",
OptLevel::More => "More",
OptLevel::Aggressive => "Aggressive",
OptLevel::Size => "Size",
OptLevel::SizeMin => "SizeMin",
})
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for OptLevel {
#[inline]
fn eq(&self, other: &OptLevel) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for OptLevel {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for OptLevel {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
OptLevel::No => {}
OptLevel::Less => {}
OptLevel::More => {}
OptLevel::Aggressive => {}
OptLevel::Size => {}
OptLevel::SizeMin => {}
}
}
}
};StableHash, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for OptLevel {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
OptLevel::No => { 0usize }
OptLevel::Less => { 1usize }
OptLevel::More => { 2usize }
OptLevel::Aggressive => { 3usize }
OptLevel::Size => { 4usize }
OptLevel::SizeMin => { 5usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
OptLevel::No => {}
OptLevel::Less => {}
OptLevel::More => {}
OptLevel::Aggressive => {}
OptLevel::Size => {}
OptLevel::SizeMin => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for OptLevel {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { OptLevel::No }
1usize => { OptLevel::Less }
2usize => { OptLevel::More }
3usize => { OptLevel::Aggressive }
4usize => { OptLevel::Size }
5usize => { OptLevel::SizeMin }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `OptLevel`, expected 0..6, actual {0}",
n));
}
}
}
}
};Decodable)]
92pub enum OptLevel {
93 No,
95 Less,
97 More,
99 Aggressive,
101 Size,
103 SizeMin,
105}
106
107#[derive(#[automatically_derived]
impl ::core::clone::Clone for Lto {
#[inline]
fn clone(&self) -> Lto {
match self {
Lto::No => Lto::No,
Lto::Thin => Lto::Thin,
Lto::ThinLocal => Lto::ThinLocal,
Lto::Fat => Lto::Fat,
}
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for Lto {
#[inline]
fn eq(&self, other: &Lto) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for Lto {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
Lto::No => { 0usize }
Lto::Thin => { 1usize }
Lto::ThinLocal => { 2usize }
Lto::Fat => { 3usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
Lto::No => {}
Lto::Thin => {}
Lto::ThinLocal => {}
Lto::Fat => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for Lto {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { Lto::No }
1usize => { Lto::Thin }
2usize => { Lto::ThinLocal }
3usize => { Lto::Fat }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Lto`, expected 0..4, actual {0}",
n));
}
}
}
}
};Decodable)]
112pub enum Lto {
113 No,
115
116 Thin,
118
119 ThinLocal,
122
123 Fat,
125}
126
127#[derive(#[automatically_derived]
impl ::core::clone::Clone for LtoCli {
#[inline]
fn clone(&self) -> LtoCli { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for LtoCli { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for LtoCli {
#[inline]
fn eq(&self, other: &LtoCli) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for LtoCli {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for LtoCli {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
LtoCli::No => "No",
LtoCli::Yes => "Yes",
LtoCli::NoParam => "NoParam",
LtoCli::Thin => "Thin",
LtoCli::Fat => "Fat",
LtoCli::Unspecified => "Unspecified",
})
}
}Debug)]
129pub enum LtoCli {
130 No,
132 Yes,
134 NoParam,
136 Thin,
138 Fat,
140 Unspecified,
142}
143
144#[derive(#[automatically_derived]
impl ::core::clone::Clone for InstrumentCoverage {
#[inline]
fn clone(&self) -> InstrumentCoverage { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for InstrumentCoverage { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for InstrumentCoverage {
#[inline]
fn eq(&self, other: &InstrumentCoverage) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for InstrumentCoverage {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for InstrumentCoverage {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
InstrumentCoverage::No => "No",
InstrumentCoverage::Yes => "Yes",
})
}
}Debug)]
146pub enum InstrumentCoverage {
147 No,
149 Yes,
151}
152
153#[derive(#[automatically_derived]
impl ::core::clone::Clone for CoverageOptions {
#[inline]
fn clone(&self) -> CoverageOptions {
let _: ::core::clone::AssertParamIsClone<CoverageLevel>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for CoverageOptions { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for CoverageOptions {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"CoverageOptions", "level", &self.level,
"discard_all_spans_in_codegen",
&&self.discard_all_spans_in_codegen)
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for CoverageOptions {
#[inline]
fn eq(&self, other: &CoverageOptions) -> bool {
self.discard_all_spans_in_codegen ==
other.discard_all_spans_in_codegen &&
self.level == other.level
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for CoverageOptions {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<CoverageLevel>;
let _: ::core::cmp::AssertParamIsEq<bool>;
}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for CoverageOptions {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.level, state);
::core::hash::Hash::hash(&self.discard_all_spans_in_codegen, state)
}
}Hash, #[automatically_derived]
impl ::core::default::Default for CoverageOptions {
#[inline]
fn default() -> CoverageOptions {
CoverageOptions {
level: ::core::default::Default::default(),
discard_all_spans_in_codegen: ::core::default::Default::default(),
}
}
}Default)]
155pub struct CoverageOptions {
156 pub level: CoverageLevel,
157
158 pub discard_all_spans_in_codegen: bool,
164}
165
166#[derive(#[automatically_derived]
impl ::core::clone::Clone for CoverageLevel {
#[inline]
fn clone(&self) -> CoverageLevel { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for CoverageLevel { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for CoverageLevel {
#[inline]
fn eq(&self, other: &CoverageLevel) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for CoverageLevel {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for CoverageLevel {
#[inline]
fn partial_cmp(&self, other: &CoverageLevel)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for CoverageLevel {
#[inline]
fn cmp(&self, other: &CoverageLevel) -> ::core::cmp::Ordering {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr)
}
}Ord, #[automatically_derived]
impl ::core::hash::Hash for CoverageLevel {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for CoverageLevel {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
CoverageLevel::Block => "Block",
CoverageLevel::Branch => "Branch",
CoverageLevel::Condition => "Condition",
})
}
}Debug, #[automatically_derived]
impl ::core::default::Default for CoverageLevel {
#[inline]
fn default() -> CoverageLevel { Self::Block }
}Default)]
168pub enum CoverageLevel {
169 #[default]
171 Block,
172 Branch,
174 Condition,
190}
191
192#[derive(#[automatically_derived]
impl ::core::clone::Clone for Offload {
#[inline]
fn clone(&self) -> Offload {
match self {
Offload::Device => Offload::Device,
Offload::Host(__self_0) =>
Offload::Host(::core::clone::Clone::clone(__self_0)),
Offload::Test => Offload::Test,
}
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for Offload {
#[inline]
fn eq(&self, other: &Offload) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(Offload::Host(__self_0), Offload::Host(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for Offload {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
Offload::Host(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
_ => {}
}
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for Offload {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Offload::Device => ::core::fmt::Formatter::write_str(f, "Device"),
Offload::Host(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Host",
&__self_0),
Offload::Test => ::core::fmt::Formatter::write_str(f, "Test"),
}
}
}Debug, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for Offload {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
Offload::Device => { 0usize }
Offload::Host(ref __binding_0) => { 1usize }
Offload::Test => { 2usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
Offload::Device => {}
Offload::Host(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
Offload::Test => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for Offload {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { Offload::Device }
1usize => {
Offload::Host(::rustc_serialize::Decodable::decode(__decoder))
}
2usize => { Offload::Test }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Offload`, expected 0..3, actual {0}",
n));
}
}
}
}
};Decodable)]
194pub enum Offload {
195 Device,
197 Host(String),
199 Test,
201}
202
203#[derive(#[automatically_derived]
impl ::core::marker::Copy for CodegenRetagOptions { }Copy, #[automatically_derived]
impl ::core::clone::Clone for CodegenRetagOptions {
#[inline]
fn clone(&self) -> CodegenRetagOptions {
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for CodegenRetagOptions {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"CodegenRetagOptions", "no_precise_im", &self.no_precise_im,
"no_precise_pin", &&self.no_precise_pin)
}
}Debug, #[automatically_derived]
impl ::core::default::Default for CodegenRetagOptions {
#[inline]
fn default() -> CodegenRetagOptions {
CodegenRetagOptions {
no_precise_im: ::core::default::Default::default(),
no_precise_pin: ::core::default::Default::default(),
}
}
}Default, #[automatically_derived]
impl ::core::cmp::PartialEq for CodegenRetagOptions {
#[inline]
fn eq(&self, other: &CodegenRetagOptions) -> bool {
self.no_precise_im == other.no_precise_im &&
self.no_precise_pin == other.no_precise_pin
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for CodegenRetagOptions {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.no_precise_im, state);
::core::hash::Hash::hash(&self.no_precise_pin, state)
}
}Hash, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for CodegenRetagOptions {
fn encode(&self, __encoder: &mut __E) {
match *self {
CodegenRetagOptions {
no_precise_im: ref __binding_0,
no_precise_pin: ref __binding_1 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for CodegenRetagOptions {
fn decode(__decoder: &mut __D) -> Self {
CodegenRetagOptions {
no_precise_im: ::rustc_serialize::Decodable::decode(__decoder),
no_precise_pin: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable)]
205pub struct CodegenRetagOptions {
206 pub no_precise_im: bool,
208 pub no_precise_pin: bool,
210}
211
212#[derive(#[automatically_derived]
impl ::core::clone::Clone for AutoDiff {
#[inline]
fn clone(&self) -> AutoDiff {
match self {
AutoDiff::Enable => AutoDiff::Enable,
AutoDiff::PrintTA => AutoDiff::PrintTA,
AutoDiff::PrintTAFn(__self_0) =>
AutoDiff::PrintTAFn(::core::clone::Clone::clone(__self_0)),
AutoDiff::PrintAA => AutoDiff::PrintAA,
AutoDiff::PrintPerf => AutoDiff::PrintPerf,
AutoDiff::PrintSteps => AutoDiff::PrintSteps,
AutoDiff::PrintModBefore => AutoDiff::PrintModBefore,
AutoDiff::PrintModAfter => AutoDiff::PrintModAfter,
AutoDiff::PrintModFinal => AutoDiff::PrintModFinal,
AutoDiff::PrintPasses => AutoDiff::PrintPasses,
AutoDiff::NoPostopt => AutoDiff::NoPostopt,
AutoDiff::LooseTypes => AutoDiff::LooseTypes,
AutoDiff::Inline => AutoDiff::Inline,
AutoDiff::NoTT => AutoDiff::NoTT,
}
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for AutoDiff {
#[inline]
fn eq(&self, other: &AutoDiff) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(AutoDiff::PrintTAFn(__self_0), AutoDiff::PrintTAFn(__arg1_0))
=> __self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for AutoDiff {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
AutoDiff::PrintTAFn(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
_ => {}
}
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for AutoDiff {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
AutoDiff::Enable =>
::core::fmt::Formatter::write_str(f, "Enable"),
AutoDiff::PrintTA =>
::core::fmt::Formatter::write_str(f, "PrintTA"),
AutoDiff::PrintTAFn(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"PrintTAFn", &__self_0),
AutoDiff::PrintAA =>
::core::fmt::Formatter::write_str(f, "PrintAA"),
AutoDiff::PrintPerf =>
::core::fmt::Formatter::write_str(f, "PrintPerf"),
AutoDiff::PrintSteps =>
::core::fmt::Formatter::write_str(f, "PrintSteps"),
AutoDiff::PrintModBefore =>
::core::fmt::Formatter::write_str(f, "PrintModBefore"),
AutoDiff::PrintModAfter =>
::core::fmt::Formatter::write_str(f, "PrintModAfter"),
AutoDiff::PrintModFinal =>
::core::fmt::Formatter::write_str(f, "PrintModFinal"),
AutoDiff::PrintPasses =>
::core::fmt::Formatter::write_str(f, "PrintPasses"),
AutoDiff::NoPostopt =>
::core::fmt::Formatter::write_str(f, "NoPostopt"),
AutoDiff::LooseTypes =>
::core::fmt::Formatter::write_str(f, "LooseTypes"),
AutoDiff::Inline =>
::core::fmt::Formatter::write_str(f, "Inline"),
AutoDiff::NoTT => ::core::fmt::Formatter::write_str(f, "NoTT"),
}
}
}Debug, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for AutoDiff {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
AutoDiff::Enable => { 0usize }
AutoDiff::PrintTA => { 1usize }
AutoDiff::PrintTAFn(ref __binding_0) => { 2usize }
AutoDiff::PrintAA => { 3usize }
AutoDiff::PrintPerf => { 4usize }
AutoDiff::PrintSteps => { 5usize }
AutoDiff::PrintModBefore => { 6usize }
AutoDiff::PrintModAfter => { 7usize }
AutoDiff::PrintModFinal => { 8usize }
AutoDiff::PrintPasses => { 9usize }
AutoDiff::NoPostopt => { 10usize }
AutoDiff::LooseTypes => { 11usize }
AutoDiff::Inline => { 12usize }
AutoDiff::NoTT => { 13usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
AutoDiff::Enable => {}
AutoDiff::PrintTA => {}
AutoDiff::PrintTAFn(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
AutoDiff::PrintAA => {}
AutoDiff::PrintPerf => {}
AutoDiff::PrintSteps => {}
AutoDiff::PrintModBefore => {}
AutoDiff::PrintModAfter => {}
AutoDiff::PrintModFinal => {}
AutoDiff::PrintPasses => {}
AutoDiff::NoPostopt => {}
AutoDiff::LooseTypes => {}
AutoDiff::Inline => {}
AutoDiff::NoTT => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for AutoDiff {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { AutoDiff::Enable }
1usize => { AutoDiff::PrintTA }
2usize => {
AutoDiff::PrintTAFn(::rustc_serialize::Decodable::decode(__decoder))
}
3usize => { AutoDiff::PrintAA }
4usize => { AutoDiff::PrintPerf }
5usize => { AutoDiff::PrintSteps }
6usize => { AutoDiff::PrintModBefore }
7usize => { AutoDiff::PrintModAfter }
8usize => { AutoDiff::PrintModFinal }
9usize => { AutoDiff::PrintPasses }
10usize => { AutoDiff::NoPostopt }
11usize => { AutoDiff::LooseTypes }
12usize => { AutoDiff::Inline }
13usize => { AutoDiff::NoTT }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `AutoDiff`, expected 0..14, actual {0}",
n));
}
}
}
}
};Decodable)]
214pub enum AutoDiff {
215 Enable,
217
218 PrintTA,
220 PrintTAFn(String),
222 PrintAA,
224 PrintPerf,
226 PrintSteps,
228 PrintModBefore,
230 PrintModAfter,
232 PrintModFinal,
234
235 PrintPasses,
237 NoPostopt,
239 LooseTypes,
242 Inline,
244 NoTT,
246}
247
248#[derive(#[automatically_derived]
impl ::core::clone::Clone for AnnotateMoves {
#[inline]
fn clone(&self) -> AnnotateMoves {
let _: ::core::clone::AssertParamIsClone<Option<u64>>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for AnnotateMoves { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for AnnotateMoves {
#[inline]
fn eq(&self, other: &AnnotateMoves) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(AnnotateMoves::Enabled(__self_0),
AnnotateMoves::Enabled(__arg1_0)) => __self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for AnnotateMoves {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
AnnotateMoves::Enabled(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
_ => {}
}
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for AnnotateMoves {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
AnnotateMoves::Disabled =>
::core::fmt::Formatter::write_str(f, "Disabled"),
AnnotateMoves::Enabled(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Enabled", &__self_0),
}
}
}Debug)]
250pub enum AnnotateMoves {
251 Disabled,
253 Enabled(Option<u64>),
256}
257
258#[derive(#[automatically_derived]
impl ::core::clone::Clone for InstrumentMcount {
#[inline]
fn clone(&self) -> InstrumentMcount { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for InstrumentMcount { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for InstrumentMcount {
#[inline]
fn eq(&self, other: &InstrumentMcount) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for InstrumentMcount {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for InstrumentMcount {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
InstrumentMcount::Disabled => "Disabled",
InstrumentMcount::Mcount => "Mcount",
InstrumentMcount::Fentry => "Fentry",
})
}
}Debug, #[automatically_derived]
impl ::core::hash::Hash for InstrumentMcount {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash)]
260pub enum InstrumentMcount {
261 Disabled,
263 Mcount,
265 Fentry,
267}
268
269#[derive(#[automatically_derived]
impl ::core::clone::Clone for InstrumentXRay {
#[inline]
fn clone(&self) -> InstrumentXRay {
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<Option<usize>>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for InstrumentXRay { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for InstrumentXRay {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["always", "never", "ignore_loops", "instruction_threshold",
"skip_entry", "skip_exit"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.always, &self.never, &self.ignore_loops,
&self.instruction_threshold, &self.skip_entry,
&&self.skip_exit];
::core::fmt::Formatter::debug_struct_fields_finish(f,
"InstrumentXRay", names, values)
}
}Debug, #[automatically_derived]
impl ::core::default::Default for InstrumentXRay {
#[inline]
fn default() -> InstrumentXRay {
InstrumentXRay {
always: ::core::default::Default::default(),
never: ::core::default::Default::default(),
ignore_loops: ::core::default::Default::default(),
instruction_threshold: ::core::default::Default::default(),
skip_entry: ::core::default::Default::default(),
skip_exit: ::core::default::Default::default(),
}
}
}Default, #[automatically_derived]
impl ::core::cmp::PartialEq for InstrumentXRay {
#[inline]
fn eq(&self, other: &InstrumentXRay) -> bool {
self.always == other.always && self.never == other.never &&
self.ignore_loops == other.ignore_loops &&
self.skip_entry == other.skip_entry &&
self.skip_exit == other.skip_exit &&
self.instruction_threshold == other.instruction_threshold
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for InstrumentXRay {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<bool>;
let _: ::core::cmp::AssertParamIsEq<Option<usize>>;
}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for InstrumentXRay {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.always, state);
::core::hash::Hash::hash(&self.never, state);
::core::hash::Hash::hash(&self.ignore_loops, state);
::core::hash::Hash::hash(&self.instruction_threshold, state);
::core::hash::Hash::hash(&self.skip_entry, state);
::core::hash::Hash::hash(&self.skip_exit, state)
}
}Hash)]
271pub struct InstrumentXRay {
272 pub always: bool,
274 pub never: bool,
276 pub ignore_loops: bool,
279 pub instruction_threshold: Option<usize>,
282 pub skip_entry: bool,
284 pub skip_exit: bool,
286}
287
288#[derive(#[automatically_derived]
impl ::core::clone::Clone for LinkerPluginLto {
#[inline]
fn clone(&self) -> LinkerPluginLto {
match self {
LinkerPluginLto::LinkerPlugin(__self_0) =>
LinkerPluginLto::LinkerPlugin(::core::clone::Clone::clone(__self_0)),
LinkerPluginLto::LinkerPluginAuto =>
LinkerPluginLto::LinkerPluginAuto,
LinkerPluginLto::Disabled => LinkerPluginLto::Disabled,
}
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for LinkerPluginLto {
#[inline]
fn eq(&self, other: &LinkerPluginLto) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(LinkerPluginLto::LinkerPlugin(__self_0),
LinkerPluginLto::LinkerPlugin(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for LinkerPluginLto {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
LinkerPluginLto::LinkerPlugin(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
_ => {}
}
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for LinkerPluginLto {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
LinkerPluginLto::LinkerPlugin(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"LinkerPlugin", &__self_0),
LinkerPluginLto::LinkerPluginAuto =>
::core::fmt::Formatter::write_str(f, "LinkerPluginAuto"),
LinkerPluginLto::Disabled =>
::core::fmt::Formatter::write_str(f, "Disabled"),
}
}
}Debug)]
289pub enum LinkerPluginLto {
290 LinkerPlugin(PathBuf),
291 LinkerPluginAuto,
292 Disabled,
293}
294
295impl LinkerPluginLto {
296 pub fn enabled(&self) -> bool {
297 match *self {
298 LinkerPluginLto::LinkerPlugin(_) | LinkerPluginLto::LinkerPluginAuto => true,
299 LinkerPluginLto::Disabled => false,
300 }
301 }
302}
303
304#[derive(#[automatically_derived]
impl ::core::default::Default for LinkSelfContained {
#[inline]
fn default() -> LinkSelfContained {
LinkSelfContained {
explicitly_set: ::core::default::Default::default(),
enabled_components: ::core::default::Default::default(),
disabled_components: ::core::default::Default::default(),
}
}
}Default, #[automatically_derived]
impl ::core::clone::Clone for LinkSelfContained {
#[inline]
fn clone(&self) -> LinkSelfContained {
LinkSelfContained {
explicitly_set: ::core::clone::Clone::clone(&self.explicitly_set),
enabled_components: ::core::clone::Clone::clone(&self.enabled_components),
disabled_components: ::core::clone::Clone::clone(&self.disabled_components),
}
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for LinkSelfContained {
#[inline]
fn eq(&self, other: &LinkSelfContained) -> bool {
self.explicitly_set == other.explicitly_set &&
self.enabled_components == other.enabled_components &&
self.disabled_components == other.disabled_components
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for LinkSelfContained {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"LinkSelfContained", "explicitly_set", &self.explicitly_set,
"enabled_components", &self.enabled_components,
"disabled_components", &&self.disabled_components)
}
}Debug)]
320pub struct LinkSelfContained {
321 pub explicitly_set: Option<bool>,
324
325 enabled_components: LinkSelfContainedComponents,
328
329 disabled_components: LinkSelfContainedComponents,
332}
333
334impl LinkSelfContained {
335 pub(crate) fn handle_cli_component(&mut self, component: &str) -> Option<()> {
338 if let Some(component_to_enable) = component.strip_prefix('+') {
343 self.explicitly_set = None;
344 self.enabled_components
345 .insert(LinkSelfContainedComponents::from_str(component_to_enable).ok()?);
346 Some(())
347 } else if let Some(component_to_disable) = component.strip_prefix('-') {
348 self.explicitly_set = None;
349 self.disabled_components
350 .insert(LinkSelfContainedComponents::from_str(component_to_disable).ok()?);
351 Some(())
352 } else {
353 None
354 }
355 }
356
357 pub(crate) fn set_all_explicitly(&mut self, enabled: bool) {
360 self.explicitly_set = Some(enabled);
361
362 if enabled {
363 self.enabled_components = LinkSelfContainedComponents::all();
364 self.disabled_components = LinkSelfContainedComponents::empty();
365 } else {
366 self.enabled_components = LinkSelfContainedComponents::empty();
367 self.disabled_components = LinkSelfContainedComponents::all();
368 }
369 }
370
371 pub fn on() -> Self {
373 let mut on = LinkSelfContained::default();
374 on.set_all_explicitly(true);
375 on
376 }
377
378 fn check_unstable_variants(&self, target_tuple: &TargetTuple) -> Result<(), String> {
382 if self.explicitly_set.is_some() {
383 return Ok(());
384 }
385
386 let has_minus_linker = self.disabled_components.is_linker_enabled();
388 if has_minus_linker && target_tuple.tuple() != "x86_64-unknown-linux-gnu" {
389 return Err(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`-C link-self-contained=-linker` is unstable on the `{0}` target. The `-Z unstable-options` flag must also be passed to use it on this target",
target_tuple))
})format!(
390 "`-C link-self-contained=-linker` is unstable on the `{target_tuple}` \
391 target. The `-Z unstable-options` flag must also be passed to use it on this target",
392 ));
393 }
394
395 let unstable_enabled = self.enabled_components;
397 let unstable_disabled = self.disabled_components - LinkSelfContainedComponents::LINKER;
398 if !unstable_enabled.union(unstable_disabled).is_empty() {
399 return Err(String::from(
400 "only `-C link-self-contained` values `y`/`yes`/`on`/`n`/`no`/`off`/`-linker` \
401 are stable, the `-Z unstable-options` flag must also be passed to use \
402 the unstable values",
403 ));
404 }
405
406 Ok(())
407 }
408
409 pub fn is_linker_enabled(&self) -> bool {
412 self.enabled_components.contains(LinkSelfContainedComponents::LINKER)
413 }
414
415 pub fn is_linker_disabled(&self) -> bool {
418 self.disabled_components.contains(LinkSelfContainedComponents::LINKER)
419 }
420
421 fn check_consistency(&self) -> Option<LinkSelfContainedComponents> {
424 if self.explicitly_set.is_some() {
425 None
426 } else {
427 let common = self.enabled_components.intersection(self.disabled_components);
428 if common.is_empty() { None } else { Some(common) }
429 }
430 }
431}
432
433#[derive(#[automatically_derived]
impl ::core::default::Default for LinkerFeaturesCli {
#[inline]
fn default() -> LinkerFeaturesCli {
LinkerFeaturesCli {
enabled: ::core::default::Default::default(),
disabled: ::core::default::Default::default(),
}
}
}Default, #[automatically_derived]
impl ::core::marker::Copy for LinkerFeaturesCli { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LinkerFeaturesCli {
#[inline]
fn clone(&self) -> LinkerFeaturesCli {
let _: ::core::clone::AssertParamIsClone<LinkerFeatures>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for LinkerFeaturesCli {
#[inline]
fn eq(&self, other: &LinkerFeaturesCli) -> bool {
self.enabled == other.enabled && self.disabled == other.disabled
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for LinkerFeaturesCli {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"LinkerFeaturesCli", "enabled", &self.enabled, "disabled",
&&self.disabled)
}
}Debug)]
442pub struct LinkerFeaturesCli {
443 pub enabled: LinkerFeatures,
445
446 pub disabled: LinkerFeatures,
448}
449
450impl LinkerFeaturesCli {
451 pub(crate) fn handle_cli_feature(&mut self, feature: &str) -> Option<()> {
454 match feature {
460 "+lld" => {
461 self.enabled.insert(LinkerFeatures::LLD);
462 self.disabled.remove(LinkerFeatures::LLD);
463 Some(())
464 }
465 "-lld" => {
466 self.disabled.insert(LinkerFeatures::LLD);
467 self.enabled.remove(LinkerFeatures::LLD);
468 Some(())
469 }
470 _ => None,
471 }
472 }
473
474 pub(crate) fn check_unstable_variants(&self, target_tuple: &TargetTuple) -> Result<(), String> {
479 let has_minus_lld = self.disabled.is_lld_enabled();
481 if has_minus_lld && target_tuple.tuple() != "x86_64-unknown-linux-gnu" {
482 return Err(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`-C linker-features=-lld` is unstable on the `{0}` target. The `-Z unstable-options` flag must also be passed to use it on this target",
target_tuple))
})format!(
483 "`-C linker-features=-lld` is unstable on the `{target_tuple}` \
484 target. The `-Z unstable-options` flag must also be passed to use it on this target",
485 ));
486 }
487
488 let unstable_enabled = self.enabled;
490 let unstable_disabled = self.disabled - LinkerFeatures::LLD;
491 if !unstable_enabled.union(unstable_disabled).is_empty() {
492 let unstable_features: Vec<_> = unstable_enabled
493 .iter()
494 .map(|f| ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("+{0}", f.as_str().unwrap()))
})format!("+{}", f.as_str().unwrap()))
495 .chain(unstable_disabled.iter().map(|f| ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("-{0}", f.as_str().unwrap()))
})format!("-{}", f.as_str().unwrap())))
496 .collect();
497 return Err(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`-C linker-features={0}` is unstable, and also requires the `-Z unstable-options` flag to be used",
unstable_features.join(",")))
})format!(
498 "`-C linker-features={}` is unstable, and also requires the \
499 `-Z unstable-options` flag to be used",
500 unstable_features.join(","),
501 ));
502 }
503
504 Ok(())
505 }
506}
507
508#[derive(#[automatically_derived]
impl ::core::clone::Clone for IncrementalStateAssertion {
#[inline]
fn clone(&self) -> IncrementalStateAssertion { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for IncrementalStateAssertion { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for IncrementalStateAssertion {
#[inline]
fn eq(&self, other: &IncrementalStateAssertion) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for IncrementalStateAssertion {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for IncrementalStateAssertion {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
IncrementalStateAssertion::Loaded => "Loaded",
IncrementalStateAssertion::NotLoaded => "NotLoaded",
})
}
}Debug)]
510pub enum IncrementalStateAssertion {
511 Loaded,
516 NotLoaded,
518}
519
520#[derive(#[automatically_derived]
impl ::core::marker::Copy for LocationDetail { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LocationDetail {
#[inline]
fn clone(&self) -> LocationDetail {
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for LocationDetail {
#[inline]
fn eq(&self, other: &LocationDetail) -> bool {
self.file == other.file && self.line == other.line &&
self.column == other.column
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for LocationDetail {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.file, state);
::core::hash::Hash::hash(&self.line, state);
::core::hash::Hash::hash(&self.column, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for LocationDetail {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"LocationDetail", "file", &self.file, "line", &self.line,
"column", &&self.column)
}
}Debug)]
522pub struct LocationDetail {
523 pub file: bool,
524 pub line: bool,
525 pub column: bool,
526}
527
528impl LocationDetail {
529 pub(crate) fn all() -> Self {
530 Self { file: true, line: true, column: true }
531 }
532}
533
534#[derive(#[automatically_derived]
impl ::core::marker::Copy for FmtDebug { }Copy, #[automatically_derived]
impl ::core::clone::Clone for FmtDebug {
#[inline]
fn clone(&self) -> FmtDebug { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for FmtDebug {
#[inline]
fn eq(&self, other: &FmtDebug) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for FmtDebug {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for FmtDebug {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
FmtDebug::Full => "Full",
FmtDebug::Shallow => "Shallow",
FmtDebug::None => "None",
})
}
}Debug)]
536pub enum FmtDebug {
537 Full,
539 Shallow,
541 None,
543}
544
545impl FmtDebug {
546 pub(crate) fn all() -> [Symbol; 3] {
547 [sym::full, sym::none, sym::shallow]
548 }
549}
550
551#[derive(#[automatically_derived]
impl ::core::clone::Clone for SwitchWithOptPath {
#[inline]
fn clone(&self) -> SwitchWithOptPath {
match self {
SwitchWithOptPath::Enabled(__self_0) =>
SwitchWithOptPath::Enabled(::core::clone::Clone::clone(__self_0)),
SwitchWithOptPath::Disabled => SwitchWithOptPath::Disabled,
}
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for SwitchWithOptPath {
#[inline]
fn eq(&self, other: &SwitchWithOptPath) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(SwitchWithOptPath::Enabled(__self_0),
SwitchWithOptPath::Enabled(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for SwitchWithOptPath {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
SwitchWithOptPath::Enabled(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
_ => {}
}
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for SwitchWithOptPath {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
SwitchWithOptPath::Enabled(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Enabled", &__self_0),
SwitchWithOptPath::Disabled =>
::core::fmt::Formatter::write_str(f, "Disabled"),
}
}
}Debug, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for SwitchWithOptPath {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
SwitchWithOptPath::Enabled(ref __binding_0) => { 0usize }
SwitchWithOptPath::Disabled => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
SwitchWithOptPath::Enabled(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
SwitchWithOptPath::Disabled => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for SwitchWithOptPath {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
SwitchWithOptPath::Enabled(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => { SwitchWithOptPath::Disabled }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `SwitchWithOptPath`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable)]
552pub enum SwitchWithOptPath {
553 Enabled(Option<PathBuf>),
554 Disabled,
555}
556
557impl SwitchWithOptPath {
558 pub fn enabled(&self) -> bool {
559 match *self {
560 SwitchWithOptPath::Enabled(_) => true,
561 SwitchWithOptPath::Disabled => false,
562 }
563 }
564}
565
566#[derive(#[automatically_derived]
impl ::core::marker::Copy for SymbolManglingVersion { }Copy, #[automatically_derived]
impl ::core::clone::Clone for SymbolManglingVersion {
#[inline]
fn clone(&self) -> SymbolManglingVersion { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for SymbolManglingVersion {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
SymbolManglingVersion::Legacy => "Legacy",
SymbolManglingVersion::V0 => "V0",
SymbolManglingVersion::Hashed => "Hashed",
})
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for SymbolManglingVersion {
#[inline]
fn eq(&self, other: &SymbolManglingVersion) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for SymbolManglingVersion {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for SymbolManglingVersion {
#[inline]
fn partial_cmp(&self, other: &SymbolManglingVersion)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for SymbolManglingVersion {
#[inline]
fn cmp(&self, other: &SymbolManglingVersion) -> ::core::cmp::Ordering {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr)
}
}Ord, #[automatically_derived]
impl ::core::hash::Hash for SymbolManglingVersion {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
SymbolManglingVersion {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
SymbolManglingVersion::Legacy => {}
SymbolManglingVersion::V0 => {}
SymbolManglingVersion::Hashed => {}
}
}
}
};StableHash)]
567#[derive(const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for SymbolManglingVersion {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
SymbolManglingVersion::Legacy => { 0usize }
SymbolManglingVersion::V0 => { 1usize }
SymbolManglingVersion::Hashed => { 2usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
SymbolManglingVersion::Legacy => {}
SymbolManglingVersion::V0 => {}
SymbolManglingVersion::Hashed => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::BlobDecoder> ::rustc_serialize::Decodable<__D>
for SymbolManglingVersion {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { SymbolManglingVersion::Legacy }
1usize => { SymbolManglingVersion::V0 }
2usize => { SymbolManglingVersion::Hashed }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `SymbolManglingVersion`, expected 0..3, actual {0}",
n));
}
}
}
}
};BlobDecodable)]
568pub enum SymbolManglingVersion {
569 Legacy,
570 V0,
571 Hashed,
572}
573
574#[derive(#[automatically_derived]
impl ::core::clone::Clone for DebugInfo {
#[inline]
fn clone(&self) -> DebugInfo { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for DebugInfo { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for DebugInfo {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
DebugInfo::None => "None",
DebugInfo::LineDirectivesOnly => "LineDirectivesOnly",
DebugInfo::LineTablesOnly => "LineTablesOnly",
DebugInfo::Limited => "Limited",
DebugInfo::Full => "Full",
})
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for DebugInfo {
#[inline]
fn eq(&self, other: &DebugInfo) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for DebugInfo {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash)]
575pub enum DebugInfo {
576 None,
577 LineDirectivesOnly,
578 LineTablesOnly,
579 Limited,
580 Full,
581}
582
583#[derive(#[automatically_derived]
impl ::core::clone::Clone for DebugInfoCompression {
#[inline]
fn clone(&self) -> DebugInfoCompression { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for DebugInfoCompression { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for DebugInfoCompression {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
DebugInfoCompression::None => "None",
DebugInfoCompression::Zlib => "Zlib",
DebugInfoCompression::Zstd => "Zstd",
})
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for DebugInfoCompression {
#[inline]
fn eq(&self, other: &DebugInfoCompression) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for DebugInfoCompression {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash)]
584pub enum DebugInfoCompression {
585 None,
586 Zlib,
587 Zstd,
588}
589
590#[derive(#[automatically_derived]
impl ::core::clone::Clone for MirStripDebugInfo {
#[inline]
fn clone(&self) -> MirStripDebugInfo { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for MirStripDebugInfo { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for MirStripDebugInfo {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
MirStripDebugInfo::None => "None",
MirStripDebugInfo::LocalsInTinyFunctions =>
"LocalsInTinyFunctions",
MirStripDebugInfo::AllLocals => "AllLocals",
})
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for MirStripDebugInfo {
#[inline]
fn eq(&self, other: &MirStripDebugInfo) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for MirStripDebugInfo {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash)]
591pub enum MirStripDebugInfo {
592 None,
593 LocalsInTinyFunctions,
594 AllLocals,
595}
596
597#[derive(#[automatically_derived]
impl ::core::clone::Clone for SplitDwarfKind {
#[inline]
fn clone(&self) -> SplitDwarfKind { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for SplitDwarfKind { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for SplitDwarfKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
SplitDwarfKind::Single => "Single",
SplitDwarfKind::Split => "Split",
})
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for SplitDwarfKind {
#[inline]
fn eq(&self, other: &SplitDwarfKind) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for SplitDwarfKind {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for SplitDwarfKind {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
SplitDwarfKind::Single => { 0usize }
SplitDwarfKind::Split => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
SplitDwarfKind::Single => {}
SplitDwarfKind::Split => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for SplitDwarfKind {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { SplitDwarfKind::Single }
1usize => { SplitDwarfKind::Split }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `SplitDwarfKind`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable)]
607pub enum SplitDwarfKind {
608 Single,
611 Split,
614}
615
616impl FromStr for SplitDwarfKind {
617 type Err = ();
618
619 fn from_str(s: &str) -> Result<Self, ()> {
620 Ok(match s {
621 "single" => SplitDwarfKind::Single,
622 "split" => SplitDwarfKind::Split,
623 _ => return Err(()),
624 })
625 }
626}
627
628macro_rules! define_output_types {
629 (
630 $(
631 $(#[doc = $doc:expr])*
632 $Variant:ident => {
633 shorthand: $shorthand:expr,
634 extension: $extension:expr,
635 description: $description:expr,
636 default_filename: $default_filename:expr,
637 is_text: $is_text:expr,
638 compatible_with_cgus_and_single_output: $compatible:expr
639 }
640 ),* $(,)?
641 ) => {
642 #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord, StableHash)]
643 #[derive(Encodable, Decodable)]
644 pub enum OutputType {
645 $(
646 $(#[doc = $doc])*
647 $Variant,
648 )*
649 }
650
651 impl StableOrd for OutputType {
652 const CAN_USE_UNSTABLE_SORT: bool = true;
653
654 const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
656 }
657
658 impl OutputType {
659 pub fn iter_all() -> impl Iterator<Item = OutputType> {
660 static ALL_VARIANTS: &[OutputType] = &[
661 $(
662 OutputType::$Variant,
663 )*
664 ];
665 ALL_VARIANTS.iter().copied()
666 }
667
668 fn is_compatible_with_codegen_units_and_single_output_file(&self) -> bool {
669 match *self {
670 $(
671 OutputType::$Variant => $compatible,
672 )*
673 }
674 }
675
676 pub fn shorthand(&self) -> &'static str {
677 match *self {
678 $(
679 OutputType::$Variant => $shorthand,
680 )*
681 }
682 }
683
684 fn from_shorthand(shorthand: &str) -> Option<Self> {
685 match shorthand {
686 $(
687 s if s == $shorthand => Some(OutputType::$Variant),
688 )*
689 _ => None,
690 }
691 }
692
693 fn shorthands_display() -> String {
694 let shorthands = vec![
695 $(
696 format!("`{}`", $shorthand),
697 )*
698 ];
699 shorthands.join(", ")
700 }
701
702 pub fn extension(&self) -> &'static str {
703 match *self {
704 $(
705 OutputType::$Variant => $extension,
706 )*
707 }
708 }
709
710 pub fn is_text_output(&self) -> bool {
711 match *self {
712 $(
713 OutputType::$Variant => $is_text,
714 )*
715 }
716 }
717
718 pub fn description(&self) -> &'static str {
719 match *self {
720 $(
721 OutputType::$Variant => $description,
722 )*
723 }
724 }
725
726 pub fn default_filename(&self) -> &'static str {
727 match *self {
728 $(
729 OutputType::$Variant => $default_filename,
730 )*
731 }
732 }
733
734
735 }
736 }
737}
738
739#[automatically_derived]
impl ::core::clone::Clone for OutputType {
#[inline]
fn clone(&self) -> OutputType { *self }
}
#[automatically_derived]
impl ::core::marker::Copy for OutputType { }
#[automatically_derived]
impl ::core::marker::StructuralPartialEq for OutputType { }
#[automatically_derived]
impl ::core::cmp::PartialEq for OutputType {
#[inline]
fn eq(&self, other: &OutputType) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}
#[automatically_derived]
impl ::core::cmp::Eq for OutputType {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}
#[automatically_derived]
impl ::core::hash::Hash for OutputType {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}
#[automatically_derived]
impl ::core::fmt::Debug for OutputType {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
OutputType::Assembly => "Assembly",
OutputType::Bitcode => "Bitcode",
OutputType::DepInfo => "DepInfo",
OutputType::Exe => "Exe",
OutputType::LlvmAssembly => "LlvmAssembly",
OutputType::Metadata => "Metadata",
OutputType::Mir => "Mir",
OutputType::Object => "Object",
OutputType::ThinLinkBitcode => "ThinLinkBitcode",
})
}
}
#[automatically_derived]
impl ::core::cmp::PartialOrd for OutputType {
#[inline]
fn partial_cmp(&self, other: &OutputType)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}
#[automatically_derived]
impl ::core::cmp::Ord for OutputType {
#[inline]
fn cmp(&self, other: &OutputType) -> ::core::cmp::Ordering {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr)
}
}
const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for OutputType {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
OutputType::Assembly => {}
OutputType::Bitcode => {}
OutputType::DepInfo => {}
OutputType::Exe => {}
OutputType::LlvmAssembly => {}
OutputType::Metadata => {}
OutputType::Mir => {}
OutputType::Object => {}
OutputType::ThinLinkBitcode => {}
}
}
}
};
impl StableOrd for OutputType {
const CAN_USE_UNSTABLE_SORT: bool = true;
const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
}
impl OutputType {
pub fn iter_all() -> impl Iterator<Item = OutputType> {
static ALL_VARIANTS: &[OutputType] =
&[OutputType::Assembly, OutputType::Bitcode, OutputType::DepInfo,
OutputType::Exe, OutputType::LlvmAssembly,
OutputType::Metadata, OutputType::Mir, OutputType::Object,
OutputType::ThinLinkBitcode];
ALL_VARIANTS.iter().copied()
}
fn is_compatible_with_codegen_units_and_single_output_file(&self)
-> bool {
match *self {
OutputType::Assembly => false,
OutputType::Bitcode => false,
OutputType::DepInfo => true,
OutputType::Exe => true,
OutputType::LlvmAssembly => false,
OutputType::Metadata => true,
OutputType::Mir => false,
OutputType::Object => false,
OutputType::ThinLinkBitcode => false,
}
}
pub fn shorthand(&self) -> &'static str {
match *self {
OutputType::Assembly => "asm",
OutputType::Bitcode => "llvm-bc",
OutputType::DepInfo => "dep-info",
OutputType::Exe => "link",
OutputType::LlvmAssembly => "llvm-ir",
OutputType::Metadata => "metadata",
OutputType::Mir => "mir",
OutputType::Object => "obj",
OutputType::ThinLinkBitcode => "thin-link-bitcode",
}
}
fn from_shorthand(shorthand: &str) -> Option<Self> {
match shorthand {
s if s == "asm" => Some(OutputType::Assembly),
s if s == "llvm-bc" => Some(OutputType::Bitcode),
s if s == "dep-info" => Some(OutputType::DepInfo),
s if s == "link" => Some(OutputType::Exe),
s if s == "llvm-ir" => Some(OutputType::LlvmAssembly),
s if s == "metadata" => Some(OutputType::Metadata),
s if s == "mir" => Some(OutputType::Mir),
s if s == "obj" => Some(OutputType::Object),
s if s == "thin-link-bitcode" =>
Some(OutputType::ThinLinkBitcode),
_ => None,
}
}
fn shorthands_display() -> String {
let shorthands =
::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}`", "asm"))
}),
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}`", "llvm-bc"))
}),
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}`", "dep-info"))
}),
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}`", "link"))
}),
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}`", "llvm-ir"))
}),
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}`", "metadata"))
}),
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}`", "mir"))
}),
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}`", "obj"))
}),
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}`",
"thin-link-bitcode"))
})]));
shorthands.join(", ")
}
pub fn extension(&self) -> &'static str {
match *self {
OutputType::Assembly => "s",
OutputType::Bitcode => "bc",
OutputType::DepInfo => "d",
OutputType::Exe => "",
OutputType::LlvmAssembly => "ll",
OutputType::Metadata => "rmeta",
OutputType::Mir => "mir",
OutputType::Object => "o",
OutputType::ThinLinkBitcode => "indexing.o",
}
}
pub fn is_text_output(&self) -> bool {
match *self {
OutputType::Assembly => true,
OutputType::Bitcode => false,
OutputType::DepInfo => true,
OutputType::Exe => false,
OutputType::LlvmAssembly => true,
OutputType::Metadata => false,
OutputType::Mir => true,
OutputType::Object => false,
OutputType::ThinLinkBitcode => false,
}
}
pub fn description(&self) -> &'static str {
match *self {
OutputType::Assembly =>
"Generates a file with the crate's assembly code",
OutputType::Bitcode =>
"Generates a binary file containing the LLVM bitcode",
OutputType::DepInfo =>
"Generates a file with Makefile syntax that indicates all the source files that were loaded to generate the crate",
OutputType::Exe =>
"Generates the crates specified by --crate-type. This is the default if --emit is not specified",
OutputType::LlvmAssembly => "Generates a file containing LLVM IR",
OutputType::Metadata =>
"Generates a file containing metadata about the crate",
OutputType::Mir =>
"Generates a file containing rustc's mid-level intermediate representation",
OutputType::Object => "Generates a native object file",
OutputType::ThinLinkBitcode =>
"Generates the ThinLTO summary as bitcode",
}
}
pub fn default_filename(&self) -> &'static str {
match *self {
OutputType::Assembly => "CRATE_NAME.s",
OutputType::Bitcode => "CRATE_NAME.bc",
OutputType::DepInfo => "CRATE_NAME.d",
OutputType::Exe => "(platform and crate-type dependent)",
OutputType::LlvmAssembly => "CRATE_NAME.ll",
OutputType::Metadata => "libCRATE_NAME.rmeta",
OutputType::Mir => "CRATE_NAME.mir",
OutputType::Object => "CRATE_NAME.o",
OutputType::ThinLinkBitcode => "CRATE_NAME.indexing.o",
}
}
}define_output_types! {
740 Assembly => {
741 shorthand: "asm",
742 extension: "s",
743 description: "Generates a file with the crate's assembly code",
744 default_filename: "CRATE_NAME.s",
745 is_text: true,
746 compatible_with_cgus_and_single_output: false
747 },
748 #[doc = "This is the optimized bitcode, which could be either pre-LTO or non-LTO bitcode,"]
749 #[doc = "depending on the specific request type."]
750 Bitcode => {
751 shorthand: "llvm-bc",
752 extension: "bc",
753 description: "Generates a binary file containing the LLVM bitcode",
754 default_filename: "CRATE_NAME.bc",
755 is_text: false,
756 compatible_with_cgus_and_single_output: false
757 },
758 DepInfo => {
759 shorthand: "dep-info",
760 extension: "d",
761 description: "Generates a file with Makefile syntax that indicates all the source files that were loaded to generate the crate",
762 default_filename: "CRATE_NAME.d",
763 is_text: true,
764 compatible_with_cgus_and_single_output: true
765 },
766 Exe => {
767 shorthand: "link",
768 extension: "",
769 description: "Generates the crates specified by --crate-type. This is the default if --emit is not specified",
770 default_filename: "(platform and crate-type dependent)",
771 is_text: false,
772 compatible_with_cgus_and_single_output: true
773 },
774 LlvmAssembly => {
775 shorthand: "llvm-ir",
776 extension: "ll",
777 description: "Generates a file containing LLVM IR",
778 default_filename: "CRATE_NAME.ll",
779 is_text: true,
780 compatible_with_cgus_and_single_output: false
781 },
782 Metadata => {
783 shorthand: "metadata",
784 extension: "rmeta",
785 description: "Generates a file containing metadata about the crate",
786 default_filename: "libCRATE_NAME.rmeta",
787 is_text: false,
788 compatible_with_cgus_and_single_output: true
789 },
790 Mir => {
791 shorthand: "mir",
792 extension: "mir",
793 description: "Generates a file containing rustc's mid-level intermediate representation",
794 default_filename: "CRATE_NAME.mir",
795 is_text: true,
796 compatible_with_cgus_and_single_output: false
797 },
798 Object => {
799 shorthand: "obj",
800 extension: "o",
801 description: "Generates a native object file",
802 default_filename: "CRATE_NAME.o",
803 is_text: false,
804 compatible_with_cgus_and_single_output: false
805 },
806 #[doc = "This is the summary or index data part of the ThinLTO bitcode."]
807 ThinLinkBitcode => {
808 shorthand: "thin-link-bitcode",
809 extension: "indexing.o",
810 description: "Generates the ThinLTO summary as bitcode",
811 default_filename: "CRATE_NAME.indexing.o",
812 is_text: false,
813 compatible_with_cgus_and_single_output: false
814 },
815}
816
817#[derive(#[automatically_derived]
impl ::core::clone::Clone for ErrorOutputType {
#[inline]
fn clone(&self) -> ErrorOutputType {
let _: ::core::clone::AssertParamIsClone<HumanReadableErrorType>;
let _: ::core::clone::AssertParamIsClone<ColorConfig>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for ErrorOutputType { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for ErrorOutputType {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ErrorOutputType::HumanReadable {
kind: __self_0, color_config: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"HumanReadable", "kind", __self_0, "color_config",
&__self_1),
ErrorOutputType::Json {
pretty: __self_0,
json_rendered: __self_1,
color_config: __self_2 } =>
::core::fmt::Formatter::debug_struct_field3_finish(f, "Json",
"pretty", __self_0, "json_rendered", __self_1,
"color_config", &__self_2),
}
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for ErrorOutputType {
#[inline]
fn eq(&self, other: &ErrorOutputType) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(ErrorOutputType::HumanReadable {
kind: __self_0, color_config: __self_1 },
ErrorOutputType::HumanReadable {
kind: __arg1_0, color_config: __arg1_1 }) =>
__self_0 == __arg1_0 && __self_1 == __arg1_1,
(ErrorOutputType::Json {
pretty: __self_0,
json_rendered: __self_1,
color_config: __self_2 }, ErrorOutputType::Json {
pretty: __arg1_0,
json_rendered: __arg1_1,
color_config: __arg1_2 }) =>
__self_0 == __arg1_0 && __self_1 == __arg1_1 &&
__self_2 == __arg1_2,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ErrorOutputType {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<HumanReadableErrorType>;
let _: ::core::cmp::AssertParamIsEq<ColorConfig>;
let _: ::core::cmp::AssertParamIsEq<bool>;
}
}Eq, #[automatically_derived]
impl ::core::default::Default for ErrorOutputType {
#[inline]
fn default() -> ErrorOutputType {
Self::HumanReadable {
kind: const HumanReadableErrorType {
short: false,
unicode: false,
},
color_config: const ColorConfig::Auto,
}
}
}Default)]
819pub enum ErrorOutputType {
820 #[default]
822 HumanReadable {
823 kind: HumanReadableErrorType = HumanReadableErrorType { short: false, unicode: false },
824 color_config: ColorConfig = ColorConfig::Auto,
825 },
826 Json {
828 pretty: bool,
830 json_rendered: HumanReadableErrorType,
833 color_config: ColorConfig,
834 },
835}
836
837#[derive(#[automatically_derived]
impl ::core::clone::Clone for ResolveDocLinks {
#[inline]
fn clone(&self) -> ResolveDocLinks {
match self {
ResolveDocLinks::None => ResolveDocLinks::None,
ResolveDocLinks::ExportedMetadata =>
ResolveDocLinks::ExportedMetadata,
ResolveDocLinks::Exported => ResolveDocLinks::Exported,
ResolveDocLinks::All => ResolveDocLinks::All,
}
}
}Clone, #[automatically_derived]
impl ::core::hash::Hash for ResolveDocLinks {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for ResolveDocLinks {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
ResolveDocLinks::None => "None",
ResolveDocLinks::ExportedMetadata => "ExportedMetadata",
ResolveDocLinks::Exported => "Exported",
ResolveDocLinks::All => "All",
})
}
}Debug)]
838pub enum ResolveDocLinks {
839 None,
841 ExportedMetadata,
843 Exported,
845 All,
847}
848
849#[derive(#[automatically_derived]
impl ::core::clone::Clone for OutputTypes {
#[inline]
fn clone(&self) -> OutputTypes {
OutputTypes(::core::clone::Clone::clone(&self.0))
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for OutputTypes {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field1_finish(f, "OutputTypes",
&&self.0)
}
}Debug, #[automatically_derived]
impl ::core::hash::Hash for OutputTypes {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.0, state)
}
}Hash, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for OutputTypes
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
OutputTypes(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for OutputTypes {
fn encode(&self, __encoder: &mut __E) {
match *self {
OutputTypes(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for OutputTypes {
fn decode(__decoder: &mut __D) -> Self {
OutputTypes(::rustc_serialize::Decodable::decode(__decoder))
}
}
};Decodable)]
854pub struct OutputTypes(BTreeMap<OutputType, Option<OutFileName>>);
855
856impl OutputTypes {
857 pub fn new(entries: &[(OutputType, Option<OutFileName>)]) -> OutputTypes {
858 OutputTypes(BTreeMap::from_iter(entries.iter().map(|&(k, ref v)| (k, v.clone()))))
859 }
860
861 pub(crate) fn get(&self, key: &OutputType) -> Option<&Option<OutFileName>> {
862 self.0.get(key)
863 }
864
865 pub fn contains_key(&self, key: &OutputType) -> bool {
866 self.0.contains_key(key)
867 }
868
869 pub fn contains_explicit_name(&self, key: &OutputType) -> bool {
871 #[allow(non_exhaustive_omitted_patterns)] match self.0.get(key) {
Some(Some(..)) => true,
_ => false,
}matches!(self.0.get(key), Some(Some(..)))
872 }
873
874 pub fn iter(&self) -> BTreeMapIter<'_, OutputType, Option<OutFileName>> {
875 self.0.iter()
876 }
877
878 pub fn keys(&self) -> BTreeMapKeysIter<'_, OutputType, Option<OutFileName>> {
879 self.0.keys()
880 }
881
882 pub fn values(&self) -> BTreeMapValuesIter<'_, OutputType, Option<OutFileName>> {
883 self.0.values()
884 }
885
886 pub fn len(&self) -> usize {
887 self.0.len()
888 }
889
890 pub fn should_codegen(&self) -> bool {
892 self.0.keys().any(|k| match *k {
893 OutputType::Bitcode
894 | OutputType::ThinLinkBitcode
895 | OutputType::Assembly
896 | OutputType::LlvmAssembly
897 | OutputType::Mir
898 | OutputType::Object
899 | OutputType::Exe => true,
900 OutputType::Metadata | OutputType::DepInfo => false,
901 })
902 }
903
904 pub fn should_link(&self) -> bool {
906 self.0.keys().any(|k| match *k {
907 OutputType::Bitcode
908 | OutputType::ThinLinkBitcode
909 | OutputType::Assembly
910 | OutputType::LlvmAssembly
911 | OutputType::Mir
912 | OutputType::Metadata
913 | OutputType::Object
914 | OutputType::DepInfo => false,
915 OutputType::Exe => true,
916 })
917 }
918}
919
920#[derive(#[automatically_derived]
impl ::core::clone::Clone for Externs {
#[inline]
fn clone(&self) -> Externs {
Externs(::core::clone::Clone::clone(&self.0))
}
}Clone)]
924pub struct Externs(BTreeMap<String, ExternEntry>);
925
926#[derive(#[automatically_derived]
impl ::core::clone::Clone for ExternEntry {
#[inline]
fn clone(&self) -> ExternEntry {
ExternEntry {
location: ::core::clone::Clone::clone(&self.location),
is_private_dep: ::core::clone::Clone::clone(&self.is_private_dep),
add_prelude: ::core::clone::Clone::clone(&self.add_prelude),
nounused_dep: ::core::clone::Clone::clone(&self.nounused_dep),
force: ::core::clone::Clone::clone(&self.force),
}
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ExternEntry {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field5_finish(f, "ExternEntry",
"location", &self.location, "is_private_dep",
&self.is_private_dep, "add_prelude", &self.add_prelude,
"nounused_dep", &self.nounused_dep, "force", &&self.force)
}
}Debug)]
927pub struct ExternEntry {
928 pub location: ExternLocation,
929 pub is_private_dep: bool,
935 pub add_prelude: bool,
940 pub nounused_dep: bool,
945 pub force: bool,
951}
952
953#[derive(#[automatically_derived]
impl ::core::clone::Clone for ExternLocation {
#[inline]
fn clone(&self) -> ExternLocation {
match self {
ExternLocation::FoundInLibrarySearchDirectories =>
ExternLocation::FoundInLibrarySearchDirectories,
ExternLocation::ExactPaths(__self_0) =>
ExternLocation::ExactPaths(::core::clone::Clone::clone(__self_0)),
}
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ExternLocation {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ExternLocation::FoundInLibrarySearchDirectories =>
::core::fmt::Formatter::write_str(f,
"FoundInLibrarySearchDirectories"),
ExternLocation::ExactPaths(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ExactPaths", &__self_0),
}
}
}Debug)]
954pub enum ExternLocation {
955 FoundInLibrarySearchDirectories,
959 ExactPaths(BTreeSet<CanonicalizedPath>),
966}
967
968impl Externs {
969 pub fn new(data: BTreeMap<String, ExternEntry>) -> Externs {
971 Externs(data)
972 }
973
974 pub fn get(&self, key: &str) -> Option<&ExternEntry> {
975 self.0.get(key)
976 }
977
978 pub fn iter(&self) -> BTreeMapIter<'_, String, ExternEntry> {
979 self.0.iter()
980 }
981}
982
983impl ExternEntry {
984 fn new(location: ExternLocation) -> ExternEntry {
985 ExternEntry {
986 location,
987 is_private_dep: false,
988 add_prelude: false,
989 nounused_dep: false,
990 force: false,
991 }
992 }
993
994 pub fn files(&self) -> Option<impl Iterator<Item = &CanonicalizedPath>> {
995 match &self.location {
996 ExternLocation::ExactPaths(set) => Some(set.iter()),
997 _ => None,
998 }
999 }
1000}
1001
1002#[derive(#[automatically_derived]
impl ::core::fmt::Debug for NextSolverConfig {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"NextSolverConfig", "coherence", &self.coherence, "globally",
&&self.globally)
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for NextSolverConfig { }Copy, #[automatically_derived]
impl ::core::clone::Clone for NextSolverConfig {
#[inline]
fn clone(&self) -> NextSolverConfig {
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl ::core::hash::Hash for NextSolverConfig {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.coherence, state);
::core::hash::Hash::hash(&self.globally, state)
}
}Hash, #[automatically_derived]
impl ::core::cmp::PartialEq for NextSolverConfig {
#[inline]
fn eq(&self, other: &NextSolverConfig) -> bool {
self.coherence == other.coherence && self.globally == other.globally
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for NextSolverConfig {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<bool>;
}
}Eq, #[automatically_derived]
impl ::core::default::Default for NextSolverConfig {
#[inline]
fn default() -> NextSolverConfig {
NextSolverConfig { coherence: const true, globally: const false }
}
}Default)]
1003pub struct NextSolverConfig {
1004 pub coherence: bool = true,
1006 pub globally: bool = false,
1009}
1010
1011#[derive(#[automatically_derived]
impl ::core::clone::Clone for Input {
#[inline]
fn clone(&self) -> Input {
match self {
Input::File(__self_0) =>
Input::File(::core::clone::Clone::clone(__self_0)),
Input::Str { name: __self_0, input: __self_1 } =>
Input::Str {
name: ::core::clone::Clone::clone(__self_0),
input: ::core::clone::Clone::clone(__self_1),
},
}
}
}Clone)]
1012pub enum Input {
1013 File(PathBuf),
1015 Str {
1017 name: FileName,
1019 input: String,
1021 },
1022}
1023
1024impl Input {
1025 pub fn filestem(&self) -> &str {
1026 if let Input::File(ifile) = self {
1027 if let Some(name) = ifile.file_stem().and_then(OsStr::to_str) {
1030 return name;
1031 }
1032 }
1033 "rust_out"
1034 }
1035
1036 pub fn file_name(&self, session: &Session) -> FileName {
1037 match *self {
1038 Input::File(ref ifile) => FileName::Real(
1039 session
1040 .psess
1041 .source_map()
1042 .path_mapping()
1043 .to_real_filename(session.psess.source_map().working_dir(), ifile.as_path()),
1044 ),
1045 Input::Str { ref name, .. } => name.clone(),
1046 }
1047 }
1048
1049 pub fn opt_path(&self) -> Option<&Path> {
1050 match self {
1051 Input::File(file) => Some(file),
1052 Input::Str { name, .. } => match name {
1053 FileName::Real(real) => real.local_path(),
1054 FileName::CfgSpec(_) => None,
1055 FileName::Anon(_) => None,
1056 FileName::MacroExpansion(_) => None,
1057 FileName::ProcMacroSourceCode(_) => None,
1058 FileName::CliCrateAttr(_) => None,
1059 FileName::Custom(_) => None,
1060 FileName::DocTest(path, _) => Some(path),
1061 FileName::InlineAsm(_) => None,
1062 },
1063 }
1064 }
1065}
1066
1067#[derive(#[automatically_derived]
impl ::core::clone::Clone for OutFileName {
#[inline]
fn clone(&self) -> OutFileName {
match self {
OutFileName::Real(__self_0) =>
OutFileName::Real(::core::clone::Clone::clone(__self_0)),
OutFileName::Stdout => OutFileName::Stdout,
}
}
}Clone, #[automatically_derived]
impl ::core::hash::Hash for OutFileName {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
OutFileName::Real(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
_ => {}
}
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for OutFileName {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
OutFileName::Real(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Real",
&__self_0),
OutFileName::Stdout =>
::core::fmt::Formatter::write_str(f, "Stdout"),
}
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for OutFileName
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
OutFileName::Real(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
OutFileName::Stdout => {}
}
}
}
};StableHash, #[automatically_derived]
impl ::core::cmp::PartialEq for OutFileName {
#[inline]
fn eq(&self, other: &OutFileName) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(OutFileName::Real(__self_0), OutFileName::Real(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for OutFileName {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<PathBuf>;
}
}Eq, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for OutFileName {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
OutFileName::Real(ref __binding_0) => { 0usize }
OutFileName::Stdout => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
OutFileName::Real(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
OutFileName::Stdout => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for OutFileName {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
OutFileName::Real(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => { OutFileName::Stdout }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `OutFileName`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable)]
1068pub enum OutFileName {
1069 Real(PathBuf),
1070 Stdout,
1071}
1072
1073impl OutFileName {
1074 pub fn parent(&self) -> Option<&Path> {
1075 match *self {
1076 OutFileName::Real(ref path) => path.parent(),
1077 OutFileName::Stdout => None,
1078 }
1079 }
1080
1081 pub fn filestem(&self) -> Option<&OsStr> {
1082 match *self {
1083 OutFileName::Real(ref path) => path.file_stem(),
1084 OutFileName::Stdout => Some(OsStr::new("stdout")),
1085 }
1086 }
1087
1088 pub fn is_stdout(&self) -> bool {
1089 match *self {
1090 OutFileName::Real(_) => false,
1091 OutFileName::Stdout => true,
1092 }
1093 }
1094
1095 pub fn is_tty(&self) -> bool {
1096 use std::io::IsTerminal;
1097 match *self {
1098 OutFileName::Real(_) => false,
1099 OutFileName::Stdout => std::io::stdout().is_terminal(),
1100 }
1101 }
1102
1103 pub fn as_path(&self) -> &Path {
1104 match *self {
1105 OutFileName::Real(ref path) => path.as_ref(),
1106 OutFileName::Stdout => Path::new("stdout"),
1107 }
1108 }
1109
1110 pub fn file_for_writing(
1116 &self,
1117 outputs: &OutputFilenames,
1118 flavor: OutputType,
1119 codegen_unit_name: &str,
1120 ) -> PathBuf {
1121 match *self {
1122 OutFileName::Real(ref path) => path.clone(),
1123 OutFileName::Stdout => outputs.temp_path_for_cgu(flavor, codegen_unit_name),
1124 }
1125 }
1126
1127 pub fn overwrite(&self, content: &str, sess: &Session) {
1128 match self {
1129 OutFileName::Stdout => { ::std::io::_print(format_args!("{0}", content)); }print!("{content}"),
1130 OutFileName::Real(path) => {
1131 if let Err(e) = fs::write(path, content) {
1132 sess.dcx().emit_fatal(FileWriteFail { path, err: e.to_string() });
1133 }
1134 }
1135 }
1136 }
1137}
1138
1139#[derive(#[automatically_derived]
impl ::core::clone::Clone for OutputFilenames {
#[inline]
fn clone(&self) -> OutputFilenames {
OutputFilenames {
out_directory: ::core::clone::Clone::clone(&self.out_directory),
crate_stem: ::core::clone::Clone::clone(&self.crate_stem),
filestem: ::core::clone::Clone::clone(&self.filestem),
single_output_file: ::core::clone::Clone::clone(&self.single_output_file),
temps_directory: ::core::clone::Clone::clone(&self.temps_directory),
invocation_temp: ::core::clone::Clone::clone(&self.invocation_temp),
explicit_dwo_out_directory: ::core::clone::Clone::clone(&self.explicit_dwo_out_directory),
outputs: ::core::clone::Clone::clone(&self.outputs),
}
}
}Clone, #[automatically_derived]
impl ::core::hash::Hash for OutputFilenames {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.out_directory, state);
::core::hash::Hash::hash(&self.crate_stem, state);
::core::hash::Hash::hash(&self.filestem, state);
::core::hash::Hash::hash(&self.single_output_file, state);
::core::hash::Hash::hash(&self.temps_directory, state);
::core::hash::Hash::hash(&self.invocation_temp, state);
::core::hash::Hash::hash(&self.explicit_dwo_out_directory, state);
::core::hash::Hash::hash(&self.outputs, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for OutputFilenames {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["out_directory", "crate_stem", "filestem", "single_output_file",
"temps_directory", "invocation_temp",
"explicit_dwo_out_directory", "outputs"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.out_directory, &self.crate_stem, &self.filestem,
&self.single_output_file, &self.temps_directory,
&self.invocation_temp, &self.explicit_dwo_out_directory,
&&self.outputs];
::core::fmt::Formatter::debug_struct_fields_finish(f,
"OutputFilenames", names, values)
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
OutputFilenames {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
OutputFilenames {
out_directory: ref __binding_0,
crate_stem: ref __binding_1,
filestem: ref __binding_2,
single_output_file: ref __binding_3,
temps_directory: ref __binding_4,
invocation_temp: ref __binding_5,
explicit_dwo_out_directory: ref __binding_6,
outputs: ref __binding_7 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
{}
{ __binding_6.stable_hash(__hcx, __hasher); }
{ __binding_7.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for OutputFilenames {
fn encode(&self, __encoder: &mut __E) {
match *self {
OutputFilenames {
out_directory: ref __binding_0,
crate_stem: ref __binding_1,
filestem: ref __binding_2,
single_output_file: ref __binding_3,
temps_directory: ref __binding_4,
invocation_temp: ref __binding_5,
explicit_dwo_out_directory: ref __binding_6,
outputs: ref __binding_7 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_2,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_3,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_4,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_5,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_6,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_7,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for OutputFilenames {
fn decode(__decoder: &mut __D) -> Self {
OutputFilenames {
out_directory: ::rustc_serialize::Decodable::decode(__decoder),
crate_stem: ::rustc_serialize::Decodable::decode(__decoder),
filestem: ::rustc_serialize::Decodable::decode(__decoder),
single_output_file: ::rustc_serialize::Decodable::decode(__decoder),
temps_directory: ::rustc_serialize::Decodable::decode(__decoder),
invocation_temp: ::rustc_serialize::Decodable::decode(__decoder),
explicit_dwo_out_directory: ::rustc_serialize::Decodable::decode(__decoder),
outputs: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable)]
1140pub struct OutputFilenames {
1141 pub(crate) out_directory: PathBuf,
1142 crate_stem: String,
1144 filestem: String,
1146 pub single_output_file: Option<OutFileName>,
1147 temps_directory: Option<PathBuf>,
1148
1149 #[stable_hash(ignore)]
1157 invocation_temp: Option<String>,
1158
1159 explicit_dwo_out_directory: Option<PathBuf>,
1160 pub outputs: OutputTypes,
1161}
1162
1163pub const RLINK_EXT: &str = "rlink";
1164pub const RUST_CGU_EXT: &str = "rcgu";
1165pub const DWARF_OBJECT_EXT: &str = "dwo";
1166pub const MAX_FILENAME_LENGTH: usize = 143; fn maybe_strip_file_name(mut path: PathBuf) -> PathBuf {
1172 if path.file_name().map_or(0, |name| name.len()) > MAX_FILENAME_LENGTH {
1173 let filename = path.file_name().unwrap().to_string_lossy();
1174 let hash_len = 64 / 4; let hyphen_len = 1; let allowed_suffix = MAX_FILENAME_LENGTH.saturating_sub(hash_len + hyphen_len);
1179
1180 let stripped_bytes = filename.len().saturating_sub(allowed_suffix);
1182
1183 let split_at = filename.ceil_char_boundary(stripped_bytes);
1185
1186 let mut hasher = StableHasher::new();
1187 filename[..split_at].hash(&mut hasher);
1188 let hash = hasher.finish::<Hash64>();
1189
1190 path.set_file_name(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0:x}-{1}", hash,
&filename[split_at..]))
})format!("{:x}-{}", hash, &filename[split_at..]));
1191 }
1192 path
1193}
1194impl OutputFilenames {
1195 pub fn new(
1196 out_directory: PathBuf,
1197 out_crate_name: String,
1198 out_filestem: String,
1199 single_output_file: Option<OutFileName>,
1200 temps_directory: Option<PathBuf>,
1201 invocation_temp: Option<String>,
1202 explicit_dwo_out_directory: Option<PathBuf>,
1203 extra: String,
1204 outputs: OutputTypes,
1205 ) -> Self {
1206 OutputFilenames {
1207 out_directory,
1208 single_output_file,
1209 temps_directory,
1210 invocation_temp,
1211 explicit_dwo_out_directory,
1212 outputs,
1213 crate_stem: ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}{1}", out_crate_name, extra))
})format!("{out_crate_name}{extra}"),
1214 filestem: ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}{1}", out_filestem, extra))
})format!("{out_filestem}{extra}"),
1215 }
1216 }
1217
1218 pub fn path(&self, flavor: OutputType) -> OutFileName {
1219 self.outputs
1220 .get(&flavor)
1221 .and_then(|p| p.to_owned())
1222 .or_else(|| self.single_output_file.clone())
1223 .unwrap_or_else(|| OutFileName::Real(self.output_path(flavor)))
1224 }
1225
1226 pub fn interface_path(&self) -> PathBuf {
1227 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_session/src/config.rs:1227",
"rustc_session::config", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_session/src/config.rs"),
::tracing_core::__macro_support::Option::Some(1227u32),
::tracing_core::__macro_support::Option::Some("rustc_session::config"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("using crate_name={0} for interface_path",
self.crate_stem) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("using crate_name={} for interface_path", self.crate_stem);
1228 self.out_directory.join(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("lib{0}.rs", self.crate_stem))
})format!("lib{}.rs", self.crate_stem))
1229 }
1230
1231 fn output_path(&self, flavor: OutputType) -> PathBuf {
1234 let extension = flavor.extension();
1235 match flavor {
1236 OutputType::Metadata => {
1237 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_session/src/config.rs:1237",
"rustc_session::config", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_session/src/config.rs"),
::tracing_core::__macro_support::Option::Some(1237u32),
::tracing_core::__macro_support::Option::Some("rustc_session::config"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("using crate_name={0} for {1}",
self.crate_stem, extension) as
&dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("using crate_name={} for {extension}", self.crate_stem);
1238 self.out_directory.join(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("lib{0}.{1}", self.crate_stem,
extension))
})format!("lib{}.{}", self.crate_stem, extension))
1239 }
1240 _ => self.with_directory_and_extension(&self.out_directory, extension),
1241 }
1242 }
1243
1244 pub fn temp_path_for_cgu(&self, flavor: OutputType, codegen_unit_name: &str) -> PathBuf {
1248 let extension = flavor.extension();
1249 self.temp_path_ext_for_cgu(extension, codegen_unit_name)
1250 }
1251
1252 pub fn temp_path_dwo_for_cgu(&self, codegen_unit_name: &str) -> PathBuf {
1254 let p = self.temp_path_ext_for_cgu(DWARF_OBJECT_EXT, codegen_unit_name);
1255 if let Some(dwo_out) = &self.explicit_dwo_out_directory {
1256 let mut o = dwo_out.clone();
1257 o.push(p.file_name().unwrap());
1258 o
1259 } else {
1260 p
1261 }
1262 }
1263
1264 pub fn temp_path_ext_for_cgu(&self, ext: &str, codegen_unit_name: &str) -> PathBuf {
1267 let mut extension = codegen_unit_name.to_string();
1268
1269 if let Some(rng) = &self.invocation_temp {
1271 extension.push('.');
1272 extension.push_str(rng);
1273 }
1274
1275 if !ext.is_empty() {
1278 extension.push('.');
1279 extension.push_str(RUST_CGU_EXT);
1280 extension.push('.');
1281 extension.push_str(ext);
1282 }
1283
1284 let temps_directory = self.temps_directory.as_ref().unwrap_or(&self.out_directory);
1285 maybe_strip_file_name(self.with_directory_and_extension(temps_directory, &extension))
1286 }
1287
1288 pub fn temp_path_for_diagnostic(&self, ext: &str) -> PathBuf {
1289 let temps_directory = self.temps_directory.as_ref().unwrap_or(&self.out_directory);
1290 self.with_directory_and_extension(temps_directory, &ext)
1291 }
1292
1293 pub fn with_extension(&self, extension: &str) -> PathBuf {
1294 self.with_directory_and_extension(&self.out_directory, extension)
1295 }
1296
1297 pub fn with_directory_and_extension(&self, directory: &Path, extension: &str) -> PathBuf {
1298 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_session/src/config.rs:1298",
"rustc_session::config", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_session/src/config.rs"),
::tracing_core::__macro_support::Option::Some(1298u32),
::tracing_core::__macro_support::Option::Some("rustc_session::config"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("using filestem={0} for {1}",
self.filestem, extension) as
&dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("using filestem={} for {extension}", self.filestem);
1299 let mut path = directory.join(&self.filestem);
1300 path.set_extension(extension);
1301 path
1302 }
1303
1304 pub fn split_dwarf_path(
1307 &self,
1308 split_debuginfo_kind: SplitDebuginfo,
1309 split_dwarf_kind: SplitDwarfKind,
1310 cgu_name: &str,
1311 ) -> Option<PathBuf> {
1312 let obj_out = self.temp_path_for_cgu(OutputType::Object, cgu_name);
1313 let dwo_out = self.temp_path_dwo_for_cgu(cgu_name);
1314 match (split_debuginfo_kind, split_dwarf_kind) {
1315 (SplitDebuginfo::Off, SplitDwarfKind::Single | SplitDwarfKind::Split) => None,
1316 (SplitDebuginfo::Packed | SplitDebuginfo::Unpacked, SplitDwarfKind::Single) => {
1320 Some(obj_out)
1321 }
1322 (SplitDebuginfo::Packed | SplitDebuginfo::Unpacked, SplitDwarfKind::Split) => {
1324 Some(dwo_out)
1325 }
1326 }
1327 }
1328}
1329
1330pub fn parse_remap_path_scope(
1332 early_dcx: &EarlyDiagCtxt,
1333 matches: &getopts::Matches,
1334 unstable_opts: &UnstableOptions,
1335) -> RemapPathScopeComponents {
1336 if let Some(v) = matches.opt_str("remap-path-scope") {
1337 let mut slot = RemapPathScopeComponents::empty();
1338 for s in v.split(',') {
1339 slot |= match s {
1340 "macro" => RemapPathScopeComponents::MACRO,
1341 "diagnostics" => RemapPathScopeComponents::DIAGNOSTICS,
1342 "documentation" => {
1343 if !unstable_opts.unstable_options {
1344 early_dcx.early_fatal("remapping `documentation` path scope requested but `-Zunstable-options` not specified");
1345 }
1346
1347 RemapPathScopeComponents::DOCUMENTATION
1348 },
1349 "debuginfo" => RemapPathScopeComponents::DEBUGINFO,
1350 "coverage" => RemapPathScopeComponents::COVERAGE,
1351 "object" => RemapPathScopeComponents::OBJECT,
1352 "all" => RemapPathScopeComponents::all(),
1353 _ => early_dcx.early_fatal("argument for `--remap-path-scope` must be a comma separated list of scopes: `macro`, `diagnostics`, `documentation`, `debuginfo`, `coverage`, `object`, `all`"),
1354 }
1355 }
1356 slot
1357 } else {
1358 RemapPathScopeComponents::all()
1359 }
1360}
1361
1362#[derive(#[automatically_derived]
impl ::core::clone::Clone for Sysroot {
#[inline]
fn clone(&self) -> Sysroot {
Sysroot {
explicit: ::core::clone::Clone::clone(&self.explicit),
default: ::core::clone::Clone::clone(&self.default),
}
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Sysroot {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "Sysroot",
"explicit", &self.explicit, "default", &&self.default)
}
}Debug)]
1363pub struct Sysroot {
1364 pub explicit: Option<PathBuf>,
1365 pub default: PathBuf,
1366}
1367
1368impl Sysroot {
1369 pub fn new(explicit: Option<PathBuf>) -> Sysroot {
1370 Sysroot { explicit, default: filesearch::default_sysroot() }
1371 }
1372
1373 pub fn path(&self) -> &Path {
1375 self.explicit.as_deref().unwrap_or(&self.default)
1376 }
1377
1378 pub fn all_paths(&self) -> impl Iterator<Item = &Path> {
1380 self.explicit.as_deref().into_iter().chain(iter::once(&*self.default))
1381 }
1382}
1383
1384pub fn host_tuple() -> &'static str {
1385 (::core::option::Option::Some("aarch64-unknown-linux-gnu")option_env!("CFG_COMPILER_HOST_TRIPLE")).expect("CFG_COMPILER_HOST_TRIPLE")
1394}
1395
1396fn file_path_mapping(
1397 remap_path_prefix: Vec<(PathBuf, PathBuf)>,
1398 remap_cwd_prefix: Option<&Path>,
1399 remap_path_scope: RemapPathScopeComponents,
1400) -> FilePathMapping {
1401 let cwd_remap = if let Some(to) = remap_cwd_prefix
1404 && let Ok(cwd) = std::env::current_dir()
1405 {
1406 Some((cwd, to.to_path_buf()))
1407 } else {
1408 None
1409 };
1410 FilePathMapping::new(remap_path_prefix.into_iter().chain(cwd_remap).collect(), remap_path_scope)
1413}
1414
1415impl Default for Options {
1416 fn default() -> Options {
1417 let unstable_opts = UnstableOptions::default();
1418
1419 let working_dir = {
1423 let working_dir = std::env::current_dir().unwrap();
1424 let file_mapping =
1425 file_path_mapping(Vec::new(), None, RemapPathScopeComponents::empty());
1426 file_mapping.to_real_filename(&RealFileName::empty(), &working_dir)
1427 };
1428
1429 Options {
1430 crate_types: Vec::new(),
1431 optimize: OptLevel::No,
1432 debuginfo: DebugInfo::None,
1433 lint_opts: Vec::new(),
1434 lint_cap: None,
1435 describe_lints: false,
1436 output_types: OutputTypes(BTreeMap::new()),
1437 search_paths: ::alloc::vec::Vec::new()vec![],
1438 sysroot: Sysroot::new(None),
1439 target_triple: TargetTuple::from_tuple(host_tuple()),
1440 test: false,
1441 incremental: None,
1442 unstable_opts,
1443 prints: Vec::new(),
1444 cg: Default::default(),
1445 error_format: ErrorOutputType::default(),
1446 diagnostic_width: None,
1447 externs: Externs(BTreeMap::new()),
1448 crate_name: None,
1449 libs: Vec::new(),
1450 unstable_features: UnstableFeatures::Disallow,
1451 debug_assertions: true,
1452 actually_rustdoc: false,
1453 resolve_doc_links: ResolveDocLinks::None,
1454 trimmed_def_paths: false,
1455 cli_forced_codegen_units: None,
1456 cli_forced_local_thinlto_off: false,
1457 remap_path_prefix: Vec::new(),
1458 remap_path_scope: RemapPathScopeComponents::all(),
1459 real_rust_source_base_dir: None,
1460 real_rustc_dev_source_base_dir: None,
1461 edition: DEFAULT_EDITION,
1462 json_artifact_notifications: false,
1463 json_timings: false,
1464 json_unused_externs: JsonUnusedExterns::No,
1465 json_future_incompat: false,
1466 pretty: None,
1467 working_dir,
1468 color: ColorConfig::Auto,
1469 logical_env: FxIndexMap::default(),
1470 verbose: false,
1471 target_modifiers: BTreeMap::default(),
1472 mitigation_coverage_map: Default::default(),
1473 }
1474 }
1475}
1476
1477impl Options {
1478 pub fn build_dep_graph(&self) -> bool {
1480 self.incremental.is_some()
1481 || self.unstable_opts.dump_dep_graph
1482 || self.unstable_opts.query_dep_graph
1483 }
1484
1485 pub fn file_path_mapping(&self) -> FilePathMapping {
1486 file_path_mapping(
1487 self.remap_path_prefix.clone(),
1488 self.unstable_opts.remap_cwd_prefix.as_deref(),
1489 self.remap_path_scope,
1490 )
1491 }
1492
1493 pub fn will_create_output_file(&self) -> bool {
1495 !self.unstable_opts.parse_crate_root_only && self.unstable_opts.ls.is_empty() }
1498
1499 #[inline]
1500 pub fn share_generics(&self) -> bool {
1501 match self.unstable_opts.share_generics {
1502 Some(setting) => setting,
1503 None => match self.optimize {
1504 OptLevel::No | OptLevel::Less | OptLevel::Size | OptLevel::SizeMin => true,
1505 OptLevel::More | OptLevel::Aggressive => false,
1506 },
1507 }
1508 }
1509
1510 pub fn get_symbol_mangling_version(&self) -> SymbolManglingVersion {
1511 self.cg.symbol_mangling_version.unwrap_or(SymbolManglingVersion::V0)
1512 }
1513
1514 #[inline]
1515 pub fn autodiff_enabled(&self) -> bool {
1516 self.unstable_opts.autodiff.contains(&AutoDiff::Enable)
1517 }
1518}
1519
1520impl UnstableOptions {
1521 pub fn dcx_flags(&self, can_emit_warnings: bool) -> DiagCtxtFlags {
1522 DiagCtxtFlags {
1523 can_emit_warnings,
1524 treat_err_as_bug: self.treat_err_as_bug,
1525 eagerly_emit_delayed_bugs: self.eagerly_emit_delayed_bugs,
1526 macro_backtrace: self.macro_backtrace,
1527 deduplicate_diagnostics: self.deduplicate_diagnostics,
1528 track_diagnostics: self.track_diagnostics,
1529 }
1530 }
1531
1532 pub fn src_hash_algorithm(&self, target: &Target) -> SourceFileHashAlgorithm {
1533 self.src_hash_algorithm.unwrap_or_else(|| {
1534 if target.is_like_msvc {
1535 SourceFileHashAlgorithm::Sha256
1536 } else {
1537 SourceFileHashAlgorithm::Md5
1538 }
1539 })
1540 }
1541
1542 pub fn checksum_hash_algorithm(&self) -> Option<SourceFileHashAlgorithm> {
1543 self.checksum_hash_algorithm
1544 }
1545}
1546
1547#[derive(#[automatically_derived]
impl ::core::marker::Copy for EntryFnType { }Copy, #[automatically_derived]
impl ::core::clone::Clone for EntryFnType {
#[inline]
fn clone(&self) -> EntryFnType {
let _: ::core::clone::AssertParamIsClone<u8>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for EntryFnType {
#[inline]
fn eq(&self, other: &EntryFnType) -> bool {
match (self, other) {
(EntryFnType::Main { sigpipe: __self_0 }, EntryFnType::Main {
sigpipe: __arg1_0 }) => __self_0 == __arg1_0,
}
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for EntryFnType {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
match self {
EntryFnType::Main { sigpipe: __self_0 } =>
::core::hash::Hash::hash(__self_0, state),
}
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for EntryFnType {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
EntryFnType::Main { sigpipe: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Main",
"sigpipe", &__self_0),
}
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for EntryFnType
{
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
EntryFnType::Main { sigpipe: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
1549pub enum EntryFnType {
1550 Main {
1551 sigpipe: u8,
1558 },
1559}
1560
1561pub use rustc_hir::attrs::CrateType;
1562
1563#[derive(#[automatically_derived]
impl ::core::clone::Clone for Passes {
#[inline]
fn clone(&self) -> Passes {
match self {
Passes::Some(__self_0) =>
Passes::Some(::core::clone::Clone::clone(__self_0)),
Passes::All => Passes::All,
}
}
}Clone, #[automatically_derived]
impl ::core::hash::Hash for Passes {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
Passes::Some(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
_ => {}
}
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for Passes {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Passes::Some(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Some",
&__self_0),
Passes::All => ::core::fmt::Formatter::write_str(f, "All"),
}
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for Passes {
#[inline]
fn eq(&self, other: &Passes) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(Passes::Some(__self_0), Passes::Some(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Passes {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<Vec<String>>;
}
}Eq, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for Passes {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
Passes::Some(ref __binding_0) => { 0usize }
Passes::All => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
Passes::Some(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
Passes::All => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for Passes {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
Passes::Some(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => { Passes::All }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Passes`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable)]
1564pub enum Passes {
1565 Some(Vec<String>),
1566 All,
1567}
1568
1569impl Passes {
1570 fn is_empty(&self) -> bool {
1571 match *self {
1572 Passes::Some(ref v) => v.is_empty(),
1573 Passes::All => false,
1574 }
1575 }
1576
1577 pub(crate) fn extend(&mut self, passes: impl IntoIterator<Item = String>) {
1578 match *self {
1579 Passes::Some(ref mut v) => v.extend(passes),
1580 Passes::All => {}
1581 }
1582 }
1583}
1584
1585#[derive(#[automatically_derived]
impl ::core::clone::Clone for PAuthKey {
#[inline]
fn clone(&self) -> PAuthKey { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for PAuthKey { }Copy, #[automatically_derived]
impl ::core::hash::Hash for PAuthKey {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for PAuthKey {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self { PAuthKey::A => "A", PAuthKey::B => "B", })
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for PAuthKey {
#[inline]
fn eq(&self, other: &PAuthKey) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq)]
1586pub enum PAuthKey {
1587 A,
1588 B,
1589}
1590
1591#[derive(#[automatically_derived]
impl ::core::clone::Clone for PacRet {
#[inline]
fn clone(&self) -> PacRet {
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<PAuthKey>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for PacRet { }Copy, #[automatically_derived]
impl ::core::hash::Hash for PacRet {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.leaf, state);
::core::hash::Hash::hash(&self.pc, state);
::core::hash::Hash::hash(&self.key, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for PacRet {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "PacRet",
"leaf", &self.leaf, "pc", &self.pc, "key", &&self.key)
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for PacRet {
#[inline]
fn eq(&self, other: &PacRet) -> bool {
self.leaf == other.leaf && self.pc == other.pc &&
self.key == other.key
}
}PartialEq)]
1592pub struct PacRet {
1593 pub leaf: bool,
1594 pub pc: bool,
1595 pub key: PAuthKey,
1596}
1597
1598#[derive(#[automatically_derived]
impl ::core::clone::Clone for BranchProtection {
#[inline]
fn clone(&self) -> BranchProtection {
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<Option<PacRet>>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for BranchProtection { }Copy, #[automatically_derived]
impl ::core::hash::Hash for BranchProtection {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.bti, state);
::core::hash::Hash::hash(&self.pac_ret, state);
::core::hash::Hash::hash(&self.gcs, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for BranchProtection {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"BranchProtection", "bti", &self.bti, "pac_ret", &self.pac_ret,
"gcs", &&self.gcs)
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for BranchProtection {
#[inline]
fn eq(&self, other: &BranchProtection) -> bool {
self.bti == other.bti && self.gcs == other.gcs &&
self.pac_ret == other.pac_ret
}
}PartialEq, #[automatically_derived]
impl ::core::default::Default for BranchProtection {
#[inline]
fn default() -> BranchProtection {
BranchProtection {
bti: ::core::default::Default::default(),
pac_ret: ::core::default::Default::default(),
gcs: ::core::default::Default::default(),
}
}
}Default)]
1599pub struct BranchProtection {
1600 pub bti: bool,
1601 pub pac_ret: Option<PacRet>,
1602 pub gcs: bool,
1603}
1604
1605#[derive(#[automatically_derived]
impl ::core::clone::Clone for PointerAuthOption {
#[inline]
fn clone(&self) -> PointerAuthOption { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for PointerAuthOption { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for PointerAuthOption {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
PointerAuthOption::Aarch64JumpTableHardening =>
"Aarch64JumpTableHardening",
PointerAuthOption::AuthTraps => "AuthTraps",
PointerAuthOption::Calls => "Calls",
PointerAuthOption::ElfGot => "ElfGot",
PointerAuthOption::FunctionPointerTypeDiscrimination =>
"FunctionPointerTypeDiscrimination",
PointerAuthOption::IndirectGotos => "IndirectGotos",
PointerAuthOption::InitFini => "InitFini",
PointerAuthOption::InitFiniAddressDiscrimination =>
"InitFiniAddressDiscrimination",
PointerAuthOption::Intrinsics => "Intrinsics",
PointerAuthOption::ReturnAddresses => "ReturnAddresses",
PointerAuthOption::TypeInfoVTPtrDisc => "TypeInfoVTPtrDisc",
PointerAuthOption::VTPtrAddrDisc => "VTPtrAddrDisc",
PointerAuthOption::VTPtrTypeDisc => "VTPtrTypeDisc",
})
}
}Debug, #[automatically_derived]
impl ::core::cmp::Eq for PointerAuthOption {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for PointerAuthOption {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::cmp::Ord for PointerAuthOption {
#[inline]
fn cmp(&self, other: &PointerAuthOption) -> ::core::cmp::Ordering {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr)
}
}Ord, #[automatically_derived]
impl ::core::cmp::PartialOrd for PointerAuthOption {
#[inline]
fn partial_cmp(&self, other: &PointerAuthOption)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::PartialEq for PointerAuthOption {
#[inline]
fn eq(&self, other: &PointerAuthOption) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq)]
1606pub enum PointerAuthOption {
1607 Aarch64JumpTableHardening,
1612 AuthTraps,
1613 Calls,
1614 ElfGot,
1615 FunctionPointerTypeDiscrimination,
1616 IndirectGotos,
1617 InitFini,
1618 InitFiniAddressDiscrimination,
1619 Intrinsics,
1620 ReturnAddresses,
1621 TypeInfoVTPtrDisc,
1622 VTPtrAddrDisc,
1623 VTPtrTypeDisc,
1624 }
1626impl PointerAuthOption {
1627 pub fn parse(s: &str) -> Option<Self> {
1628 match s {
1629 "aarch64-jump-table-hardening" => Some(Self::Aarch64JumpTableHardening),
1630 "auth-traps" => Some(Self::AuthTraps),
1631 "calls" => Some(Self::Calls),
1632 "elf-got" => Some(Self::ElfGot),
1633 "function-pointer-type-discrimination" => Some(Self::FunctionPointerTypeDiscrimination),
1634 "indirect-gotos" => Some(Self::IndirectGotos),
1635 "init-fini" => Some(Self::InitFini),
1636 "init-fini-address-discrimination" => Some(Self::InitFiniAddressDiscrimination),
1637 "intrinsics" => Some(Self::Intrinsics),
1638 "return-addresses" => Some(Self::ReturnAddresses),
1639 "typeinfo-vt-ptr-discrimination" => Some(Self::TypeInfoVTPtrDisc),
1640 "vt-ptr-addr-discrimination" => Some(Self::VTPtrAddrDisc),
1641 "vt-ptr-type-discrimination" => Some(Self::VTPtrTypeDisc),
1642 _ => None,
1643 }
1644 }
1645}
1646
1647pub fn build_configuration(sess: &Session, mut user_cfg: Cfg) -> Cfg {
1648 cfg::disallow_cfgs(sess, &user_cfg);
1650
1651 user_cfg.extend(cfg::default_configuration(sess));
1654 user_cfg
1655}
1656
1657pub fn build_target_config(
1658 early_dcx: &EarlyDiagCtxt,
1659 target: &TargetTuple,
1660 sysroot: &Path,
1661 unstable_options: bool,
1662) -> Target {
1663 match Target::search(target, sysroot, unstable_options) {
1664 Ok((target, warnings)) => {
1665 for warning in warnings.warning_messages() {
1666 early_dcx.early_warn(warning)
1667 }
1668
1669 if !#[allow(non_exhaustive_omitted_patterns)] match target.pointer_width {
16 | 32 | 64 => true,
_ => false,
}matches!(target.pointer_width, 16 | 32 | 64) {
1670 early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("target specification was invalid: unrecognized target-pointer-width {0}",
target.pointer_width))
})format!(
1671 "target specification was invalid: unrecognized target-pointer-width {}",
1672 target.pointer_width
1673 ))
1674 }
1675 target
1676 }
1677 Err(e) => {
1678 let mut err =
1679 early_dcx.early_struct_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("error loading target specification: {0}",
e))
})format!("error loading target specification: {e}"));
1680 err.help("run `rustc --print target-list` for a list of built-in targets");
1681 let typed = target.tuple();
1682 let limit = typed.len() / 3 + 1;
1683 if let Some(suggestion) = rustc_target::spec::TARGETS
1684 .iter()
1685 .filter_map(|&t| {
1686 rustc_span::edit_distance::edit_distance_with_substrings(typed, t, limit)
1687 .map(|d| (d, t))
1688 })
1689 .min_by_key(|(d, _)| *d)
1690 .map(|(_, t)| t)
1691 {
1692 err.help(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("did you mean `{0}`?", suggestion))
})format!("did you mean `{suggestion}`?"));
1693 }
1694 err.emit()
1695 }
1696 }
1697}
1698
1699#[derive(#[automatically_derived]
impl ::core::marker::Copy for OptionStability { }Copy, #[automatically_derived]
impl ::core::clone::Clone for OptionStability {
#[inline]
fn clone(&self) -> OptionStability { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for OptionStability {
#[inline]
fn eq(&self, other: &OptionStability) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for OptionStability {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for OptionStability {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
OptionStability::Stable => "Stable",
OptionStability::Unstable => "Unstable",
})
}
}Debug)]
1700pub enum OptionStability {
1701 Stable,
1702 Unstable,
1703}
1704
1705#[derive(#[automatically_derived]
impl ::core::marker::Copy for OptionKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for OptionKind {
#[inline]
fn clone(&self) -> OptionKind { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for OptionKind {
#[inline]
fn eq(&self, other: &OptionKind) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for OptionKind {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for OptionKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
OptionKind::Opt => "Opt",
OptionKind::Multi => "Multi",
OptionKind::Flag => "Flag",
OptionKind::FlagMulti => "FlagMulti",
})
}
}Debug)]
1706pub enum OptionKind {
1707 Opt,
1711
1712 Multi,
1716
1717 Flag,
1722
1723 FlagMulti,
1728}
1729
1730pub struct RustcOptGroup {
1731 pub name: &'static str,
1739 stability: OptionStability,
1740 kind: OptionKind,
1741
1742 short_name: &'static str,
1743 long_name: &'static str,
1744 desc: &'static str,
1745 value_hint: &'static str,
1746
1747 pub is_verbose_help_only: bool,
1750}
1751
1752impl RustcOptGroup {
1753 pub fn is_stable(&self) -> bool {
1754 self.stability == OptionStability::Stable
1755 }
1756
1757 pub fn apply(&self, options: &mut getopts::Options) {
1758 let &Self { short_name, long_name, desc, value_hint, .. } = self;
1759 match self.kind {
1760 OptionKind::Opt => options.optopt(short_name, long_name, desc, value_hint),
1761 OptionKind::Multi => options.optmulti(short_name, long_name, desc, value_hint),
1762 OptionKind::Flag => options.optflag(short_name, long_name, desc),
1763 OptionKind::FlagMulti => options.optflagmulti(short_name, long_name, desc),
1764 };
1765 }
1766
1767 pub fn long_name(&self) -> &str {
1769 self.long_name
1770 }
1771}
1772
1773pub fn make_opt(
1774 stability: OptionStability,
1775 kind: OptionKind,
1776 short_name: &'static str,
1777 long_name: &'static str,
1778 desc: &'static str,
1779 value_hint: &'static str,
1780) -> RustcOptGroup {
1781 match kind {
1783 OptionKind::Opt | OptionKind::Multi => {}
1784 OptionKind::Flag | OptionKind::FlagMulti => {
match (&value_hint, &"") {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val,
&*right_val, ::core::option::Option::None);
}
}
}
}assert_eq!(value_hint, ""),
1785 }
1786 RustcOptGroup {
1787 name: cmp::max_by_key(short_name, long_name, |s| s.len()),
1788 stability,
1789 kind,
1790 short_name,
1791 long_name,
1792 desc,
1793 value_hint,
1794 is_verbose_help_only: false,
1795 }
1796}
1797
1798static EDITION_STRING: LazyLock<String> = LazyLock::new(|| {
1799 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("Specify which edition of the compiler to use when compiling code. The default is {0} and the latest stable edition is {1}.",
DEFAULT_EDITION, LATEST_STABLE_EDITION))
})format!(
1800 "Specify which edition of the compiler to use when compiling code. \
1801The default is {DEFAULT_EDITION} and the latest stable edition is {LATEST_STABLE_EDITION}."
1802 )
1803});
1804
1805static EMIT_HELP: LazyLock<String> = LazyLock::new(|| {
1806 let mut result =
1807 String::from("Comma separated list of types of output for the compiler to emit.\n");
1808 result.push_str("Each TYPE has the default FILE name:\n");
1809
1810 for output in OutputType::iter_all() {
1811 result.push_str(&::alloc::__export::must_use({
::alloc::fmt::format(format_args!("* {0} - {1}\n",
output.shorthand(), output.default_filename()))
})format!("* {} - {}\n", output.shorthand(), output.default_filename()));
1812 }
1813
1814 result
1815});
1816
1817pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
1827 use OptionKind::{Flag, FlagMulti, Multi, Opt};
1828 use OptionStability::{Stable, Unstable};
1829
1830 use self::make_opt as opt;
1831
1832 let mut options = ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[opt(Stable, Flag, "h", "help", "Display this message", ""),
opt(Stable, Multi, "", "cfg",
"Configure the compilation environment.\n\
SPEC supports the syntax `<NAME>[=\"<VALUE>\"]`.",
"<SPEC>"),
opt(Stable, Multi, "", "check-cfg",
"Provide list of expected cfgs for checking", "<SPEC>"),
opt(Stable, Multi, "L", "",
"Add a directory to the library search path. \
The optional KIND can be one of <dependency|crate|native|framework|all> (default: all).",
"[<KIND>=]<PATH>"),
opt(Stable, Multi, "l", "",
"Link the generated crate(s) to the specified native\n\
library NAME. The optional KIND can be one of\n\
<static|framework|dylib> (default: dylib).\n\
Optional comma separated MODIFIERS\n\
<bundle|verbatim|whole-archive|as-needed>\n\
may be specified each with a prefix of either '+' to\n\
enable or '-' to disable.",
"[<KIND>[:<MODIFIERS>]=]<NAME>[:<RENAME>]"),
make_crate_type_option(),
opt(Stable, Opt, "", "crate-name",
"Specify the name of the crate being built", "<NAME>"),
opt(Stable, Opt, "", "edition", &EDITION_STRING,
EDITION_NAME_LIST),
opt(Stable, Multi, "", "emit", &EMIT_HELP, "<TYPE>[=<FILE>]"),
opt(Stable, Multi, "", "print", &print_request::PRINT_HELP,
"<INFO>[=<FILE>]"),
opt(Stable, FlagMulti, "g", "",
"Equivalent to -C debuginfo=2", ""),
opt(Stable, FlagMulti, "O", "",
"Equivalent to -C opt-level=3", ""),
opt(Stable, Opt, "o", "", "Write output to FILENAME",
"<FILENAME>"),
opt(Stable, Opt, "", "out-dir",
"Write output to compiler-chosen filename in DIR", "<DIR>"),
opt(Stable, Opt, "", "explain",
"Provide a detailed explanation of an error message",
"<OPT>"),
opt(Stable, Flag, "", "test", "Build a test harness", ""),
opt(Stable, Opt, "", "target",
"Target tuple for which the code is compiled", "<TARGET>"),
opt(Stable, Multi, "A", "allow", "Set lint allowed",
"<LINT>"),
opt(Stable, Multi, "W", "warn", "Set lint warnings",
"<LINT>"),
opt(Stable, Multi, "", "force-warn", "Set lint force-warn",
"<LINT>"),
opt(Stable, Multi, "D", "deny", "Set lint denied", "<LINT>"),
opt(Stable, Multi, "F", "forbid", "Set lint forbidden",
"<LINT>"),
opt(Stable, Multi, "", "cap-lints",
"Set the most restrictive lint level. More restrictive lints are capped at this level",
"<LEVEL>"),
opt(Stable, Multi, "C", "codegen", "Set a codegen option",
"<OPT>[=<VALUE>]"),
opt(Stable, Flag, "V", "version",
"Print version info and exit", ""),
opt(Stable, Flag, "v", "verbose", "Use verbose output", "")]))vec![
1833 opt(Stable, Flag, "h", "help", "Display this message", ""),
1834 opt(
1835 Stable,
1836 Multi,
1837 "",
1838 "cfg",
1839 "Configure the compilation environment.\n\
1840 SPEC supports the syntax `<NAME>[=\"<VALUE>\"]`.",
1841 "<SPEC>",
1842 ),
1843 opt(Stable, Multi, "", "check-cfg", "Provide list of expected cfgs for checking", "<SPEC>"),
1844 opt(
1845 Stable,
1846 Multi,
1847 "L",
1848 "",
1849 "Add a directory to the library search path. \
1850 The optional KIND can be one of <dependency|crate|native|framework|all> (default: all).",
1851 "[<KIND>=]<PATH>",
1852 ),
1853 opt(
1854 Stable,
1855 Multi,
1856 "l",
1857 "",
1858 "Link the generated crate(s) to the specified native\n\
1859 library NAME. The optional KIND can be one of\n\
1860 <static|framework|dylib> (default: dylib).\n\
1861 Optional comma separated MODIFIERS\n\
1862 <bundle|verbatim|whole-archive|as-needed>\n\
1863 may be specified each with a prefix of either '+' to\n\
1864 enable or '-' to disable.",
1865 "[<KIND>[:<MODIFIERS>]=]<NAME>[:<RENAME>]",
1866 ),
1867 make_crate_type_option(),
1868 opt(Stable, Opt, "", "crate-name", "Specify the name of the crate being built", "<NAME>"),
1869 opt(Stable, Opt, "", "edition", &EDITION_STRING, EDITION_NAME_LIST),
1870 opt(Stable, Multi, "", "emit", &EMIT_HELP, "<TYPE>[=<FILE>]"),
1871 opt(Stable, Multi, "", "print", &print_request::PRINT_HELP, "<INFO>[=<FILE>]"),
1872 opt(Stable, FlagMulti, "g", "", "Equivalent to -C debuginfo=2", ""),
1873 opt(Stable, FlagMulti, "O", "", "Equivalent to -C opt-level=3", ""),
1874 opt(Stable, Opt, "o", "", "Write output to FILENAME", "<FILENAME>"),
1875 opt(Stable, Opt, "", "out-dir", "Write output to compiler-chosen filename in DIR", "<DIR>"),
1876 opt(
1877 Stable,
1878 Opt,
1879 "",
1880 "explain",
1881 "Provide a detailed explanation of an error message",
1882 "<OPT>",
1883 ),
1884 opt(Stable, Flag, "", "test", "Build a test harness", ""),
1885 opt(Stable, Opt, "", "target", "Target tuple for which the code is compiled", "<TARGET>"),
1886 opt(Stable, Multi, "A", "allow", "Set lint allowed", "<LINT>"),
1887 opt(Stable, Multi, "W", "warn", "Set lint warnings", "<LINT>"),
1888 opt(Stable, Multi, "", "force-warn", "Set lint force-warn", "<LINT>"),
1889 opt(Stable, Multi, "D", "deny", "Set lint denied", "<LINT>"),
1890 opt(Stable, Multi, "F", "forbid", "Set lint forbidden", "<LINT>"),
1891 opt(
1892 Stable,
1893 Multi,
1894 "",
1895 "cap-lints",
1896 "Set the most restrictive lint level. More restrictive lints are capped at this level",
1897 "<LEVEL>",
1898 ),
1899 opt(Stable, Multi, "C", "codegen", "Set a codegen option", "<OPT>[=<VALUE>]"),
1900 opt(Stable, Flag, "V", "version", "Print version info and exit", ""),
1901 opt(Stable, Flag, "v", "verbose", "Use verbose output", ""),
1902 ];
1903
1904 let verbose_only = [
1907 opt(
1908 Stable,
1909 Multi,
1910 "",
1911 "extern",
1912 "Specify where an external rust library is located",
1913 "<NAME>[=<PATH>]",
1914 ),
1915 opt(Stable, Opt, "", "sysroot", "Override the system root", "<PATH>"),
1916 opt(Unstable, Multi, "Z", "", "Set unstable / perma-unstable options", "<FLAG>"),
1917 opt(
1918 Stable,
1919 Opt,
1920 "",
1921 "error-format",
1922 "How errors and other messages are produced",
1923 "<human|json|short>",
1924 ),
1925 opt(Stable, Multi, "", "json", "Configure the JSON output of the compiler", "<CONFIG>"),
1926 opt(
1927 Stable,
1928 Opt,
1929 "",
1930 "color",
1931 "Configure coloring of output:
1932 * auto = colorize, if output goes to a tty (default);
1933 * always = always colorize output;
1934 * never = never colorize output",
1935 "<auto|always|never>",
1936 ),
1937 opt(
1938 Stable,
1939 Opt,
1940 "",
1941 "diagnostic-width",
1942 "Inform rustc of the width of the output so that diagnostics can be truncated to fit",
1943 "<WIDTH>",
1944 ),
1945 opt(
1946 Stable,
1947 Multi,
1948 "",
1949 "remap-path-prefix",
1950 "Remap source names in all output (compiler messages and output files)",
1951 "<FROM>=<TO>",
1952 ),
1953 opt(
1954 Stable,
1955 Opt,
1956 "",
1957 "remap-path-scope",
1958 "Defines which scopes of paths should be remapped by `--remap-path-prefix`",
1959 "<macro,diagnostics,debuginfo,coverage,object,all>",
1960 ),
1961 opt(Unstable, Multi, "", "env-set", "Inject an environment variable", "<VAR>=<VALUE>"),
1962 ];
1963 options.extend(verbose_only.into_iter().map(|mut opt| {
1964 opt.is_verbose_help_only = true;
1965 opt
1966 }));
1967
1968 options
1969}
1970
1971pub fn get_cmd_lint_options(
1972 early_dcx: &EarlyDiagCtxt,
1973 matches: &getopts::Matches,
1974) -> (Vec<(String, lint::Level)>, bool, Option<lint::Level>) {
1975 let mut lint_opts_with_position = ::alloc::vec::Vec::new()vec![];
1976 let mut describe_lints = false;
1977
1978 for level in [lint::Allow, lint::Warn, lint::ForceWarn, lint::Deny, lint::Forbid] {
1979 for (arg_pos, lint_name) in matches.opt_strs_pos(level.as_str()) {
1980 if lint_name == "help" {
1981 describe_lints = true;
1982 } else {
1983 lint_opts_with_position.push((arg_pos, lint_name.replace('-', "_"), level));
1984 }
1985 }
1986 }
1987
1988 lint_opts_with_position.sort_by_key(|x| x.0);
1989 let lint_opts = lint_opts_with_position
1990 .iter()
1991 .cloned()
1992 .map(|(_, lint_name, level)| (lint_name, level))
1993 .collect();
1994
1995 let lint_cap = matches.opt_str("cap-lints").map(|cap| {
1996 lint::Level::from_str(&cap)
1997 .unwrap_or_else(|| early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("unknown lint level: `{0}`", cap))
})format!("unknown lint level: `{cap}`")))
1998 });
1999
2000 (lint_opts, describe_lints, lint_cap)
2001}
2002
2003pub fn parse_color(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> ColorConfig {
2005 match matches.opt_str("color").as_deref() {
2006 Some("auto") => ColorConfig::Auto,
2007 Some("always") => ColorConfig::Always,
2008 Some("never") => ColorConfig::Never,
2009
2010 None => ColorConfig::Auto,
2011
2012 Some(arg) => early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("argument for `--color` must be auto, always or never (instead was `{0}`)",
arg))
})format!(
2013 "argument for `--color` must be auto, \
2014 always or never (instead was `{arg}`)"
2015 )),
2016 }
2017}
2018
2019pub struct JsonConfig {
2021 pub json_rendered: HumanReadableErrorType,
2022 pub json_color: ColorConfig,
2023 json_artifact_notifications: bool,
2024 json_timings: bool,
2027 pub json_unused_externs: JsonUnusedExterns,
2028 json_future_incompat: bool,
2029}
2030
2031#[derive(#[automatically_derived]
impl ::core::marker::Copy for JsonUnusedExterns { }Copy, #[automatically_derived]
impl ::core::clone::Clone for JsonUnusedExterns {
#[inline]
fn clone(&self) -> JsonUnusedExterns { *self }
}Clone)]
2033pub enum JsonUnusedExterns {
2034 No,
2036 Silent,
2038 Loud,
2040}
2041
2042impl JsonUnusedExterns {
2043 pub fn is_enabled(&self) -> bool {
2044 match self {
2045 JsonUnusedExterns::No => false,
2046 JsonUnusedExterns::Loud | JsonUnusedExterns::Silent => true,
2047 }
2048 }
2049
2050 pub fn is_loud(&self) -> bool {
2051 match self {
2052 JsonUnusedExterns::No | JsonUnusedExterns::Silent => false,
2053 JsonUnusedExterns::Loud => true,
2054 }
2055 }
2056}
2057
2058pub fn parse_json(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> JsonConfig {
2063 let mut json_rendered = HumanReadableErrorType { short: false, unicode: false };
2064 let mut json_color = ColorConfig::Never;
2065 let mut json_artifact_notifications = false;
2066 let mut json_unused_externs = JsonUnusedExterns::No;
2067 let mut json_future_incompat = false;
2068 let mut json_timings = false;
2069 for option in matches.opt_strs("json") {
2070 if matches.opt_str("color").is_some() {
2074 early_dcx.early_fatal("cannot specify the `--color` option with `--json`");
2075 }
2076
2077 for sub_option in option.split(',') {
2078 match sub_option {
2079 "diagnostic-short" => {
2080 json_rendered = HumanReadableErrorType { short: true, unicode: false };
2081 }
2082 "diagnostic-unicode" => {
2083 json_rendered = HumanReadableErrorType { short: false, unicode: true };
2084 }
2085 "diagnostic-rendered-ansi" => json_color = ColorConfig::Always,
2086 "artifacts" => json_artifact_notifications = true,
2087 "timings" => json_timings = true,
2088 "unused-externs" => json_unused_externs = JsonUnusedExterns::Loud,
2089 "unused-externs-silent" => json_unused_externs = JsonUnusedExterns::Silent,
2090 "future-incompat" => json_future_incompat = true,
2091 s => early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("unknown `--json` option `{0}`", s))
})format!("unknown `--json` option `{s}`")),
2092 }
2093 }
2094 }
2095
2096 JsonConfig {
2097 json_rendered,
2098 json_color,
2099 json_artifact_notifications,
2100 json_timings,
2101 json_unused_externs,
2102 json_future_incompat,
2103 }
2104}
2105
2106pub fn parse_error_format(
2108 early_dcx: &mut EarlyDiagCtxt,
2109 matches: &getopts::Matches,
2110 color_config: ColorConfig,
2111 json_color: ColorConfig,
2112 json_rendered: HumanReadableErrorType,
2113) -> ErrorOutputType {
2114 let default_kind = HumanReadableErrorType { short: false, unicode: false };
2115 let error_format = if matches.opts_present(&["error-format".to_owned()]) {
2120 match matches.opt_str("error-format").as_deref() {
2121 None | Some("human") => {
2122 ErrorOutputType::HumanReadable { color_config, kind: default_kind }
2123 }
2124 Some("json") => {
2125 ErrorOutputType::Json { pretty: false, json_rendered, color_config: json_color }
2126 }
2127 Some("pretty-json") => {
2128 ErrorOutputType::Json { pretty: true, json_rendered, color_config: json_color }
2129 }
2130 Some("short") => ErrorOutputType::HumanReadable {
2131 kind: HumanReadableErrorType { short: true, unicode: false },
2132 color_config,
2133 },
2134 Some("human-unicode") => ErrorOutputType::HumanReadable {
2135 kind: HumanReadableErrorType { short: false, unicode: true },
2136 color_config,
2137 },
2138 Some(arg) => {
2139 early_dcx.set_error_format(ErrorOutputType::HumanReadable {
2140 color_config,
2141 kind: default_kind,
2142 });
2143 early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("argument for `--error-format` must be `human`, `human-unicode`, `json`, `pretty-json` or `short` (instead was `{0}`)",
arg))
})format!(
2144 "argument for `--error-format` must be `human`, `human-unicode`, \
2145 `json`, `pretty-json` or `short` (instead was `{arg}`)"
2146 ))
2147 }
2148 }
2149 } else {
2150 ErrorOutputType::HumanReadable { color_config, kind: default_kind }
2151 };
2152
2153 match error_format {
2154 ErrorOutputType::Json { .. } => {}
2155
2156 _ if !matches.opt_strs("json").is_empty() => {
2160 early_dcx.early_fatal("using `--json` requires also using `--error-format=json`");
2161 }
2162
2163 _ => {}
2164 }
2165
2166 error_format
2167}
2168
2169pub fn parse_crate_edition(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> Edition {
2170 let edition = match matches.opt_str("edition") {
2171 Some(arg) => Edition::from_str(&arg).unwrap_or_else(|_| {
2172 early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("argument for `--edition` must be one of: {0}. (instead was `{1}`)",
EDITION_NAME_LIST, arg))
})format!(
2173 "argument for `--edition` must be one of: \
2174 {EDITION_NAME_LIST}. (instead was `{arg}`)"
2175 ))
2176 }),
2177 None => DEFAULT_EDITION,
2178 };
2179
2180 if !edition.is_stable() && !nightly_options::is_unstable_enabled(matches) {
2181 let is_nightly = nightly_options::match_is_nightly_build(matches);
2182 let msg = if !is_nightly {
2183 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("the crate requires edition {0}, but the latest edition supported by this Rust version is {1}",
edition, LATEST_STABLE_EDITION))
})format!(
2184 "the crate requires edition {edition}, but the latest edition supported by this Rust version is {LATEST_STABLE_EDITION}"
2185 )
2186 } else {
2187 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("edition {0} is unstable and only available with -Z unstable-options",
edition))
})format!("edition {edition} is unstable and only available with -Z unstable-options")
2188 };
2189 early_dcx.early_fatal(msg)
2190 }
2191
2192 edition
2193}
2194
2195fn check_error_format_stability(
2196 early_dcx: &EarlyDiagCtxt,
2197 unstable_opts: &UnstableOptions,
2198 is_nightly_build: bool,
2199 format: ErrorOutputType,
2200) {
2201 if unstable_opts.unstable_options || is_nightly_build {
2202 return;
2203 }
2204 let format = match format {
2205 ErrorOutputType::Json { pretty: true, .. } => "pretty-json",
2206 ErrorOutputType::HumanReadable { kind, .. } => match kind {
2207 HumanReadableErrorType { unicode: true, .. } => "human-unicode",
2208 _ => return,
2209 },
2210 _ => return,
2211 };
2212 early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`--error-format={0}` is unstable",
format))
})format!("`--error-format={format}` is unstable"))
2213}
2214
2215fn parse_output_types(
2216 early_dcx: &EarlyDiagCtxt,
2217 unstable_opts: &UnstableOptions,
2218 matches: &getopts::Matches,
2219) -> OutputTypes {
2220 let mut output_types = BTreeMap::new();
2221 if !unstable_opts.parse_crate_root_only {
2222 for list in matches.opt_strs("emit") {
2223 for output_type in list.split(',') {
2224 let (shorthand, path) = split_out_file_name(output_type);
2225 let output_type = OutputType::from_shorthand(shorthand).unwrap_or_else(|| {
2226 early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("unknown emission type: `{1}` - expected one of: {0}",
OutputType::shorthands_display(), shorthand))
})format!(
2227 "unknown emission type: `{shorthand}` - expected one of: {display}",
2228 display = OutputType::shorthands_display(),
2229 ))
2230 });
2231 if output_type == OutputType::ThinLinkBitcode && !unstable_opts.unstable_options {
2232 early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} requested but -Zunstable-options not specified",
OutputType::ThinLinkBitcode.shorthand()))
})format!(
2233 "{} requested but -Zunstable-options not specified",
2234 OutputType::ThinLinkBitcode.shorthand()
2235 ));
2236 }
2237 output_types.insert(output_type, path);
2238 }
2239 }
2240 };
2241 if output_types.is_empty() {
2242 output_types.insert(OutputType::Exe, None);
2243 }
2244 OutputTypes(output_types)
2245}
2246
2247fn split_out_file_name(arg: &str) -> (&str, Option<OutFileName>) {
2248 match arg.split_once('=') {
2249 None => (arg, None),
2250 Some((kind, "-")) => (kind, Some(OutFileName::Stdout)),
2251 Some((kind, path)) => (kind, Some(OutFileName::Real(PathBuf::from(path)))),
2252 }
2253}
2254
2255fn should_override_cgus_and_disable_thinlto(
2256 early_dcx: &EarlyDiagCtxt,
2257 output_types: &OutputTypes,
2258 matches: &getopts::Matches,
2259 mut codegen_units: Option<usize>,
2260) -> (bool, Option<usize>) {
2261 let mut disable_local_thinlto = false;
2262 let incompatible: Vec<_> = output_types
2265 .0
2266 .iter()
2267 .map(|ot_path| ot_path.0)
2268 .filter(|ot| !ot.is_compatible_with_codegen_units_and_single_output_file())
2269 .map(|ot| ot.shorthand())
2270 .collect();
2271 if !incompatible.is_empty() {
2272 match codegen_units {
2273 Some(n) if n > 1 => {
2274 if matches.opt_present("o") {
2275 for ot in &incompatible {
2276 early_dcx.early_warn(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`--emit={0}` with `-o` incompatible with `-C codegen-units=N` for N > 1",
ot))
})format!(
2277 "`--emit={ot}` with `-o` incompatible with \
2278 `-C codegen-units=N` for N > 1",
2279 ));
2280 }
2281 early_dcx.early_warn("resetting to default -C codegen-units=1");
2282 codegen_units = Some(1);
2283 disable_local_thinlto = true;
2284 }
2285 }
2286 _ => {
2287 codegen_units = Some(1);
2288 disable_local_thinlto = true;
2289 }
2290 }
2291 }
2292
2293 if codegen_units == Some(0) {
2294 early_dcx.early_fatal("value for codegen units must be a positive non-zero integer");
2295 }
2296
2297 (disable_local_thinlto, codegen_units)
2298}
2299
2300pub fn parse_target_triple(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> TargetTuple {
2301 match matches.opt_str("target") {
2302 Some(target) if target.ends_with(".json") => {
2303 let path = Path::new(&target);
2304 TargetTuple::from_path(path).unwrap_or_else(|_| {
2305 early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("target file {0:?} does not exist",
path))
})format!("target file {path:?} does not exist"))
2306 })
2307 }
2308 Some(target) => TargetTuple::TargetTuple(target),
2309 _ => TargetTuple::from_tuple(host_tuple()),
2310 }
2311}
2312
2313fn parse_opt_level(
2314 early_dcx: &EarlyDiagCtxt,
2315 matches: &getopts::Matches,
2316 cg: &CodegenOptions,
2317) -> OptLevel {
2318 let max_o = matches.opt_positions("O").into_iter().max();
2325 let max_c = matches
2326 .opt_strs_pos("C")
2327 .into_iter()
2328 .flat_map(|(i, s)| {
2329 if let Some("opt-level") = s.split('=').next() { Some(i) } else { None }
2331 })
2332 .max();
2333 if max_o > max_c {
2334 OptLevel::Aggressive
2335 } else {
2336 match cg.opt_level.as_ref() {
2337 "0" => OptLevel::No,
2338 "1" => OptLevel::Less,
2339 "2" => OptLevel::More,
2340 "3" => OptLevel::Aggressive,
2341 "s" => OptLevel::Size,
2342 "z" => OptLevel::SizeMin,
2343 arg => {
2344 early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("optimization level needs to be between 0-3, s or z (instead was `{0}`)",
arg))
})format!(
2345 "optimization level needs to be \
2346 between 0-3, s or z (instead was `{arg}`)"
2347 ));
2348 }
2349 }
2350 }
2351}
2352
2353fn select_debuginfo(matches: &getopts::Matches, cg: &CodegenOptions) -> DebugInfo {
2354 let max_g = matches.opt_positions("g").into_iter().max();
2355 let max_c = matches
2356 .opt_strs_pos("C")
2357 .into_iter()
2358 .flat_map(|(i, s)| {
2359 if let Some("debuginfo") = s.split('=').next() { Some(i) } else { None }
2361 })
2362 .max();
2363 if max_g > max_c { DebugInfo::Full } else { cg.debuginfo }
2364}
2365
2366pub fn parse_externs(
2367 early_dcx: &EarlyDiagCtxt,
2368 matches: &getopts::Matches,
2369 unstable_opts: &UnstableOptions,
2370) -> Externs {
2371 let is_unstable_enabled = unstable_opts.unstable_options;
2372 let mut externs: BTreeMap<String, ExternEntry> = BTreeMap::new();
2373 for arg in matches.opt_strs("extern") {
2374 let ExternOpt { crate_name: name, path, options } =
2375 split_extern_opt(early_dcx, unstable_opts, &arg).unwrap_or_else(|e| e.emit());
2376
2377 let entry = externs.entry(name.to_owned());
2378
2379 use std::collections::btree_map::Entry;
2380
2381 let entry = if let Some(path) = path {
2382 let path = CanonicalizedPath::new(path);
2384 match entry {
2385 Entry::Vacant(vacant) => {
2386 let files = BTreeSet::from_iter(iter::once(path));
2387 vacant.insert(ExternEntry::new(ExternLocation::ExactPaths(files)))
2388 }
2389 Entry::Occupied(occupied) => {
2390 let ext_ent = occupied.into_mut();
2391 match ext_ent {
2392 ExternEntry { location: ExternLocation::ExactPaths(files), .. } => {
2393 files.insert(path);
2394 }
2395 ExternEntry {
2396 location: location @ ExternLocation::FoundInLibrarySearchDirectories,
2397 ..
2398 } => {
2399 let files = BTreeSet::from_iter(iter::once(path));
2401 *location = ExternLocation::ExactPaths(files);
2402 }
2403 }
2404 ext_ent
2405 }
2406 }
2407 } else {
2408 match entry {
2410 Entry::Vacant(vacant) => {
2411 vacant.insert(ExternEntry::new(ExternLocation::FoundInLibrarySearchDirectories))
2412 }
2413 Entry::Occupied(occupied) => {
2414 occupied.into_mut()
2416 }
2417 }
2418 };
2419
2420 let mut is_private_dep = false;
2421 let mut add_prelude = true;
2422 let mut nounused_dep = false;
2423 let mut force = false;
2424 if let Some(opts) = options {
2425 if !is_unstable_enabled {
2426 early_dcx.early_fatal(
2427 "the `-Z unstable-options` flag must also be passed to \
2428 enable `--extern` options",
2429 );
2430 }
2431 for opt in opts.split(',') {
2432 match opt {
2433 "priv" => is_private_dep = true,
2434 "noprelude" => {
2435 if let ExternLocation::ExactPaths(_) = &entry.location {
2436 add_prelude = false;
2437 } else {
2438 early_dcx.early_fatal(
2439 "the `noprelude` --extern option requires a file path",
2440 );
2441 }
2442 }
2443 "nounused" => nounused_dep = true,
2444 "force" => force = true,
2445 _ => early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("unknown --extern option `{0}`",
opt))
})format!("unknown --extern option `{opt}`")),
2446 }
2447 }
2448 }
2449
2450 entry.is_private_dep |= is_private_dep;
2453 entry.nounused_dep |= nounused_dep;
2455 entry.force |= force;
2457 entry.add_prelude |= add_prelude;
2459 }
2460 Externs(externs)
2461}
2462
2463fn parse_remap_path_prefix(
2464 early_dcx: &EarlyDiagCtxt,
2465 matches: &getopts::Matches,
2466) -> Vec<(PathBuf, PathBuf)> {
2467 matches
2468 .opt_strs("remap-path-prefix")
2469 .into_iter()
2470 .map(|remap| match remap.rsplit_once('=') {
2471 None => {
2472 early_dcx.early_fatal("--remap-path-prefix must contain '=' between FROM and TO")
2473 }
2474 Some((from, to)) => (PathBuf::from(from), PathBuf::from(to)),
2475 })
2476 .collect()
2477}
2478
2479fn parse_logical_env(
2480 early_dcx: &EarlyDiagCtxt,
2481 matches: &getopts::Matches,
2482) -> FxIndexMap<String, String> {
2483 let mut vars = FxIndexMap::default();
2484
2485 for arg in matches.opt_strs("env-set") {
2486 if let Some((name, val)) = arg.split_once('=') {
2487 vars.insert(name.to_string(), val.to_string());
2488 } else {
2489 early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`--env-set`: specify value for variable `{0}`",
arg))
})format!("`--env-set`: specify value for variable `{arg}`"));
2490 }
2491 }
2492
2493 vars
2494}
2495
2496#[allow(rustc::bad_opt_access)]
2498pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::Matches) -> Options {
2499 let color = parse_color(early_dcx, matches);
2500
2501 let edition = parse_crate_edition(early_dcx, matches);
2502
2503 let crate_name = matches.opt_str("crate-name");
2504 let unstable_features = UnstableFeatures::from_environment(crate_name.as_deref());
2505 let JsonConfig {
2506 json_rendered,
2507 json_color,
2508 json_artifact_notifications,
2509 json_timings,
2510 json_unused_externs,
2511 json_future_incompat,
2512 } = parse_json(early_dcx, matches);
2513
2514 let error_format = parse_error_format(early_dcx, matches, color, json_color, json_rendered);
2515
2516 early_dcx.set_error_format(error_format);
2517
2518 let diagnostic_width = matches.opt_get("diagnostic-width").unwrap_or_else(|_| {
2519 early_dcx.early_fatal("`--diagnostic-width` must be an positive integer");
2520 });
2521
2522 let unparsed_crate_types = matches.opt_strs("crate-type");
2523 let crate_types = parse_crate_types_from_list(unparsed_crate_types)
2524 .unwrap_or_else(|e| early_dcx.early_fatal(e));
2525
2526 let mut collected_options = Default::default();
2527
2528 let mut unstable_opts = UnstableOptions::build(early_dcx, matches, &mut collected_options);
2529
2530 if unstable_opts.staticlib_hide_internal_symbols && !crate_types.contains(&CrateType::StaticLib)
2531 {
2532 early_dcx.early_warn(
2533 "-Zstaticlib-hide-internal-symbols has no effect without `--crate-type staticlib`",
2534 );
2535 }
2536
2537 if unstable_opts.staticlib_rename_internal_symbols
2538 && !crate_types.contains(&CrateType::StaticLib)
2539 {
2540 early_dcx.early_warn(
2541 "-Zstaticlib-rename-internal-symbols has no effect without `--crate-type staticlib`",
2542 );
2543 }
2544
2545 let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(early_dcx, matches);
2546
2547 if !unstable_opts.unstable_options && json_timings {
2548 early_dcx.early_fatal("--json=timings is unstable and requires using `-Zunstable-options`");
2549 }
2550
2551 check_error_format_stability(
2552 early_dcx,
2553 &unstable_opts,
2554 unstable_features.is_nightly_build(),
2555 error_format,
2556 );
2557
2558 let output_types = parse_output_types(early_dcx, &unstable_opts, matches);
2559
2560 let mut cg = CodegenOptions::build(early_dcx, matches, &mut collected_options);
2561 let (disable_local_thinlto, codegen_units) = should_override_cgus_and_disable_thinlto(
2562 early_dcx,
2563 &output_types,
2564 matches,
2565 cg.codegen_units,
2566 );
2567
2568 if unstable_opts.threads == Some(parse::MAX_THREADS_CAP) {
2569 early_dcx.early_warn(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("number of threads was capped at {0}",
parse::MAX_THREADS_CAP))
})format!("number of threads was capped at {}", parse::MAX_THREADS_CAP));
2570 }
2571
2572 let incremental = cg.incremental.as_ref().map(PathBuf::from);
2573
2574 if cg.profile_generate.enabled() && cg.profile_use.is_some() {
2575 early_dcx.early_fatal("options `-C profile-generate` and `-C profile-use` are exclusive");
2576 }
2577
2578 if unstable_opts.profile_sample_use.is_some()
2579 && (cg.profile_generate.enabled() || cg.profile_use.is_some())
2580 {
2581 early_dcx.early_fatal(
2582 "option `-Z profile-sample-use` cannot be used with `-C profile-generate` or `-C profile-use`",
2583 );
2584 }
2585
2586 match cg.symbol_mangling_version {
2589 None | Some(SymbolManglingVersion::V0) => {}
2591
2592 Some(SymbolManglingVersion::Legacy) => {
2594 if !unstable_opts.unstable_options {
2595 early_dcx.early_fatal(
2596 "`-C symbol-mangling-version=legacy` requires `-Z unstable-options`",
2597 );
2598 }
2599 }
2600 Some(SymbolManglingVersion::Hashed) => {
2601 if !unstable_opts.unstable_options {
2602 early_dcx.early_fatal(
2603 "`-C symbol-mangling-version=hashed` requires `-Z unstable-options`",
2604 );
2605 }
2606 }
2607 }
2608
2609 if cg.instrument_coverage != InstrumentCoverage::No {
2610 if cg.profile_generate.enabled() || cg.profile_use.is_some() {
2611 early_dcx.early_fatal(
2612 "option `-C instrument-coverage` is not compatible with either `-C profile-use` \
2613 or `-C profile-generate`",
2614 );
2615 }
2616
2617 match cg.symbol_mangling_version {
2622 None => cg.symbol_mangling_version = Some(SymbolManglingVersion::V0),
2623 Some(SymbolManglingVersion::Legacy) => {
2624 early_dcx.early_warn(
2625 "-C instrument-coverage requires symbol mangling version `v0`, \
2626 but `-C symbol-mangling-version=legacy` was specified",
2627 );
2628 }
2629 Some(SymbolManglingVersion::V0) => {}
2630 Some(SymbolManglingVersion::Hashed) => {
2631 early_dcx.early_warn(
2632 "-C instrument-coverage requires symbol mangling version `v0`, \
2633 but `-C symbol-mangling-version=hashed` was specified",
2634 );
2635 }
2636 }
2637 }
2638
2639 if let Ok(graphviz_font) = std::env::var("RUSTC_GRAPHVIZ_FONT") {
2640 unstable_opts.graphviz_font = graphviz_font;
2643 }
2644
2645 if !cg.embed_bitcode {
2646 match cg.lto {
2647 LtoCli::No | LtoCli::Unspecified => {}
2648 LtoCli::Yes | LtoCli::NoParam | LtoCli::Thin | LtoCli::Fat => {
2649 early_dcx.early_fatal("options `-C embed-bitcode=no` and `-C lto` are incompatible")
2650 }
2651 }
2652 }
2653
2654 let unstable_options_enabled = nightly_options::is_unstable_enabled(matches);
2655 if !unstable_options_enabled && cg.force_frame_pointers == FramePointer::NonLeaf {
2656 early_dcx.early_fatal(
2657 "`-Cforce-frame-pointers=non-leaf` or `always` also requires `-Zunstable-options` \
2658 and a nightly compiler",
2659 )
2660 }
2661
2662 if !nightly_options::is_unstable_enabled(matches) && !unstable_opts.offload.is_empty() {
2663 early_dcx.early_fatal(
2664 "`-Zoffload=Enable` also requires `-Zunstable-options` \
2665 and a nightly compiler",
2666 )
2667 }
2668
2669 let target_triple = parse_target_triple(early_dcx, matches);
2670
2671 if !unstable_options_enabled {
2674 if let Err(error) = cg.link_self_contained.check_unstable_variants(&target_triple) {
2675 early_dcx.early_fatal(error);
2676 }
2677
2678 if let Some(flavor) = cg.linker_flavor {
2679 if flavor.is_unstable() {
2680 early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("the linker flavor `{0}` is unstable, the `-Z unstable-options` flag must also be passed to use the unstable values",
flavor.desc()))
})format!(
2681 "the linker flavor `{}` is unstable, the `-Z unstable-options` \
2682 flag must also be passed to use the unstable values",
2683 flavor.desc()
2684 ));
2685 }
2686 }
2687 }
2688
2689 if let Some(erroneous_components) = cg.link_self_contained.check_consistency() {
2692 let names: String = erroneous_components
2693 .into_iter()
2694 .map(|c| c.as_str().unwrap())
2695 .intersperse(", ")
2696 .collect();
2697 early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("some `-C link-self-contained` components were both enabled and disabled: {0}",
names))
})format!(
2698 "some `-C link-self-contained` components were both enabled and disabled: {names}"
2699 ));
2700 }
2701
2702 let prints = print_request::collect_print_requests(early_dcx, &mut cg, &unstable_opts, matches);
2703
2704 if unstable_opts.retpoline_external_thunk {
2706 unstable_opts.retpoline = true;
2707 collected_options.target_modifiers.insert(
2708 OptionsTargetModifiers::UnstableOptions(UnstableOptionsTargetModifiers::Retpoline),
2709 "true".to_string(),
2710 );
2711 }
2712
2713 let cg = cg;
2714
2715 let opt_level = parse_opt_level(early_dcx, matches, &cg);
2716 let debug_assertions = cg.debug_assertions.unwrap_or(opt_level == OptLevel::No);
2720 let debuginfo = select_debuginfo(matches, &cg);
2721
2722 if !unstable_options_enabled {
2723 if let Err(error) = cg.linker_features.check_unstable_variants(&target_triple) {
2724 early_dcx.early_fatal(error);
2725 }
2726 }
2727
2728 if !unstable_options_enabled && cg.panic == Some(PanicStrategy::ImmediateAbort) {
2729 early_dcx.early_fatal(
2730 "`-Cpanic=immediate-abort` requires `-Zunstable-options` and a nightly compiler",
2731 )
2732 }
2733
2734 let libs = parse_native_libs(early_dcx, &unstable_opts, unstable_features, matches);
2736
2737 let test = matches.opt_present("test");
2738
2739 if !cg.remark.is_empty() && debuginfo == DebugInfo::None {
2740 early_dcx.early_warn("-C remark requires \"-C debuginfo=n\" to show source locations");
2741 }
2742
2743 if cg.remark.is_empty() && unstable_opts.remark_dir.is_some() {
2744 early_dcx
2745 .early_warn("using -Z remark-dir without enabling remarks using e.g. -C remark=all");
2746 }
2747
2748 let externs = parse_externs(early_dcx, matches, &unstable_opts);
2749
2750 let remap_path_prefix = parse_remap_path_prefix(early_dcx, matches);
2751 let remap_path_scope = parse_remap_path_scope(early_dcx, matches, &unstable_opts);
2752
2753 let pretty = parse_pretty(early_dcx, &unstable_opts);
2754
2755 if unstable_opts.dump_dep_graph && !unstable_opts.query_dep_graph {
2757 early_dcx.early_fatal("can't dump dependency graph without `-Z query-dep-graph`");
2758 }
2759
2760 let logical_env = parse_logical_env(early_dcx, matches);
2761
2762 let sysroot = Sysroot::new(matches.opt_str("sysroot").map(PathBuf::from));
2763
2764 let real_source_base_dir = |suffix: &str, confirm: &str| {
2765 let mut candidate = sysroot.path().join(suffix);
2766 if let Ok(metadata) = candidate.symlink_metadata() {
2767 if metadata.file_type().is_symlink() {
2771 if let Ok(symlink_dest) = std::fs::read_link(&candidate) {
2772 candidate = symlink_dest;
2773 }
2774 }
2775 }
2776
2777 candidate.join(confirm).is_file().then_some(candidate)
2779 };
2780
2781 let real_rust_source_base_dir =
2782 real_source_base_dir("lib/rustlib/src/rust", "library/std/src/lib.rs");
2784
2785 let real_rustc_dev_source_base_dir =
2786 real_source_base_dir("lib/rustlib/rustc-src/rust", "compiler/rustc/src/main.rs");
2788
2789 let search_paths: Vec<SearchPath> = {
2794 let mut seen_search_paths = FxHashSet::default();
2795 let search_path_matches: Vec<String> = matches.opt_strs("L");
2796 search_path_matches
2797 .iter()
2798 .filter(|p| seen_search_paths.insert(*p))
2799 .map(|path| {
2800 SearchPath::from_cli_opt(
2801 sysroot.path(),
2802 &target_triple,
2803 early_dcx,
2804 &path,
2805 unstable_opts.unstable_options,
2806 )
2807 })
2808 .collect()
2809 };
2810
2811 let working_dir = {
2814 let working_dir = std::env::current_dir().unwrap_or_else(|e| {
2815 early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("Current directory is invalid: {0}",
e))
})format!("Current directory is invalid: {e}"));
2816 });
2817
2818 let file_mapping = file_path_mapping(
2819 remap_path_prefix.clone(),
2820 unstable_opts.remap_cwd_prefix.as_deref(),
2821 remap_path_scope,
2822 );
2823 file_mapping.to_real_filename(&RealFileName::empty(), &working_dir)
2824 };
2825
2826 let verbose = matches.opt_present("verbose") || unstable_opts.verbose_internals;
2827
2828 Options {
2829 crate_types,
2830 optimize: opt_level,
2831 debuginfo,
2832 lint_opts,
2833 lint_cap,
2834 describe_lints,
2835 output_types,
2836 search_paths,
2837 sysroot,
2838 target_triple,
2839 test,
2840 incremental,
2841 unstable_opts,
2842 prints,
2843 cg,
2844 error_format,
2845 diagnostic_width,
2846 externs,
2847 unstable_features,
2848 crate_name,
2849 libs,
2850 debug_assertions,
2851 actually_rustdoc: false,
2852 resolve_doc_links: ResolveDocLinks::ExportedMetadata,
2853 trimmed_def_paths: false,
2854 cli_forced_codegen_units: codegen_units,
2855 cli_forced_local_thinlto_off: disable_local_thinlto,
2856 remap_path_prefix,
2857 remap_path_scope,
2858 real_rust_source_base_dir,
2859 real_rustc_dev_source_base_dir,
2860 edition,
2861 json_artifact_notifications,
2862 json_timings,
2863 json_unused_externs,
2864 json_future_incompat,
2865 pretty,
2866 working_dir,
2867 color,
2868 logical_env,
2869 verbose,
2870 target_modifiers: collected_options.target_modifiers,
2871 mitigation_coverage_map: collected_options.mitigations,
2872 }
2873}
2874
2875fn parse_pretty(early_dcx: &EarlyDiagCtxt, unstable_opts: &UnstableOptions) -> Option<PpMode> {
2876 use PpMode::*;
2877
2878 let first = match unstable_opts.unpretty.as_deref()? {
2879 "normal" => Source(PpSourceMode::Normal),
2880 "expanded" => Source(PpSourceMode::Expanded),
2881 "expanded,identified" => Source(PpSourceMode::ExpandedIdentified),
2882 "expanded,hygiene" => Source(PpSourceMode::ExpandedHygiene),
2883 "ast-tree" => AstTree,
2884 "ast-tree,expanded" => AstTreeExpanded,
2885 "hir" => Hir(PpHirMode::Normal),
2886 "hir,identified" => Hir(PpHirMode::Identified),
2887 "hir,typed" => Hir(PpHirMode::Typed),
2888 "hir-tree" => HirTree,
2889 "thir-tree" => ThirTree,
2890 "thir-flat" => ThirFlat,
2891 "mir" => Mir,
2892 "stable-mir" => StableMir,
2893 "mir-cfg" => MirCFG,
2894 name => early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("argument to `unpretty` must be one of `normal`, `expanded`, `expanded,identified`, `expanded,hygiene`, `ast-tree`, `ast-tree,expanded`, `hir`, `hir,identified`, `hir,typed`, `hir-tree`, `thir-tree`, `thir-flat`, `mir`, `stable-mir`, or `mir-cfg`; got {0}",
name))
})format!(
2895 "argument to `unpretty` must be one of `normal`, \
2896 `expanded`, `expanded,identified`, `expanded,hygiene`, \
2897 `ast-tree`, `ast-tree,expanded`, `hir`, `hir,identified`, \
2898 `hir,typed`, `hir-tree`, `thir-tree`, `thir-flat`, `mir`, `stable-mir`, or \
2899 `mir-cfg`; got {name}"
2900 )),
2901 };
2902 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_session/src/config.rs:2902",
"rustc_session::config", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_session/src/config.rs"),
::tracing_core::__macro_support::Option::Some(2902u32),
::tracing_core::__macro_support::Option::Some("rustc_session::config"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("got unpretty option: {0:?}",
first) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("got unpretty option: {first:?}");
2903 Some(first)
2904}
2905
2906pub fn make_crate_type_option() -> RustcOptGroup {
2907 make_opt(
2908 OptionStability::Stable,
2909 OptionKind::Multi,
2910 "",
2911 "crate-type",
2912 "Comma separated list of types of crates
2913 for the compiler to emit",
2914 "<bin|lib|rlib|dylib|cdylib|staticlib|proc-macro>",
2915 )
2916}
2917
2918pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateType>, String> {
2919 let mut crate_types: Vec<CrateType> = Vec::new();
2920 for unparsed_crate_type in &list_list {
2921 for part in unparsed_crate_type.split(',') {
2922 let new_part = match part {
2923 "lib" => CrateType::default(),
2924 "rlib" => CrateType::Rlib,
2925 "staticlib" => CrateType::StaticLib,
2926 "dylib" => CrateType::Dylib,
2927 "cdylib" => CrateType::Cdylib,
2928 "bin" => CrateType::Executable,
2929 "proc-macro" => CrateType::ProcMacro,
2930 "sdylib" => CrateType::Sdylib,
2931 _ => {
2932 return Err(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("unknown crate type: `{0}`, expected one of: `lib`, `rlib`, `staticlib`, `dylib`, `cdylib`, `bin`, `proc-macro`",
part))
})format!(
2933 "unknown crate type: `{part}`, expected one of: \
2934 `lib`, `rlib`, `staticlib`, `dylib`, `cdylib`, `bin`, `proc-macro`",
2935 ));
2936 }
2937 };
2938 if !crate_types.contains(&new_part) {
2939 crate_types.push(new_part)
2940 }
2941 }
2942 }
2943
2944 Ok(crate_types)
2945}
2946
2947pub mod nightly_options {
2948 use rustc_feature::UnstableFeatures;
2949
2950 use super::{OptionStability, RustcOptGroup};
2951 use crate::EarlyDiagCtxt;
2952
2953 pub fn is_unstable_enabled(matches: &getopts::Matches) -> bool {
2954 match_is_nightly_build(matches)
2955 && matches.opt_strs("Z").iter().any(|x| *x == "unstable-options")
2956 }
2957
2958 pub fn match_is_nightly_build(matches: &getopts::Matches) -> bool {
2959 is_nightly_build(matches.opt_str("crate-name").as_deref())
2960 }
2961
2962 fn is_nightly_build(krate: Option<&str>) -> bool {
2963 UnstableFeatures::from_environment(krate).is_nightly_build()
2964 }
2965
2966 pub fn check_nightly_options(
2967 early_dcx: &EarlyDiagCtxt,
2968 matches: &getopts::Matches,
2969 flags: &[RustcOptGroup],
2970 ) {
2971 let has_z_unstable_option = matches.opt_strs("Z").iter().any(|x| *x == "unstable-options");
2972 let really_allows_unstable_options = match_is_nightly_build(matches);
2973 let mut nightly_options_on_stable = 0;
2974
2975 for opt in flags.iter() {
2976 if opt.stability == OptionStability::Stable {
2977 continue;
2978 }
2979 if !matches.opt_present(opt.name) {
2980 continue;
2981 }
2982 if opt.name != "Z" && !has_z_unstable_option {
2983 early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("the `-Z unstable-options` flag must also be passed to enable the flag `{0}`",
opt.name))
})format!(
2984 "the `-Z unstable-options` flag must also be passed to enable \
2985 the flag `{}`",
2986 opt.name
2987 ));
2988 }
2989 if really_allows_unstable_options {
2990 continue;
2991 }
2992 match opt.stability {
2993 OptionStability::Unstable => {
2994 nightly_options_on_stable += 1;
2995 let msg = ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("the option `{0}` is only accepted on the nightly compiler",
opt.name))
})format!(
2996 "the option `{}` is only accepted on the nightly compiler",
2997 opt.name
2998 );
2999 let _ = early_dcx.early_err(msg);
3001 }
3002 OptionStability::Stable => {}
3003 }
3004 }
3005 if nightly_options_on_stable > 0 {
3006 early_dcx
3007 .early_help("consider switching to a nightly toolchain: `rustup default nightly`");
3008 early_dcx.early_note("selecting a toolchain with `+toolchain` arguments require a rustup proxy; see <https://rust-lang.github.io/rustup/concepts/index.html>");
3009 early_dcx.early_note("for more information about Rust's stability policy, see <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html#unstable-features>");
3010 early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} nightly option{1} were parsed",
nightly_options_on_stable,
if nightly_options_on_stable > 1 { "s" } else { "" }))
})format!(
3011 "{} nightly option{} were parsed",
3012 nightly_options_on_stable,
3013 if nightly_options_on_stable > 1 { "s" } else { "" }
3014 ));
3015 }
3016 }
3017}
3018
3019#[derive(#[automatically_derived]
impl ::core::marker::Copy for PpSourceMode { }Copy, #[automatically_derived]
impl ::core::clone::Clone for PpSourceMode {
#[inline]
fn clone(&self) -> PpSourceMode { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for PpSourceMode {
#[inline]
fn eq(&self, other: &PpSourceMode) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for PpSourceMode {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
PpSourceMode::Normal => "Normal",
PpSourceMode::Expanded => "Expanded",
PpSourceMode::ExpandedIdentified => "ExpandedIdentified",
PpSourceMode::ExpandedHygiene => "ExpandedHygiene",
})
}
}Debug)]
3020pub enum PpSourceMode {
3021 Normal,
3023 Expanded,
3025 ExpandedIdentified,
3027 ExpandedHygiene,
3029}
3030
3031#[derive(#[automatically_derived]
impl ::core::marker::Copy for PpHirMode { }Copy, #[automatically_derived]
impl ::core::clone::Clone for PpHirMode {
#[inline]
fn clone(&self) -> PpHirMode { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for PpHirMode {
#[inline]
fn eq(&self, other: &PpHirMode) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for PpHirMode {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
PpHirMode::Normal => "Normal",
PpHirMode::Identified => "Identified",
PpHirMode::Typed => "Typed",
})
}
}Debug)]
3032pub enum PpHirMode {
3033 Normal,
3035 Identified,
3037 Typed,
3039}
3040
3041#[derive(#[automatically_derived]
impl ::core::marker::Copy for PpMode { }Copy, #[automatically_derived]
impl ::core::clone::Clone for PpMode {
#[inline]
fn clone(&self) -> PpMode {
let _: ::core::clone::AssertParamIsClone<PpSourceMode>;
let _: ::core::clone::AssertParamIsClone<PpHirMode>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for PpMode {
#[inline]
fn eq(&self, other: &PpMode) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(PpMode::Source(__self_0), PpMode::Source(__arg1_0)) =>
__self_0 == __arg1_0,
(PpMode::Hir(__self_0), PpMode::Hir(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for PpMode {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
PpMode::Source(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Source",
&__self_0),
PpMode::AstTree =>
::core::fmt::Formatter::write_str(f, "AstTree"),
PpMode::AstTreeExpanded =>
::core::fmt::Formatter::write_str(f, "AstTreeExpanded"),
PpMode::Hir(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Hir",
&__self_0),
PpMode::HirTree =>
::core::fmt::Formatter::write_str(f, "HirTree"),
PpMode::ThirTree =>
::core::fmt::Formatter::write_str(f, "ThirTree"),
PpMode::ThirFlat =>
::core::fmt::Formatter::write_str(f, "ThirFlat"),
PpMode::Mir => ::core::fmt::Formatter::write_str(f, "Mir"),
PpMode::MirCFG => ::core::fmt::Formatter::write_str(f, "MirCFG"),
PpMode::StableMir =>
::core::fmt::Formatter::write_str(f, "StableMir"),
}
}
}Debug)]
3042pub enum PpMode {
3044 Source(PpSourceMode),
3047 AstTree,
3049 AstTreeExpanded,
3051 Hir(PpHirMode),
3053 HirTree,
3055 ThirTree,
3057 ThirFlat,
3059 Mir,
3061 MirCFG,
3063 StableMir,
3065}
3066
3067impl PpMode {
3068 pub fn needs_ast_map(&self) -> bool {
3069 use PpMode::*;
3070 use PpSourceMode::*;
3071 match *self {
3072 Source(Normal) | AstTree => false,
3073
3074 Source(Expanded | ExpandedIdentified | ExpandedHygiene)
3075 | AstTreeExpanded
3076 | Hir(_)
3077 | HirTree
3078 | ThirTree
3079 | ThirFlat
3080 | Mir
3081 | MirCFG
3082 | StableMir => true,
3083 }
3084 }
3085
3086 pub fn needs_analysis(&self) -> bool {
3087 use PpMode::*;
3088 #[allow(non_exhaustive_omitted_patterns)] match *self {
Hir(PpHirMode::Typed) | Mir | StableMir | MirCFG | ThirTree | ThirFlat =>
true,
_ => false,
}matches!(*self, Hir(PpHirMode::Typed) | Mir | StableMir | MirCFG | ThirTree | ThirFlat)
3089 }
3090}
3091
3092#[derive(#[automatically_derived]
impl ::core::clone::Clone for WasiExecModel {
#[inline]
fn clone(&self) -> WasiExecModel {
match self {
WasiExecModel::Command => WasiExecModel::Command,
WasiExecModel::Reactor => WasiExecModel::Reactor,
}
}
}Clone, #[automatically_derived]
impl ::core::hash::Hash for WasiExecModel {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::cmp::PartialEq for WasiExecModel {
#[inline]
fn eq(&self, other: &WasiExecModel) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for WasiExecModel {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for WasiExecModel {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
WasiExecModel::Command => "Command",
WasiExecModel::Reactor => "Reactor",
})
}
}Debug)]
3093pub enum WasiExecModel {
3094 Command,
3095 Reactor,
3096}
3097
3098pub(crate) mod dep_tracking {
3117 use std::collections::BTreeMap;
3118 use std::hash::Hash;
3119 use std::num::NonZero;
3120 use std::path::PathBuf;
3121
3122 use rustc_abi::Align;
3123 use rustc_ast::attr::version::RustcVersion;
3124 use rustc_data_structures::fx::FxIndexMap;
3125 use rustc_data_structures::stable_hash::StableHasher;
3126 use rustc_errors::LanguageIdentifier;
3127 use rustc_feature::UnstableFeatures;
3128 use rustc_hashes::Hash64;
3129 use rustc_hir::attrs::CollapseMacroDebuginfo;
3130 use rustc_span::edition::Edition;
3131 use rustc_span::{RealFileName, RemapPathScopeComponents};
3132 use rustc_target::spec::{
3133 CodeModel, FramePointer, MergeFunctions, OnBrokenPipe, PanicStrategy, RelocModel,
3134 RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, SymbolVisibility, TargetTuple,
3135 TlsModel,
3136 };
3137
3138 use super::{
3139 AnnotateMoves, AutoDiff, BranchProtection, CFGuard, CFProtection, CodegenRetagOptions,
3140 CoverageOptions, CrateType, DebugInfo, DebugInfoCompression, ErrorOutputType, FmtDebug,
3141 FunctionReturn, InliningThreshold, InstrumentCoverage, InstrumentMcount, InstrumentXRay,
3142 LinkerPluginLto, LocationDetail, LtoCli, MirStripDebugInfo, NextSolverConfig, Offload,
3143 OptLevel, OutFileName, OutputType, OutputTypes, PatchableFunctionEntry, PointerAuthOption,
3144 Polonius, ResolveDocLinks, SourceFileHashAlgorithm, SplitDwarfKind, SwitchWithOptPath,
3145 SymbolManglingVersion, WasiExecModel,
3146 };
3147 use crate::lint;
3148 use crate::utils::NativeLib;
3149
3150 pub(crate) trait DepTrackingHash {
3151 fn hash(
3152 &self,
3153 hasher: &mut StableHasher,
3154 error_format: ErrorOutputType,
3155 for_crate_hash: bool,
3156 );
3157 }
3158
3159 macro_rules! impl_dep_tracking_hash_via_hash {
3160 ($($t:ty),+ $(,)?) => {$(
3161 impl DepTrackingHash for $t {
3162 fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType, _for_crate_hash: bool) {
3163 Hash::hash(self, hasher);
3164 }
3165 }
3166 )+};
3167 }
3168
3169 impl<T: DepTrackingHash> DepTrackingHash for Option<T> {
3170 fn hash(
3171 &self,
3172 hasher: &mut StableHasher,
3173 error_format: ErrorOutputType,
3174 for_crate_hash: bool,
3175 ) {
3176 match self {
3177 Some(x) => {
3178 Hash::hash(&1, hasher);
3179 DepTrackingHash::hash(x, hasher, error_format, for_crate_hash);
3180 }
3181 None => Hash::hash(&0, hasher),
3182 }
3183 }
3184 }
3185
3186 impl DepTrackingHash for PointerAuthOption {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}impl_dep_tracking_hash_via_hash!(
3187 (),
3188 AnnotateMoves,
3189 AutoDiff,
3190 Offload,
3191 bool,
3192 usize,
3193 NonZero<usize>,
3194 u64,
3195 Hash64,
3196 String,
3197 PathBuf,
3198 lint::Level,
3199 WasiExecModel,
3200 u32,
3201 FramePointer,
3202 RelocModel,
3203 CodeModel,
3204 TlsModel,
3205 InstrumentCoverage,
3206 CoverageOptions,
3207 InstrumentMcount,
3208 InstrumentXRay,
3209 CrateType,
3210 MergeFunctions,
3211 OnBrokenPipe,
3212 PanicStrategy,
3213 RelroLevel,
3214 OptLevel,
3215 LtoCli,
3216 DebugInfo,
3217 DebugInfoCompression,
3218 MirStripDebugInfo,
3219 CollapseMacroDebuginfo,
3220 UnstableFeatures,
3221 NativeLib,
3222 SanitizerSet,
3223 CFGuard,
3224 CFProtection,
3225 TargetTuple,
3226 Edition,
3227 LinkerPluginLto,
3228 ResolveDocLinks,
3229 SplitDebuginfo,
3230 SplitDwarfKind,
3231 StackProtector,
3232 SwitchWithOptPath,
3233 SymbolManglingVersion,
3234 SymbolVisibility,
3235 RemapPathScopeComponents,
3236 SourceFileHashAlgorithm,
3237 OutFileName,
3238 OutputType,
3239 RealFileName,
3240 LocationDetail,
3241 FmtDebug,
3242 BranchProtection,
3243 LanguageIdentifier,
3244 NextSolverConfig,
3245 PatchableFunctionEntry,
3246 Polonius,
3247 InliningThreshold,
3248 FunctionReturn,
3249 Align,
3250 CodegenRetagOptions,
3251 RustcVersion,
3252 PointerAuthOption,
3253 );
3254
3255 impl<T1, T2> DepTrackingHash for (T1, T2)
3256 where
3257 T1: DepTrackingHash,
3258 T2: DepTrackingHash,
3259 {
3260 fn hash(
3261 &self,
3262 hasher: &mut StableHasher,
3263 error_format: ErrorOutputType,
3264 for_crate_hash: bool,
3265 ) {
3266 Hash::hash(&0, hasher);
3267 DepTrackingHash::hash(&self.0, hasher, error_format, for_crate_hash);
3268 Hash::hash(&1, hasher);
3269 DepTrackingHash::hash(&self.1, hasher, error_format, for_crate_hash);
3270 }
3271 }
3272
3273 impl<T1, T2, T3> DepTrackingHash for (T1, T2, T3)
3274 where
3275 T1: DepTrackingHash,
3276 T2: DepTrackingHash,
3277 T3: DepTrackingHash,
3278 {
3279 fn hash(
3280 &self,
3281 hasher: &mut StableHasher,
3282 error_format: ErrorOutputType,
3283 for_crate_hash: bool,
3284 ) {
3285 Hash::hash(&0, hasher);
3286 DepTrackingHash::hash(&self.0, hasher, error_format, for_crate_hash);
3287 Hash::hash(&1, hasher);
3288 DepTrackingHash::hash(&self.1, hasher, error_format, for_crate_hash);
3289 Hash::hash(&2, hasher);
3290 DepTrackingHash::hash(&self.2, hasher, error_format, for_crate_hash);
3291 }
3292 }
3293
3294 impl<T: DepTrackingHash> DepTrackingHash for Vec<T> {
3295 fn hash(
3296 &self,
3297 hasher: &mut StableHasher,
3298 error_format: ErrorOutputType,
3299 for_crate_hash: bool,
3300 ) {
3301 Hash::hash(&self.len(), hasher);
3302 for (index, elem) in self.iter().enumerate() {
3303 Hash::hash(&index, hasher);
3304 DepTrackingHash::hash(elem, hasher, error_format, for_crate_hash);
3305 }
3306 }
3307 }
3308
3309 impl<T: DepTrackingHash, V: DepTrackingHash> DepTrackingHash for FxIndexMap<T, V> {
3310 fn hash(
3311 &self,
3312 hasher: &mut StableHasher,
3313 error_format: ErrorOutputType,
3314 for_crate_hash: bool,
3315 ) {
3316 Hash::hash(&self.len(), hasher);
3317 for (key, value) in self.iter() {
3318 DepTrackingHash::hash(key, hasher, error_format, for_crate_hash);
3319 DepTrackingHash::hash(value, hasher, error_format, for_crate_hash);
3320 }
3321 }
3322 }
3323
3324 impl DepTrackingHash for OutputTypes {
3325 fn hash(
3326 &self,
3327 hasher: &mut StableHasher,
3328 error_format: ErrorOutputType,
3329 for_crate_hash: bool,
3330 ) {
3331 Hash::hash(&self.0.len(), hasher);
3332 for (key, val) in &self.0 {
3333 DepTrackingHash::hash(key, hasher, error_format, for_crate_hash);
3334 if !for_crate_hash {
3335 DepTrackingHash::hash(val, hasher, error_format, for_crate_hash);
3336 }
3337 }
3338 }
3339 }
3340
3341 pub(crate) fn stable_hash(
3343 sub_hashes: BTreeMap<&'static str, &dyn DepTrackingHash>,
3344 hasher: &mut StableHasher,
3345 error_format: ErrorOutputType,
3346 for_crate_hash: bool,
3347 ) {
3348 for (key, sub_hash) in sub_hashes {
3349 Hash::hash(&key.len(), hasher);
3352 Hash::hash(key, hasher);
3353 sub_hash.hash(hasher, error_format, for_crate_hash);
3354 }
3355 }
3356}
3357
3358#[derive(#[automatically_derived]
impl ::core::clone::Clone for ProcMacroExecutionStrategy {
#[inline]
fn clone(&self) -> ProcMacroExecutionStrategy { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for ProcMacroExecutionStrategy { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for ProcMacroExecutionStrategy {
#[inline]
fn eq(&self, other: &ProcMacroExecutionStrategy) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for ProcMacroExecutionStrategy {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for ProcMacroExecutionStrategy {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
ProcMacroExecutionStrategy::SameThread => "SameThread",
ProcMacroExecutionStrategy::CrossThread => "CrossThread",
})
}
}Debug)]
3360pub enum ProcMacroExecutionStrategy {
3361 SameThread,
3363
3364 CrossThread,
3366}
3367
3368#[derive(#[automatically_derived]
impl ::core::clone::Clone for DumpMonoStatsFormat {
#[inline]
fn clone(&self) -> DumpMonoStatsFormat { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for DumpMonoStatsFormat { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for DumpMonoStatsFormat {
#[inline]
fn eq(&self, other: &DumpMonoStatsFormat) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for DumpMonoStatsFormat {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for DumpMonoStatsFormat {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
DumpMonoStatsFormat::Markdown => "Markdown",
DumpMonoStatsFormat::Json => "Json",
})
}
}Debug)]
3370pub enum DumpMonoStatsFormat {
3371 Markdown,
3373 Json,
3375}
3376
3377impl DumpMonoStatsFormat {
3378 pub fn extension(self) -> &'static str {
3379 match self {
3380 Self::Markdown => "md",
3381 Self::Json => "json",
3382 }
3383 }
3384}
3385
3386#[derive(#[automatically_derived]
impl ::core::clone::Clone for PatchableFunctionEntry {
#[inline]
fn clone(&self) -> PatchableFunctionEntry {
PatchableFunctionEntry {
prefix: ::core::clone::Clone::clone(&self.prefix),
entry: ::core::clone::Clone::clone(&self.entry),
section: ::core::clone::Clone::clone(&self.section),
}
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for PatchableFunctionEntry {
#[inline]
fn eq(&self, other: &PatchableFunctionEntry) -> bool {
self.prefix == other.prefix && self.entry == other.entry &&
self.section == other.section
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for PatchableFunctionEntry {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.prefix, state);
::core::hash::Hash::hash(&self.entry, state);
::core::hash::Hash::hash(&self.section, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for PatchableFunctionEntry {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"PatchableFunctionEntry", "prefix", &self.prefix, "entry",
&self.entry, "section", &&self.section)
}
}Debug, #[automatically_derived]
impl ::core::default::Default for PatchableFunctionEntry {
#[inline]
fn default() -> PatchableFunctionEntry {
PatchableFunctionEntry {
prefix: ::core::default::Default::default(),
entry: ::core::default::Default::default(),
section: ::core::default::Default::default(),
}
}
}Default)]
3389pub struct PatchableFunctionEntry {
3390 prefix: u8,
3392 entry: u8,
3394 section: Option<String>,
3396}
3397
3398impl PatchableFunctionEntry {
3399 pub fn from_parts(
3400 total_nops: u8,
3401 prefix_nops: u8,
3402 section: Option<String>,
3403 ) -> Option<PatchableFunctionEntry> {
3404 if total_nops < prefix_nops {
3405 None
3406 } else if section.as_ref().map(|x| x.contains('\0') || x.is_empty()).unwrap_or(false) {
3408 None
3409 } else {
3410 Some(Self { prefix: prefix_nops, entry: total_nops - prefix_nops, section })
3411 }
3412 }
3413 pub fn prefix(&self) -> u8 {
3414 self.prefix
3415 }
3416 pub fn entry(&self) -> u8 {
3417 self.entry
3418 }
3419 pub fn section(&self) -> Option<&str> {
3420 self.section.as_ref().map(|x| x.as_str())
3421 }
3422}
3423
3424#[derive(#[automatically_derived]
impl ::core::clone::Clone for Polonius {
#[inline]
fn clone(&self) -> Polonius { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Polonius { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for Polonius {
#[inline]
fn eq(&self, other: &Polonius) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for Polonius {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for Polonius {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
Polonius::Off => "Off",
Polonius::Legacy => "Legacy",
Polonius::Next => "Next",
})
}
}Debug, #[automatically_derived]
impl ::core::default::Default for Polonius {
#[inline]
fn default() -> Polonius { Self::Off }
}Default)]
3427pub enum Polonius {
3428 #[default]
3430 Off,
3431
3432 Legacy,
3434
3435 Next,
3437}
3438
3439impl Polonius {
3440 pub fn is_legacy_enabled(&self) -> bool {
3442 #[allow(non_exhaustive_omitted_patterns)] match self {
Polonius::Legacy => true,
_ => false,
}matches!(self, Polonius::Legacy)
3443 }
3444
3445 pub fn is_next_enabled(&self) -> bool {
3447 #[allow(non_exhaustive_omitted_patterns)] match self {
Polonius::Next => true,
_ => false,
}matches!(self, Polonius::Next)
3448 }
3449}
3450
3451#[derive(#[automatically_derived]
impl ::core::clone::Clone for InliningThreshold {
#[inline]
fn clone(&self) -> InliningThreshold {
let _: ::core::clone::AssertParamIsClone<usize>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for InliningThreshold { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for InliningThreshold {
#[inline]
fn eq(&self, other: &InliningThreshold) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(InliningThreshold::Sometimes(__self_0),
InliningThreshold::Sometimes(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for InliningThreshold {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
InliningThreshold::Sometimes(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
_ => {}
}
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for InliningThreshold {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
InliningThreshold::Always =>
::core::fmt::Formatter::write_str(f, "Always"),
InliningThreshold::Sometimes(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Sometimes", &__self_0),
InliningThreshold::Never =>
::core::fmt::Formatter::write_str(f, "Never"),
}
}
}Debug)]
3452pub enum InliningThreshold {
3453 Always,
3454 Sometimes(usize),
3455 Never,
3456}
3457
3458impl Default for InliningThreshold {
3459 fn default() -> Self {
3460 Self::Sometimes(100)
3461 }
3462}
3463
3464#[derive(#[automatically_derived]
impl ::core::clone::Clone for FunctionReturn {
#[inline]
fn clone(&self) -> FunctionReturn { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for FunctionReturn { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for FunctionReturn {
#[inline]
fn eq(&self, other: &FunctionReturn) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for FunctionReturn {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for FunctionReturn {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
FunctionReturn::Keep => "Keep",
FunctionReturn::ThunkExtern => "ThunkExtern",
})
}
}Debug, #[automatically_derived]
impl ::core::default::Default for FunctionReturn {
#[inline]
fn default() -> FunctionReturn { Self::Keep }
}Default)]
3466pub enum FunctionReturn {
3467 #[default]
3469 Keep,
3470
3471 ThunkExtern,
3473}
3474
3475#[derive(#[automatically_derived]
impl ::core::clone::Clone for MirIncludeSpans {
#[inline]
fn clone(&self) -> MirIncludeSpans { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for MirIncludeSpans { }Copy, #[automatically_derived]
impl ::core::default::Default for MirIncludeSpans {
#[inline]
fn default() -> MirIncludeSpans { Self::Nll }
}Default, #[automatically_derived]
impl ::core::cmp::PartialEq for MirIncludeSpans {
#[inline]
fn eq(&self, other: &MirIncludeSpans) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for MirIncludeSpans {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
MirIncludeSpans::Off => "Off",
MirIncludeSpans::On => "On",
MirIncludeSpans::Nll => "Nll",
})
}
}Debug)]
3478pub enum MirIncludeSpans {
3479 Off,
3480 On,
3481 #[default]
3484 Nll,
3485}
3486
3487impl MirIncludeSpans {
3488 pub fn is_enabled(self) -> bool {
3493 self == MirIncludeSpans::On
3494 }
3495}