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::num::NonZero;
11use std::path::{Path, PathBuf};
12use std::str::{self, FromStr};
13use std::sync::LazyLock;
14use std::{cmp, fs, iter, thread};
15
16use externs::{ExternOpt, split_extern_opt};
17use rustc_data_structures::fx::FxHashSet;
18use rustc_data_structures::stable_hash::{StableHasher, StableOrd};
19use rustc_errors::emitter::HumanReadableErrorType;
20use rustc_errors::{ColorConfig, DiagCtxtFlags};
21use rustc_feature::UnstableFeatures;
22use rustc_hashes::Hash64;
23use rustc_macros::{BlobDecodable, Decodable, Encodable, StableHash};
24use rustc_span::edition::{
25 DEFAULT_EDITION, EDITION_NAME_LIST, EDITION_NAME_LIST_STABLE, Edition, LATEST_STABLE_EDITION,
26};
27use rustc_span::source_map::FilePathMapping;
28use rustc_span::{
29 FileName, RealFileName, RemapPathScopeComponents, SourceFileHashAlgorithm, Symbol, sym,
30};
31use rustc_structures::CrateType;
32use rustc_target::spec::{
33 FramePointer, LinkSelfContainedComponents, LinkerFeatures, PanicStrategy, SplitDebuginfo,
34 Target, TargetTuple,
35};
36use tracing::debug;
37
38pub use crate::config::cfg::{Cfg, CheckCfg, ExpectedValues};
39use crate::config::native_libs::parse_native_libs;
40pub use crate::config::print_request::{
41 PrintCategory, PrintKind, PrintRequest, collect_print_requests,
42};
43use crate::diagnostics::FileWriteFail;
44use crate::macros::AllVariants;
45pub use crate::options::*;
46use crate::search_paths::SearchPath;
47use crate::utils::CanonicalizedPath;
48use crate::{EarlyDiagCtxt, Session, filesearch, lint};
49
50mod cfg;
51mod externs;
52mod native_libs;
53mod print_request;
54pub mod sigpipe;
55
56pub const DEFAULT_STACK_SIZE: usize = 17 * 1024 * 1024;
58
59pub const NATIVE_CPU: &str = "native";
61
62#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for Strip {
}
#[automatically_derived]impl ::core::clone::Clone for Strip {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for Strip { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for Strip { }
#[automatically_derived]impl ::core::cmp::PartialEq for Strip {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::hash::Hash for Strip {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
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)]
64pub enum Strip {
65 None,
67
68 Debuginfo,
70
71 Symbols,
73}
74
75#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for CFGuard {
}
#[automatically_derived]impl ::core::clone::Clone for CFGuard {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for CFGuard { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for CFGuard {
}
#[automatically_derived]impl ::core::cmp::PartialEq for CFGuard {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::hash::Hash for CFGuard {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
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)]
77pub enum CFGuard {
78 Disabled,
80
81 NoChecks,
83
84 Checks,
86}
87
88#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for CFProtection {
}
#[automatically_derived]impl ::core::clone::Clone for CFProtection {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for CFProtection { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
CFProtection {
}
#[automatically_derived]impl ::core::cmp::PartialEq for CFProtection {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::hash::Hash for CFProtection {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
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)]
90pub enum CFProtection {
91 None,
93
94 Branch,
96
97 Return,
99
100 Full,
102}
103
104#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for OptLevel {
}
#[automatically_derived]impl ::core::clone::Clone for OptLevel {
#[inline]
fn clone(&self) -> Self { *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::debug_c_like_enum_write_str(f,
"No Less More Aggressive Size SizeMin",
match self {
OptLevel::No => 0usize,
OptLevel::Less => 3usize,
OptLevel::More => 8usize,
OptLevel::Aggressive => 13usize,
OptLevel::Size => 24usize,
OptLevel::SizeMin => 29usize,
})
}
}Debug, #[automatically_derived]impl ::core::marker::StructuralPartialEq for OptLevel
{
}
#[automatically_derived]impl ::core::cmp::PartialEq for OptLevel {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::hash::Hash for OptLevel {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
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) {
match *self {
OptLevel::No => 0u8.stable_hash(__hcx, __hasher),
OptLevel::Less => 1u8.stable_hash(__hcx, __hasher),
OptLevel::More => 2u8.stable_hash(__hcx, __hasher),
OptLevel::Aggressive => 3u8.stable_hash(__hcx, __hasher),
OptLevel::Size => 4u8.stable_hash(__hcx, __hasher),
OptLevel::SizeMin => 5u8.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);
}
}
};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)]
105pub enum OptLevel {
106 No,
108 Less,
110 More,
112 Aggressive,
114 Size,
116 SizeMin,
118}
119
120impl OptLevel {
121 pub fn mir_opt_level(&self) -> usize {
124 match self {
125 OptLevel::No => 1,
126 _ => 2,
127 }
128 }
129
130 pub fn objective(&self) -> OptimizationObjective {
132 match self {
133 OptLevel::No => OptimizationObjective::None,
134 OptLevel::Less => OptimizationObjective::Balanced,
135 OptLevel::More | OptLevel::Aggressive => OptimizationObjective::Speed,
136 OptLevel::Size | OptLevel::SizeMin => OptimizationObjective::Size,
137 }
138 }
139}
140
141#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for OptimizationObjective {
}
#[automatically_derived]impl ::core::clone::Clone for OptimizationObjective {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for OptimizationObjective {
}Copy, #[automatically_derived]impl ::core::fmt::Debug for OptimizationObjective {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
OptimizationObjective::None => "None",
OptimizationObjective::Balanced => "Balanced",
OptimizationObjective::Speed => "Speed",
OptimizationObjective::Size => "Size",
})
}
}Debug, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
OptimizationObjective {
}
#[automatically_derived]impl ::core::cmp::PartialEq for OptimizationObjective
{
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for OptimizationObjective { }Eq)]
147pub enum OptimizationObjective {
148 None,
150 Balanced,
152 Speed,
154 Size,
156}
157
158#[derive(#[automatically_derived]impl ::core::clone::Clone for Lto {
#[inline]
fn clone(&self) -> Self {
match self {
Self::No => Lto::No,
Self::Thin => Lto::Thin,
Self::ThinLocal => Lto::ThinLocal,
Self::Fat => Lto::Fat,
}
}
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for Lto { }
#[automatically_derived]impl ::core::cmp::PartialEq for Lto {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}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);
}
}
};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)]
163pub enum Lto {
164 No,
166
167 Thin,
169
170 ThinLocal,
173
174 Fat,
176}
177
178#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for LtoCli {
}
#[automatically_derived]impl ::core::clone::Clone for LtoCli {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for LtoCli { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for LtoCli {
}
#[automatically_derived]impl ::core::cmp::PartialEq for LtoCli {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::hash::Hash for LtoCli {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
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::debug_c_like_enum_write_str(f,
"No Yes NoParam Thin Fat Unspecified",
match self {
LtoCli::No => 0usize,
LtoCli::Yes => 3usize,
LtoCli::NoParam => 7usize,
LtoCli::Thin => 15usize,
LtoCli::Fat => 20usize,
LtoCli::Unspecified => 24usize,
})
}
}Debug)]
180pub enum LtoCli {
181 No,
183 Yes,
185 NoParam,
187 Thin,
189 Fat,
191 Unspecified,
193}
194
195#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for InstrumentCoverage {
}
#[automatically_derived]impl ::core::clone::Clone for InstrumentCoverage {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for InstrumentCoverage { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
InstrumentCoverage {
}
#[automatically_derived]impl ::core::cmp::PartialEq for InstrumentCoverage {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::hash::Hash for InstrumentCoverage {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
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)]
197pub enum InstrumentCoverage {
198 No,
200 Yes,
202}
203
204#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for CoverageOptions {
}
#[automatically_derived]impl ::core::clone::Clone for CoverageOptions {
#[inline]
fn clone(&self) -> Self {
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 discard_all_spans_in_codegen", &self.level,
&&self.discard_all_spans_in_codegen)
}
}Debug, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
CoverageOptions {
}
#[automatically_derived]impl ::core::cmp::PartialEq for CoverageOptions {
#[inline]
fn eq(&self, other: &Self) -> 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() -> Self {
CoverageOptions {
level: ::core::default::Default::default(),
discard_all_spans_in_codegen: ::core::default::Default::default(),
}
}
}Default)]
206pub struct CoverageOptions {
207 pub level: CoverageLevel,
208
209 pub discard_all_spans_in_codegen: bool,
215}
216
217#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for CoverageLevel {
}
#[automatically_derived]impl ::core::clone::Clone for CoverageLevel {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for CoverageLevel { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
CoverageLevel {
}
#[automatically_derived]impl ::core::cmp::PartialEq for CoverageLevel {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for CoverageLevel { }Eq, #[automatically_derived]impl ::core::cmp::PartialOrd for CoverageLevel {
#[inline]
fn partial_cmp(&self, other: &Self)
-> ::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: &Self) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self),
&::core::intrinsics::discriminant_value(other))
}
}Ord, #[automatically_derived]impl ::core::hash::Hash for CoverageLevel {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
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() -> Self { Self::Block }
}Default)]
219pub enum CoverageLevel {
220 #[default]
222 Block,
223 Branch,
225 Condition,
241}
242
243#[derive(#[automatically_derived]impl ::core::clone::Clone for Offload {
#[inline]
fn clone(&self) -> Self {
match self {
Self::Device(__self_0) =>
Offload::Device(::core::clone::Clone::clone(__self_0)),
Self::Host(__self_0) =>
Offload::Host(::core::clone::Clone::clone(__self_0)),
Self::Test => Offload::Test,
Self::HostMetadata(__self_0) =>
Offload::HostMetadata(::core::clone::Clone::clone(__self_0)),
}
}
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for Offload {
}
#[automatically_derived]impl ::core::cmp::PartialEq for Offload {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::Device(__self_0), Self::Device(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::Host(__self_0), Self::Host(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::HostMetadata(__self_0), Self::HostMetadata(__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) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state);
match self {
Self::Device(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
Self::Host(__self_0) => ::core::hash::Hash::hash(__self_0, state),
Self::HostMetadata(__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 {
Self::Device(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Device", &__self_0),
Self::Host(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Host",
&__self_0),
Self::Test => ::core::fmt::Formatter::write_str(f, "Test"),
Self::HostMetadata(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"HostMetadata", &__self_0),
}
}
}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(ref __binding_0) => { 0usize }
Offload::Host(ref __binding_0) => { 1usize }
Offload::Test => { 2usize }
Offload::HostMetadata(ref __binding_0) => { 3usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
Offload::Device(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
Offload::Host(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
Offload::Test => {}
Offload::HostMetadata(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};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(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => {
Offload::Host(::rustc_serialize::Decodable::decode(__decoder))
}
2usize => { Offload::Test }
3usize => {
Offload::HostMetadata(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Offload`, expected 0..4, actual {0}",
n));
}
}
}
}
};Decodable)]
245pub enum Offload {
246 Device(String),
253 Host(String),
255 Test,
257 HostMetadata(String),
260}
261
262#[derive(#[automatically_derived]impl ::core::marker::Copy for CodegenRetagOptions { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for CodegenRetagOptions {
}
#[automatically_derived]impl ::core::clone::Clone for CodegenRetagOptions {
#[inline]
fn clone(&self) -> Self {
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 no_precise_pin",
&self.no_precise_im, &&self.no_precise_pin)
}
}Debug, #[automatically_derived]impl ::core::default::Default for CodegenRetagOptions
{
#[inline]
fn default() -> Self {
CodegenRetagOptions {
no_precise_im: ::core::default::Default::default(),
no_precise_pin: ::core::default::Default::default(),
}
}
}Default, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
CodegenRetagOptions {
}
#[automatically_derived]impl ::core::cmp::PartialEq for CodegenRetagOptions {
#[inline]
fn eq(&self, other: &Self) -> 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) {
let CodegenRetagOptions {
no_precise_im: ref __binding_0,
no_precise_pin: ref __binding_1 } = *self;
::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)]
264pub struct CodegenRetagOptions {
265 pub no_precise_im: bool,
267 pub no_precise_pin: bool,
269}
270
271#[derive(#[automatically_derived]impl ::core::clone::Clone for AutoDiff {
#[inline]
fn clone(&self) -> Self {
match self {
Self::Enable => AutoDiff::Enable,
Self::PrintTA => AutoDiff::PrintTA,
Self::PrintTAFn(__self_0) =>
AutoDiff::PrintTAFn(::core::clone::Clone::clone(__self_0)),
Self::PrintAA => AutoDiff::PrintAA,
Self::PrintPerf => AutoDiff::PrintPerf,
Self::PrintSteps => AutoDiff::PrintSteps,
Self::PrintModBefore => AutoDiff::PrintModBefore,
Self::PrintModAfter => AutoDiff::PrintModAfter,
Self::PrintModFinal => AutoDiff::PrintModFinal,
Self::PrintPasses => AutoDiff::PrintPasses,
Self::NoPostopt => AutoDiff::NoPostopt,
Self::LooseTypes => AutoDiff::LooseTypes,
Self::Inline => AutoDiff::Inline,
Self::NoTT => AutoDiff::NoTT,
}
}
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for AutoDiff
{
}
#[automatically_derived]impl ::core::cmp::PartialEq for AutoDiff {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::PrintTAFn(__self_0), Self::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) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state);
match self {
Self::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 {
Self::Enable => ::core::fmt::Formatter::write_str(f, "Enable"),
Self::PrintTA => ::core::fmt::Formatter::write_str(f, "PrintTA"),
Self::PrintTAFn(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"PrintTAFn", &__self_0),
Self::PrintAA => ::core::fmt::Formatter::write_str(f, "PrintAA"),
Self::PrintPerf =>
::core::fmt::Formatter::write_str(f, "PrintPerf"),
Self::PrintSteps =>
::core::fmt::Formatter::write_str(f, "PrintSteps"),
Self::PrintModBefore =>
::core::fmt::Formatter::write_str(f, "PrintModBefore"),
Self::PrintModAfter =>
::core::fmt::Formatter::write_str(f, "PrintModAfter"),
Self::PrintModFinal =>
::core::fmt::Formatter::write_str(f, "PrintModFinal"),
Self::PrintPasses =>
::core::fmt::Formatter::write_str(f, "PrintPasses"),
Self::NoPostopt =>
::core::fmt::Formatter::write_str(f, "NoPostopt"),
Self::LooseTypes =>
::core::fmt::Formatter::write_str(f, "LooseTypes"),
Self::Inline => ::core::fmt::Formatter::write_str(f, "Inline"),
Self::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)]
273pub enum AutoDiff {
274 Enable,
276
277 PrintTA,
279 PrintTAFn(String),
281 PrintAA,
283 PrintPerf,
285 PrintSteps,
287 PrintModBefore,
289 PrintModAfter,
291 PrintModFinal,
293
294 PrintPasses,
296 NoPostopt,
298 LooseTypes,
301 Inline,
303 NoTT,
305}
306
307#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for AnnotateMoves {
}
#[automatically_derived]impl ::core::clone::Clone for AnnotateMoves {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<Option<u64>>;
*self
}
}Clone, #[automatically_derived]impl ::core::marker::Copy for AnnotateMoves { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
AnnotateMoves {
}
#[automatically_derived]impl ::core::cmp::PartialEq for AnnotateMoves {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::Enabled(__self_0), Self::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) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state);
match self {
Self::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 {
Self::Disabled =>
::core::fmt::Formatter::write_str(f, "Disabled"),
Self::Enabled(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Enabled", &__self_0),
}
}
}Debug)]
309pub enum AnnotateMoves {
310 Disabled,
312 Enabled(Option<u64>),
315}
316
317#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for InstrumentMcountOpts {
}
#[automatically_derived]impl ::core::clone::Clone for InstrumentMcountOpts {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]impl ::core::marker::Copy for InstrumentMcountOpts { }Copy, #[automatically_derived]impl ::core::fmt::Debug for InstrumentMcountOpts {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"InstrumentMcountOpts no_call record", &self.no_call,
&&self.record)
}
}Debug, #[automatically_derived]impl ::core::default::Default for InstrumentMcountOpts
{
#[inline]
fn default() -> Self {
InstrumentMcountOpts {
no_call: ::core::default::Default::default(),
record: ::core::default::Default::default(),
}
}
}Default, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
InstrumentMcountOpts {
}
#[automatically_derived]impl ::core::cmp::PartialEq for InstrumentMcountOpts {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.no_call == other.no_call && self.record == other.record
}
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for InstrumentMcountOpts {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<bool>;
}
}Eq, #[automatically_derived]impl ::core::hash::Hash for InstrumentMcountOpts {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.no_call, state);
::core::hash::Hash::hash(&self.record, state)
}
}Hash)]
318pub struct InstrumentMcountOpts {
319 pub no_call: bool,
321 pub record: bool,
323}
324
325#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for InstrumentMcount {
}
#[automatically_derived]impl ::core::clone::Clone for InstrumentMcount {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<InstrumentMcountOpts>;
*self
}
}Clone, #[automatically_derived]impl ::core::marker::Copy for InstrumentMcount { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
InstrumentMcount {
}
#[automatically_derived]impl ::core::cmp::PartialEq for InstrumentMcount {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::Mcount(__self_0), Self::Mcount(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::Fentry(__self_0), Self::Fentry(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for InstrumentMcount {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<InstrumentMcountOpts>;
}
}Eq, #[automatically_derived]impl ::core::fmt::Debug for InstrumentMcount {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Self::Disabled =>
::core::fmt::Formatter::write_str(f, "Disabled"),
Self::Mcount(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Mcount", &__self_0),
Self::Fentry(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Fentry", &__self_0),
}
}
}Debug, #[automatically_derived]impl ::core::hash::Hash for InstrumentMcount {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state);
match self {
Self::Mcount(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
Self::Fentry(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
_ => {}
}
}
}Hash)]
327pub enum InstrumentMcount {
328 Disabled,
330 Mcount(InstrumentMcountOpts),
332 Fentry(InstrumentMcountOpts),
334}
335
336#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for InstrumentXRay {
}
#[automatically_derived]impl ::core::clone::Clone for InstrumentXRay {
#[inline]
fn clone(&self) -> Self {
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 _ =
"InstrumentXRay 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, names, values)
}
}Debug, #[automatically_derived]impl ::core::default::Default for InstrumentXRay {
#[inline]
fn default() -> Self {
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::marker::StructuralPartialEq for
InstrumentXRay {
}
#[automatically_derived]impl ::core::cmp::PartialEq for InstrumentXRay {
#[inline]
fn eq(&self, other: &Self) -> 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)]
338pub struct InstrumentXRay {
339 pub always: bool,
341 pub never: bool,
343 pub ignore_loops: bool,
346 pub instruction_threshold: Option<usize>,
349 pub skip_entry: bool,
351 pub skip_exit: bool,
353}
354
355#[derive(#[automatically_derived]impl ::core::clone::Clone for LinkerPluginLto {
#[inline]
fn clone(&self) -> Self {
match self {
Self::LinkerPlugin(__self_0) =>
LinkerPluginLto::LinkerPlugin(::core::clone::Clone::clone(__self_0)),
Self::LinkerPluginAuto => LinkerPluginLto::LinkerPluginAuto,
Self::Disabled => LinkerPluginLto::Disabled,
}
}
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
LinkerPluginLto {
}
#[automatically_derived]impl ::core::cmp::PartialEq for LinkerPluginLto {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::LinkerPlugin(__self_0), Self::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) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state);
match self {
Self::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 {
Self::LinkerPlugin(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"LinkerPlugin", &__self_0),
Self::LinkerPluginAuto =>
::core::fmt::Formatter::write_str(f, "LinkerPluginAuto"),
Self::Disabled =>
::core::fmt::Formatter::write_str(f, "Disabled"),
}
}
}Debug)]
356pub enum LinkerPluginLto {
357 LinkerPlugin(PathBuf),
358 LinkerPluginAuto,
359 Disabled,
360}
361
362impl LinkerPluginLto {
363 pub fn enabled(&self) -> bool {
364 match *self {
365 LinkerPluginLto::LinkerPlugin(_) | LinkerPluginLto::LinkerPluginAuto => true,
366 LinkerPluginLto::Disabled => false,
367 }
368 }
369}
370
371#[derive(#[automatically_derived]impl ::core::default::Default for LinkSelfContained {
#[inline]
fn default() -> Self {
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) -> Self {
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::marker::StructuralPartialEq for
LinkSelfContained {
}
#[automatically_derived]impl ::core::cmp::PartialEq for LinkSelfContained {
#[inline]
fn eq(&self, other: &Self) -> 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 enabled_components disabled_components",
&self.explicitly_set, &self.enabled_components,
&&self.disabled_components)
}
}Debug)]
387pub struct LinkSelfContained {
388 pub explicitly_set: Option<bool>,
391
392 enabled_components: LinkSelfContainedComponents,
395
396 disabled_components: LinkSelfContainedComponents,
399}
400
401impl LinkSelfContained {
402 pub(crate) fn handle_cli_component(&mut self, component: &str) -> Option<()> {
405 if let Some(component_to_enable) = component.strip_prefix('+') {
410 self.explicitly_set = None;
411 self.enabled_components
412 .insert(LinkSelfContainedComponents::from_str(component_to_enable).ok()?);
413 Some(())
414 } else if let Some(component_to_disable) = component.strip_prefix('-') {
415 self.explicitly_set = None;
416 self.disabled_components
417 .insert(LinkSelfContainedComponents::from_str(component_to_disable).ok()?);
418 Some(())
419 } else {
420 None
421 }
422 }
423
424 pub(crate) fn set_all_explicitly(&mut self, enabled: bool) {
427 self.explicitly_set = Some(enabled);
428
429 if enabled {
430 self.enabled_components = LinkSelfContainedComponents::all();
431 self.disabled_components = LinkSelfContainedComponents::empty();
432 } else {
433 self.enabled_components = LinkSelfContainedComponents::empty();
434 self.disabled_components = LinkSelfContainedComponents::all();
435 }
436 }
437
438 pub fn on() -> Self {
440 let mut on = LinkSelfContained::default();
441 on.set_all_explicitly(true);
442 on
443 }
444
445 fn check_unstable_variants(&self, target_tuple: &TargetTuple) -> Result<(), String> {
449 if self.explicitly_set.is_some() {
450 return Ok(());
451 }
452
453 let has_minus_linker = self.disabled_components.is_linker_enabled();
455 if has_minus_linker && target_tuple.tuple() != "x86_64-unknown-linux-gnu" {
456 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!(
457 "`-C link-self-contained=-linker` is unstable on the `{target_tuple}` \
458 target. The `-Z unstable-options` flag must also be passed to use it on this target",
459 ));
460 }
461
462 let unstable_enabled = self.enabled_components;
464 let unstable_disabled = self.disabled_components - LinkSelfContainedComponents::LINKER;
465 if !unstable_enabled.union(unstable_disabled).is_empty() {
466 return Err(String::from(
467 "only `-C link-self-contained` values `y`/`yes`/`on`/`n`/`no`/`off`/`-linker` \
468 are stable, the `-Z unstable-options` flag must also be passed to use \
469 the unstable values",
470 ));
471 }
472
473 Ok(())
474 }
475
476 pub fn is_linker_enabled(&self) -> bool {
479 self.enabled_components.contains(LinkSelfContainedComponents::LINKER)
480 }
481
482 pub fn is_linker_disabled(&self) -> bool {
485 self.disabled_components.contains(LinkSelfContainedComponents::LINKER)
486 }
487
488 fn check_consistency(&self) -> Option<LinkSelfContainedComponents> {
491 if self.explicitly_set.is_some() {
492 None
493 } else {
494 let common = self.enabled_components.intersection(self.disabled_components);
495 if common.is_empty() { None } else { Some(common) }
496 }
497 }
498}
499
500#[derive(#[automatically_derived]impl ::core::default::Default for LinkerFeaturesCli {
#[inline]
fn default() -> Self {
LinkerFeaturesCli {
enabled: ::core::default::Default::default(),
disabled: ::core::default::Default::default(),
}
}
}Default, #[automatically_derived]impl ::core::marker::Copy for LinkerFeaturesCli { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for LinkerFeaturesCli {
}
#[automatically_derived]impl ::core::clone::Clone for LinkerFeaturesCli {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<LinkerFeatures>;
*self
}
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
LinkerFeaturesCli {
}
#[automatically_derived]impl ::core::cmp::PartialEq for LinkerFeaturesCli {
#[inline]
fn eq(&self, other: &Self) -> 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 disabled", &self.enabled,
&&self.disabled)
}
}Debug)]
509pub struct LinkerFeaturesCli {
510 pub enabled: LinkerFeatures,
512
513 pub disabled: LinkerFeatures,
515}
516
517impl LinkerFeaturesCli {
518 pub(crate) fn handle_cli_feature(&mut self, feature: &str) -> Option<()> {
521 match feature {
527 "+lld" => {
528 self.enabled.insert(LinkerFeatures::LLD);
529 self.disabled.remove(LinkerFeatures::LLD);
530 Some(())
531 }
532 "-lld" => {
533 self.disabled.insert(LinkerFeatures::LLD);
534 self.enabled.remove(LinkerFeatures::LLD);
535 Some(())
536 }
537 _ => None,
538 }
539 }
540
541 pub(crate) fn check_unstable_variants(&self, target_tuple: &TargetTuple) -> Result<(), String> {
546 let has_minus_lld = self.disabled.is_lld_enabled();
548 if has_minus_lld && target_tuple.tuple() != "x86_64-unknown-linux-gnu" {
549 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!(
550 "`-C linker-features=-lld` is unstable on the `{target_tuple}` \
551 target. The `-Z unstable-options` flag must also be passed to use it on this target",
552 ));
553 }
554
555 let unstable_enabled = self.enabled;
557 let unstable_disabled = self.disabled - LinkerFeatures::LLD;
558 if !unstable_enabled.union(unstable_disabled).is_empty() {
559 let unstable_features: Vec<_> = unstable_enabled
560 .iter()
561 .map(|f| ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("+{0}", f.as_str().unwrap()))
})format!("+{}", f.as_str().unwrap()))
562 .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())))
563 .collect();
564 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!(
565 "`-C linker-features={}` is unstable, and also requires the \
566 `-Z unstable-options` flag to be used",
567 unstable_features.join(","),
568 ));
569 }
570
571 Ok(())
572 }
573}
574
575#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for IncrementalStateAssertion {
}
#[automatically_derived]impl ::core::clone::Clone for
IncrementalStateAssertion {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for
IncrementalStateAssertion {
}Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
IncrementalStateAssertion {
}
#[automatically_derived]impl ::core::cmp::PartialEq for
IncrementalStateAssertion {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::hash::Hash for IncrementalStateAssertion
{
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
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)]
577pub enum IncrementalStateAssertion {
578 Loaded,
583 NotLoaded,
585}
586
587#[derive(#[automatically_derived]impl ::core::marker::Copy for LocationDetail { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for LocationDetail {
}
#[automatically_derived]impl ::core::clone::Clone for LocationDetail {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
LocationDetail {
}
#[automatically_derived]impl ::core::cmp::PartialEq for LocationDetail {
#[inline]
fn eq(&self, other: &Self) -> 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 line column", &self.file, &self.line,
&&self.column)
}
}Debug)]
589pub struct LocationDetail {
590 pub file: bool,
591 pub line: bool,
592 pub column: bool,
593}
594
595impl LocationDetail {
596 pub(crate) fn all() -> Self {
597 Self { file: true, line: true, column: true }
598 }
599}
600
601#[derive(#[automatically_derived]impl ::core::marker::Copy for FmtDebug { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for FmtDebug {
}
#[automatically_derived]impl ::core::clone::Clone for FmtDebug {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for FmtDebug
{
}
#[automatically_derived]impl ::core::cmp::PartialEq for FmtDebug {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::hash::Hash for FmtDebug {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
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)]
603pub enum FmtDebug {
604 Full,
606 Shallow,
608 None,
610}
611
612impl FmtDebug {
613 pub(crate) fn all() -> [Symbol; 3] {
614 [sym::full, sym::none, sym::shallow]
615 }
616}
617
618#[derive(#[automatically_derived]impl ::core::clone::Clone for SwitchWithOptPath {
#[inline]
fn clone(&self) -> Self {
match self {
Self::Enabled(__self_0) =>
SwitchWithOptPath::Enabled(::core::clone::Clone::clone(__self_0)),
Self::Disabled => SwitchWithOptPath::Disabled,
}
}
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
SwitchWithOptPath {
}
#[automatically_derived]impl ::core::cmp::PartialEq for SwitchWithOptPath {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::Enabled(__self_0), Self::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) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state);
match self {
Self::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 {
Self::Enabled(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Enabled", &__self_0),
Self::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)]
619pub enum SwitchWithOptPath {
620 Enabled(Option<PathBuf>),
621 Disabled,
622}
623
624impl SwitchWithOptPath {
625 pub fn enabled(&self) -> bool {
626 match *self {
627 SwitchWithOptPath::Enabled(_) => true,
628 SwitchWithOptPath::Disabled => false,
629 }
630 }
631}
632
633#[derive(#[automatically_derived]impl ::core::marker::Copy for SymbolManglingVersion {
}Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for SymbolManglingVersion {
}
#[automatically_derived]impl ::core::clone::Clone for SymbolManglingVersion {
#[inline]
fn clone(&self) -> Self { *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::marker::StructuralPartialEq for
SymbolManglingVersion {
}
#[automatically_derived]impl ::core::cmp::PartialEq for SymbolManglingVersion
{
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for SymbolManglingVersion { }Eq, #[automatically_derived]impl ::core::cmp::PartialOrd for SymbolManglingVersion
{
#[inline]
fn partial_cmp(&self, other: &Self)
-> ::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: &Self) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self),
&::core::intrinsics::discriminant_value(other))
}
}Ord, #[automatically_derived]impl ::core::hash::Hash for SymbolManglingVersion {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
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) {
match *self {
SymbolManglingVersion::Legacy =>
0u8.stable_hash(__hcx, __hasher),
SymbolManglingVersion::V0 =>
1u8.stable_hash(__hcx, __hasher),
SymbolManglingVersion::Hashed =>
2u8.stable_hash(__hcx, __hasher),
}
match *self {
SymbolManglingVersion::Legacy => {}
SymbolManglingVersion::V0 => {}
SymbolManglingVersion::Hashed => {}
}
}
}
};StableHash)]
634#[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);
}
}
};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)]
635pub enum SymbolManglingVersion {
636 Legacy,
637 V0,
638 Hashed,
639}
640
641#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for DebugInfo {
}
#[automatically_derived]impl ::core::clone::Clone for DebugInfo {
#[inline]
fn clone(&self) -> Self { *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::debug_c_like_enum_write_str(f,
"None LineDirectivesOnly LineTablesOnly Limited Full",
match self {
DebugInfo::None => 0usize,
DebugInfo::LineDirectivesOnly => 5usize,
DebugInfo::LineTablesOnly => 24usize,
DebugInfo::Limited => 39usize,
DebugInfo::Full => 47usize,
})
}
}Debug, #[automatically_derived]impl ::core::marker::StructuralPartialEq for DebugInfo
{
}
#[automatically_derived]impl ::core::cmp::PartialEq for DebugInfo {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::hash::Hash for DebugInfo {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state)
}
}Hash)]
642pub enum DebugInfo {
643 None,
644 LineDirectivesOnly,
645 LineTablesOnly,
646 Limited,
647 Full,
648}
649
650#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for DebugInfoCompression {
}
#[automatically_derived]impl ::core::clone::Clone for DebugInfoCompression {
#[inline]
fn clone(&self) -> Self { *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::marker::StructuralPartialEq for
DebugInfoCompression {
}
#[automatically_derived]impl ::core::cmp::PartialEq for DebugInfoCompression {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::hash::Hash for DebugInfoCompression {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state)
}
}Hash)]
651pub enum DebugInfoCompression {
652 None,
653 Zlib,
654 Zstd,
655}
656
657#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for MirStripDebugInfo {
}
#[automatically_derived]impl ::core::clone::Clone for MirStripDebugInfo {
#[inline]
fn clone(&self) -> Self { *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::marker::StructuralPartialEq for
MirStripDebugInfo {
}
#[automatically_derived]impl ::core::cmp::PartialEq for MirStripDebugInfo {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::hash::Hash for MirStripDebugInfo {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state)
}
}Hash)]
658pub enum MirStripDebugInfo {
659 None,
660 LocalsInTinyFunctions,
661 AllLocals,
662}
663
664#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for SplitDwarfKind {
}
#[automatically_derived]impl ::core::clone::Clone for SplitDwarfKind {
#[inline]
fn clone(&self) -> Self { *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::marker::StructuralPartialEq for
SplitDwarfKind {
}
#[automatically_derived]impl ::core::cmp::PartialEq for SplitDwarfKind {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::hash::Hash for SplitDwarfKind {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
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);
}
}
};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)]
674pub enum SplitDwarfKind {
675 Single,
678 Split,
681}
682
683impl FromStr for SplitDwarfKind {
684 type Err = ();
685
686 fn from_str(s: &str) -> Result<Self, ()> {
687 Ok(match s {
688 "single" => SplitDwarfKind::Single,
689 "split" => SplitDwarfKind::Split,
690 _ => return Err(()),
691 })
692 }
693}
694
695macro_rules! define_output_types {
696 (
697 $(
698 $(#[doc = $doc:expr])*
699 $Variant:ident => {
700 shorthand: $shorthand:expr,
701 extension: $extension:expr,
702 description: $description:expr,
703 default_filename: $default_filename:expr,
704 is_text: $is_text:expr,
705 compatible_with_cgus_and_single_output: $compatible:expr
706 }
707 ),* $(,)?
708 ) => {
709 #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord, StableHash)]
710 #[derive(Encodable, Decodable)]
711 pub enum OutputType {
712 $(
713 $(#[doc = $doc])*
714 $Variant,
715 )*
716 }
717
718 impl StableOrd for OutputType {
719 const CAN_USE_UNSTABLE_SORT: bool = true;
720
721 const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
723 }
724
725 impl OutputType {
726 pub fn iter_all() -> impl Iterator<Item = OutputType> {
727 static ALL_VARIANTS: &[OutputType] = &[
728 $(
729 OutputType::$Variant,
730 )*
731 ];
732 ALL_VARIANTS.iter().copied()
733 }
734
735 fn is_compatible_with_codegen_units_and_single_output_file(&self) -> bool {
736 match *self {
737 $(
738 OutputType::$Variant => $compatible,
739 )*
740 }
741 }
742
743 pub fn shorthand(&self) -> &'static str {
744 match *self {
745 $(
746 OutputType::$Variant => $shorthand,
747 )*
748 }
749 }
750
751 fn from_shorthand(shorthand: &str) -> Option<Self> {
752 match shorthand {
753 $(
754 s if s == $shorthand => Some(OutputType::$Variant),
755 )*
756 _ => None,
757 }
758 }
759
760 fn shorthands_display() -> String {
761 let shorthands = vec![
762 $(
763 format!("`{}`", $shorthand),
764 )*
765 ];
766 shorthands.join(", ")
767 }
768
769 pub fn extension(&self) -> &'static str {
770 match *self {
771 $(
772 OutputType::$Variant => $extension,
773 )*
774 }
775 }
776
777 pub fn is_text_output(&self) -> bool {
778 match *self {
779 $(
780 OutputType::$Variant => $is_text,
781 )*
782 }
783 }
784
785 pub fn description(&self) -> &'static str {
786 match *self {
787 $(
788 OutputType::$Variant => $description,
789 )*
790 }
791 }
792
793 pub fn default_filename(&self) -> &'static str {
794 match *self {
795 $(
796 OutputType::$Variant => $default_filename,
797 )*
798 }
799 }
800
801
802 }
803 }
804}
805
806pub enum OutputType {
Assembly,
#[doc =
"This is the optimized bitcode, which could be either pre-LTO or non-LTO bitcode,"]
#[doc = "depending on the specific request type."]
Bitcode,
DepInfo,
Exe,
LlvmAssembly,
Metadata,
Mir,
Object,
#[doc = "This is the summary or index data part of the ThinLTO bitcode."]
ThinLinkBitcode,
}
const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for OutputType {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
OutputType::Assembly => { 0usize }
OutputType::Bitcode => { 1usize }
OutputType::DepInfo => { 2usize }
OutputType::Exe => { 3usize }
OutputType::LlvmAssembly => { 4usize }
OutputType::Metadata => { 5usize }
OutputType::Mir => { 6usize }
OutputType::Object => { 7usize }
OutputType::ThinLinkBitcode => { 8usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
}
}
};
const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for OutputType {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { OutputType::Assembly }
1usize => { OutputType::Bitcode }
2usize => { OutputType::DepInfo }
3usize => { OutputType::Exe }
4usize => { OutputType::LlvmAssembly }
5usize => { OutputType::Metadata }
6usize => { OutputType::Mir }
7usize => { OutputType::Object }
8usize => { OutputType::ThinLinkBitcode }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `OutputType`, expected 0..9, actual {0}",
n));
}
}
}
}
};
#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for OutputType {
}
#[automatically_derived]impl ::core::clone::Clone for OutputType {
#[inline]
fn clone(&self) -> Self { *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: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}
#[automatically_derived]impl ::core::cmp::Eq for OutputType { }
#[automatically_derived]impl ::core::hash::Hash for OutputType {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state)
}
}
#[automatically_derived]impl ::core::fmt::Debug for OutputType {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_c_like_enum_write_str(f,
"Assembly Bitcode DepInfo Exe LlvmAssembly Metadata Mir Object ThinLinkBitcode",
match self {
OutputType::Assembly => 0usize,
OutputType::Bitcode => 9usize,
OutputType::DepInfo => 17usize,
OutputType::Exe => 25usize,
OutputType::LlvmAssembly => 29usize,
OutputType::Metadata => 42usize,
OutputType::Mir => 51usize,
OutputType::Object => 55usize,
OutputType::ThinLinkBitcode => 62usize,
})
}
}
#[automatically_derived]impl ::core::cmp::PartialOrd for OutputType {
#[inline]
fn partial_cmp(&self, other: &Self)
-> ::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: &Self) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self),
&::core::intrinsics::discriminant_value(other))
}
}
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) {
match *self {
OutputType::Assembly => 0u8.stable_hash(__hcx, __hasher),
OutputType::Bitcode => 1u8.stable_hash(__hcx, __hasher),
OutputType::DepInfo => 2u8.stable_hash(__hcx, __hasher),
OutputType::Exe => 3u8.stable_hash(__hcx, __hasher),
OutputType::LlvmAssembly =>
4u8.stable_hash(__hcx, __hasher),
OutputType::Metadata => 5u8.stable_hash(__hcx, __hasher),
OutputType::Mir => 6u8.stable_hash(__hcx, __hasher),
OutputType::Object => 7u8.stable_hash(__hcx, __hasher),
OutputType::ThinLinkBitcode =>
8u8.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! {
807 Assembly => {
808 shorthand: "asm",
809 extension: "s",
810 description: "Generates a file with the crate's assembly code",
811 default_filename: "CRATE_NAME.s",
812 is_text: true,
813 compatible_with_cgus_and_single_output: false
814 },
815 #[doc = "This is the optimized bitcode, which could be either pre-LTO or non-LTO bitcode,"]
816 #[doc = "depending on the specific request type."]
817 Bitcode => {
818 shorthand: "llvm-bc",
819 extension: "bc",
820 description: "Generates a binary file containing the LLVM bitcode",
821 default_filename: "CRATE_NAME.bc",
822 is_text: false,
823 compatible_with_cgus_and_single_output: false
824 },
825 DepInfo => {
826 shorthand: "dep-info",
827 extension: "d",
828 description: "Generates a file with Makefile syntax that indicates all the source files that were loaded to generate the crate",
829 default_filename: "CRATE_NAME.d",
830 is_text: true,
831 compatible_with_cgus_and_single_output: true
832 },
833 Exe => {
834 shorthand: "link",
835 extension: "",
836 description: "Generates the crates specified by --crate-type. This is the default if --emit is not specified",
837 default_filename: "(platform and crate-type dependent)",
838 is_text: false,
839 compatible_with_cgus_and_single_output: true
840 },
841 LlvmAssembly => {
842 shorthand: "llvm-ir",
843 extension: "ll",
844 description: "Generates a file containing LLVM IR",
845 default_filename: "CRATE_NAME.ll",
846 is_text: true,
847 compatible_with_cgus_and_single_output: false
848 },
849 Metadata => {
850 shorthand: "metadata",
851 extension: "rmeta",
852 description: "Generates a file containing metadata about the crate",
853 default_filename: "libCRATE_NAME.rmeta",
854 is_text: false,
855 compatible_with_cgus_and_single_output: true
856 },
857 Mir => {
858 shorthand: "mir",
859 extension: "mir",
860 description: "Generates a file containing rustc's mid-level intermediate representation",
861 default_filename: "CRATE_NAME.mir",
862 is_text: true,
863 compatible_with_cgus_and_single_output: false
864 },
865 Object => {
866 shorthand: "obj",
867 extension: "o",
868 description: "Generates a native object file",
869 default_filename: "CRATE_NAME.o",
870 is_text: false,
871 compatible_with_cgus_and_single_output: false
872 },
873 #[doc = "This is the summary or index data part of the ThinLTO bitcode."]
874 ThinLinkBitcode => {
875 shorthand: "thin-link-bitcode",
876 extension: "indexing.o",
877 description: "Generates the ThinLTO summary as bitcode",
878 default_filename: "CRATE_NAME.indexing.o",
879 is_text: false,
880 compatible_with_cgus_and_single_output: false
881 },
882}
883
884#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for ErrorOutputType {
}
#[automatically_derived]impl ::core::clone::Clone for ErrorOutputType {
#[inline]
fn clone(&self) -> Self {
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 {
Self::HumanReadable { kind: __self_0, color_config: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"HumanReadable kind color_config", __self_0, &__self_1),
Self::Json {
pretty: __self_0,
json_rendered: __self_1,
color_config: __self_2 } =>
::core::fmt::Formatter::debug_struct_field3_finish(f,
"Json pretty json_rendered color_config", __self_0,
__self_1, &__self_2),
}
}
}Debug, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
ErrorOutputType {
}
#[automatically_derived]impl ::core::cmp::PartialEq for ErrorOutputType {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::HumanReadable { kind: __self_0, color_config: __self_1
}, Self::HumanReadable {
kind: __arg1_0, color_config: __arg1_1 }) =>
__self_0 == __arg1_0 && __self_1 == __arg1_1,
(Self::Json {
pretty: __self_0,
json_rendered: __self_1,
color_config: __self_2 }, Self::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() -> Self {
Self::HumanReadable {
kind: const HumanReadableErrorType {
short: false,
unicode: false,
},
color_config: const ColorConfig::Auto,
}
}
}Default)]
886pub enum ErrorOutputType {
887 #[default]
889 HumanReadable {
890 kind: HumanReadableErrorType = HumanReadableErrorType { short: false, unicode: false },
891 color_config: ColorConfig = ColorConfig::Auto,
892 },
893 Json {
895 pretty: bool,
897 json_rendered: HumanReadableErrorType,
900 color_config: ColorConfig,
901 },
902}
903
904#[derive(#[automatically_derived]impl ::core::clone::Clone for ResolveDocLinks {
#[inline]
fn clone(&self) -> Self {
match self {
Self::None => ResolveDocLinks::None,
Self::ExportedMetadata => ResolveDocLinks::ExportedMetadata,
Self::Exported => ResolveDocLinks::Exported,
Self::All => ResolveDocLinks::All,
}
}
}Clone, #[automatically_derived]impl ::core::hash::Hash for ResolveDocLinks {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
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)]
905pub enum ResolveDocLinks {
906 None,
908 ExportedMetadata,
910 Exported,
912 All,
914}
915
916#[derive(#[automatically_derived]impl ::core::clone::Clone for OutputTypes {
#[inline]
fn clone(&self) -> Self {
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_struct_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) {
let OutputTypes(ref __binding_0) = *self;
::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)]
921pub struct OutputTypes(BTreeMap<OutputType, Option<OutFileName>>);
922
923impl OutputTypes {
924 pub fn new(entries: &[(OutputType, Option<OutFileName>)]) -> OutputTypes {
925 OutputTypes(BTreeMap::from_iter(entries.iter().map(|&(k, ref v)| (k, v.clone()))))
926 }
927
928 pub(crate) fn get(&self, key: &OutputType) -> Option<&Option<OutFileName>> {
929 self.0.get(key)
930 }
931
932 pub fn contains_key(&self, key: &OutputType) -> bool {
933 self.0.contains_key(key)
934 }
935
936 pub fn contains_explicit_name(&self, key: &OutputType) -> bool {
938 #[allow(non_exhaustive_omitted_patterns)] match self.0.get(key) {
Some(Some(..)) => true,
_ => false,
}matches!(self.0.get(key), Some(Some(..)))
939 }
940
941 pub fn iter(&self) -> BTreeMapIter<'_, OutputType, Option<OutFileName>> {
942 self.0.iter()
943 }
944
945 pub fn keys(&self) -> BTreeMapKeysIter<'_, OutputType, Option<OutFileName>> {
946 self.0.keys()
947 }
948
949 pub fn values(&self) -> BTreeMapValuesIter<'_, OutputType, Option<OutFileName>> {
950 self.0.values()
951 }
952
953 pub fn len(&self) -> usize {
954 self.0.len()
955 }
956
957 pub fn should_codegen(&self) -> bool {
959 self.0.keys().any(|k| match *k {
960 OutputType::Bitcode
961 | OutputType::ThinLinkBitcode
962 | OutputType::Assembly
963 | OutputType::LlvmAssembly
964 | OutputType::Mir
965 | OutputType::Object
966 | OutputType::Exe => true,
967 OutputType::Metadata | OutputType::DepInfo => false,
968 })
969 }
970
971 pub fn should_link(&self) -> bool {
973 self.0.keys().any(|k| match *k {
974 OutputType::Bitcode
975 | OutputType::ThinLinkBitcode
976 | OutputType::Assembly
977 | OutputType::LlvmAssembly
978 | OutputType::Mir
979 | OutputType::Metadata
980 | OutputType::Object
981 | OutputType::DepInfo => false,
982 OutputType::Exe => true,
983 })
984 }
985}
986
987#[derive(#[automatically_derived]impl ::core::clone::Clone for Externs {
#[inline]
fn clone(&self) -> Self { Externs(::core::clone::Clone::clone(&self.0)) }
}Clone)]
991pub struct Externs(BTreeMap<String, ExternEntry>);
992
993#[derive(#[automatically_derived]impl ::core::clone::Clone for ExternEntry {
#[inline]
fn clone(&self) -> Self {
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 is_private_dep add_prelude nounused_dep force",
&self.location, &self.is_private_dep, &self.add_prelude,
&self.nounused_dep, &&self.force)
}
}Debug)]
994pub struct ExternEntry {
995 pub location: ExternLocation,
996 pub is_private_dep: bool,
1002 pub add_prelude: bool,
1007 pub nounused_dep: bool,
1012 pub force: bool,
1018}
1019
1020#[derive(#[automatically_derived]impl ::core::clone::Clone for ExternLocation {
#[inline]
fn clone(&self) -> Self {
match self {
Self::FoundInLibrarySearchDirectories =>
ExternLocation::FoundInLibrarySearchDirectories,
Self::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 {
Self::FoundInLibrarySearchDirectories =>
::core::fmt::Formatter::write_str(f,
"FoundInLibrarySearchDirectories"),
Self::ExactPaths(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"ExactPaths", &__self_0),
}
}
}Debug)]
1021pub enum ExternLocation {
1022 FoundInLibrarySearchDirectories,
1026 ExactPaths(BTreeSet<CanonicalizedPath>),
1033}
1034
1035impl Externs {
1036 pub fn new(data: BTreeMap<String, ExternEntry>) -> Externs {
1038 Externs(data)
1039 }
1040
1041 pub fn get(&self, key: &str) -> Option<&ExternEntry> {
1042 self.0.get(key)
1043 }
1044
1045 pub fn iter(&self) -> BTreeMapIter<'_, String, ExternEntry> {
1046 self.0.iter()
1047 }
1048}
1049
1050impl ExternEntry {
1051 fn new(location: ExternLocation) -> ExternEntry {
1052 ExternEntry {
1053 location,
1054 is_private_dep: false,
1055 add_prelude: false,
1056 nounused_dep: false,
1057 force: false,
1058 }
1059 }
1060
1061 pub fn files(&self) -> Option<impl Iterator<Item = &CanonicalizedPath>> {
1062 match &self.location {
1063 ExternLocation::ExactPaths(set) => Some(set.iter()),
1064 _ => None,
1065 }
1066 }
1067}
1068
1069#[derive(#[automatically_derived]impl ::core::fmt::Debug for NextSolverConfig {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
NextSolverConfig::Coherence => "Coherence",
NextSolverConfig::Globally => "Globally",
})
}
}Debug, #[automatically_derived]impl ::core::marker::Copy for NextSolverConfig { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for NextSolverConfig {
}
#[automatically_derived]impl ::core::clone::Clone for NextSolverConfig {
#[inline]
fn clone(&self) -> Self { *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(&::core::intrinsics::discriminant_value(self),
state)
}
}Hash, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
NextSolverConfig {
}
#[automatically_derived]impl ::core::cmp::PartialEq for NextSolverConfig {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for NextSolverConfig { }Eq)]
1071pub enum NextSolverConfig {
1072 Coherence,
1073 Globally,
1074}
1075
1076impl Default for NextSolverConfig {
1079 fn default() -> Self {
1080 if ::core::option::Option::Some("1")option_env!("CFG_DEFAULT_NEXT_SOLVER_GLOBALLY").is_some() {
1081 Self::Globally
1082 } else {
1083 Self::Coherence
1084 }
1085 }
1086}
1087
1088#[derive(#[automatically_derived]impl ::core::clone::Clone for Input {
#[inline]
fn clone(&self) -> Self {
match self {
Self::File(__self_0) =>
Input::File(::core::clone::Clone::clone(__self_0)),
Self::DocTestStr { file: __self_0, line: __self_1, input: __self_2
} =>
Input::DocTestStr {
file: ::core::clone::Clone::clone(__self_0),
line: ::core::clone::Clone::clone(__self_1),
input: ::core::clone::Clone::clone(__self_2),
},
Self::Str { name: __self_0, input: __self_1 } =>
Input::Str {
name: ::core::clone::Clone::clone(__self_0),
input: ::core::clone::Clone::clone(__self_1),
},
}
}
}Clone)]
1089pub enum Input {
1090 File(PathBuf),
1092 DocTestStr {
1094 file: PathBuf,
1096 line: isize,
1098 input: String,
1100 },
1101 Str {
1103 name: FileName,
1105 input: String,
1107 },
1108}
1109
1110impl Input {
1111 pub fn filestem(&self) -> &str {
1112 if let Input::File(ifile) = self {
1113 if let Some(name) = ifile.file_stem().and_then(OsStr::to_str) {
1116 return name;
1117 }
1118 }
1119 "rust_out"
1120 }
1121
1122 pub fn file_name(&self, session: &Session) -> FileName {
1123 match *self {
1124 Input::File(ref ifile) => FileName::Real(
1125 session
1126 .psess
1127 .source_map()
1128 .path_mapping()
1129 .to_real_filename(session.psess.source_map().working_dir(), ifile.as_path()),
1130 ),
1131 Input::DocTestStr { ref file, line, .. } => FileName::DocTest(
1132 session
1133 .psess
1134 .source_map()
1135 .path_mapping()
1136 .to_real_filename(session.psess.source_map().working_dir(), file.as_path()),
1137 line,
1138 ),
1139 Input::Str { ref name, .. } => name.clone(),
1140 }
1141 }
1142
1143 pub fn opt_path(&self) -> Option<&Path> {
1144 match self {
1145 Input::File(file) => Some(file),
1146 Input::DocTestStr { file, .. } => Some(file),
1147 Input::Str { name, .. } => match name {
1148 FileName::Real(real) => real.local_path(),
1149 FileName::CfgSpec(_) => None,
1150 FileName::Anon(_) => None,
1151 FileName::MacroExpansion(_) => None,
1152 FileName::ProcMacroSourceCode(_) => None,
1153 FileName::CliCrateAttr(_) => None,
1154 FileName::Custom(_) => None,
1155 FileName::DocTest(path, _) => path.local_path(),
1156 FileName::InlineAsm(_) => None,
1157 },
1158 }
1159 }
1160}
1161
1162#[derive(#[automatically_derived]impl ::core::clone::Clone for OutFileName {
#[inline]
fn clone(&self) -> Self {
match self {
Self::Real(__self_0) =>
OutFileName::Real(::core::clone::Clone::clone(__self_0)),
Self::Stdout => OutFileName::Stdout,
}
}
}Clone, #[automatically_derived]impl ::core::hash::Hash for OutFileName {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state);
match self {
Self::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 {
Self::Real(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Real",
&__self_0),
Self::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) {
match *self {
OutFileName::Real(ref __binding_0) =>
0u8.stable_hash(__hcx, __hasher),
OutFileName::Stdout => 1u8.stable_hash(__hcx, __hasher),
}
match *self {
OutFileName::Real(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
OutFileName::Stdout => {}
}
}
}
};StableHash, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
OutFileName {
}
#[automatically_derived]impl ::core::cmp::PartialEq for OutFileName {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::Real(__self_0), Self::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)]
1163pub enum OutFileName {
1164 Real(PathBuf),
1165 Stdout,
1166}
1167
1168impl OutFileName {
1169 pub fn parent(&self) -> Option<&Path> {
1170 match *self {
1171 OutFileName::Real(ref path) => path.parent(),
1172 OutFileName::Stdout => None,
1173 }
1174 }
1175
1176 pub fn filestem(&self) -> Option<&OsStr> {
1177 match *self {
1178 OutFileName::Real(ref path) => path.file_stem(),
1179 OutFileName::Stdout => Some(OsStr::new("stdout")),
1180 }
1181 }
1182
1183 pub fn is_stdout(&self) -> bool {
1184 match *self {
1185 OutFileName::Real(_) => false,
1186 OutFileName::Stdout => true,
1187 }
1188 }
1189
1190 pub fn is_tty(&self) -> bool {
1191 use std::io::IsTerminal;
1192 match *self {
1193 OutFileName::Real(_) => false,
1194 OutFileName::Stdout => std::io::stdout().is_terminal(),
1195 }
1196 }
1197
1198 pub fn as_path(&self) -> &Path {
1199 match *self {
1200 OutFileName::Real(ref path) => path.as_ref(),
1201 OutFileName::Stdout => Path::new("stdout"),
1202 }
1203 }
1204
1205 pub fn file_for_writing(
1211 &self,
1212 outputs: &OutputFilenames,
1213 flavor: OutputType,
1214 codegen_unit_name: &str,
1215 ) -> PathBuf {
1216 match *self {
1217 OutFileName::Real(ref path) => path.clone(),
1218 OutFileName::Stdout => outputs.temp_path_for_cgu(flavor, codegen_unit_name),
1219 }
1220 }
1221
1222 pub fn overwrite(&self, content: &str, sess: &Session) {
1223 match self {
1224 OutFileName::Stdout => { ::std::io::_print(format_args!("{0}", content)); }print!("{content}"),
1225 OutFileName::Real(path) => {
1226 if let Err(e) = fs::write(path, content) {
1227 sess.dcx().emit_fatal(FileWriteFail { path, err: e.to_string() });
1228 }
1229 }
1230 }
1231 }
1232}
1233
1234#[derive(#[automatically_derived]impl ::core::clone::Clone for OutputFilenames {
#[inline]
fn clone(&self) -> Self {
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 _ =
"OutputFilenames 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, 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) {
let 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 } = *self;
::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)]
1235pub struct OutputFilenames {
1236 pub(crate) out_directory: PathBuf,
1237 crate_stem: String,
1239 filestem: String,
1241 pub single_output_file: Option<OutFileName>,
1242 temps_directory: Option<PathBuf>,
1243
1244 #[stable_hash(ignore)]
1252 invocation_temp: Option<String>,
1253
1254 explicit_dwo_out_directory: Option<PathBuf>,
1255 pub outputs: OutputTypes,
1256}
1257
1258pub const RLINK_EXT: &str = "rlink";
1259pub const RUST_CGU_EXT: &str = "rcgu";
1260pub const DWARF_OBJECT_EXT: &str = "dwo";
1261pub const MAX_FILENAME_LENGTH: usize = 143; fn maybe_strip_file_name(mut path: PathBuf) -> PathBuf {
1267 if path.file_name().map_or(0, |name| name.len()) > MAX_FILENAME_LENGTH {
1268 let filename = path.file_name().unwrap().to_string_lossy();
1269 let hash_len = 64 / 4; let hyphen_len = 1; let allowed_suffix = MAX_FILENAME_LENGTH.saturating_sub(hash_len + hyphen_len);
1274
1275 let stripped_bytes = filename.len().saturating_sub(allowed_suffix);
1277
1278 let split_at = filename.ceil_char_boundary(stripped_bytes);
1280
1281 let mut hasher = StableHasher::new();
1282 filename[..split_at].hash(&mut hasher);
1283 let hash = hasher.finish::<Hash64>();
1284
1285 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..]));
1286 }
1287 path
1288}
1289impl OutputFilenames {
1290 pub fn new(
1291 out_directory: PathBuf,
1292 out_crate_name: String,
1293 out_filestem: String,
1294 single_output_file: Option<OutFileName>,
1295 temps_directory: Option<PathBuf>,
1296 invocation_temp: Option<String>,
1297 explicit_dwo_out_directory: Option<PathBuf>,
1298 extra: String,
1299 outputs: OutputTypes,
1300 ) -> Self {
1301 OutputFilenames {
1302 out_directory,
1303 single_output_file,
1304 temps_directory,
1305 invocation_temp,
1306 explicit_dwo_out_directory,
1307 outputs,
1308 crate_stem: ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}{1}", out_crate_name, extra))
})format!("{out_crate_name}{extra}"),
1309 filestem: ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}{1}", out_filestem, extra))
})format!("{out_filestem}{extra}"),
1310 }
1311 }
1312
1313 pub fn path(&self, flavor: OutputType) -> OutFileName {
1314 self.outputs
1315 .get(&flavor)
1316 .and_then(|p| p.to_owned())
1317 .or_else(|| self.single_output_file.clone())
1318 .unwrap_or_else(|| OutFileName::Real(self.output_path(flavor)))
1319 }
1320
1321 pub fn interface_path(&self) -> PathBuf {
1322 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/f5cedb83a788ea9581097abc36a2a8503a7f541c/compiler/rustc_session/src/config.rs:1322",
"rustc_session::config", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/f5cedb83a788ea9581097abc36a2a8503a7f541c/compiler/rustc_session/src/config.rs"),
::tracing_core::__macro_support::Option::Some(1322u32),
::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);
1323 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))
1324 }
1325
1326 fn output_path(&self, flavor: OutputType) -> PathBuf {
1329 let extension = flavor.extension();
1330 match flavor {
1331 OutputType::Metadata => {
1332 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/f5cedb83a788ea9581097abc36a2a8503a7f541c/compiler/rustc_session/src/config.rs:1332",
"rustc_session::config", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/f5cedb83a788ea9581097abc36a2a8503a7f541c/compiler/rustc_session/src/config.rs"),
::tracing_core::__macro_support::Option::Some(1332u32),
::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);
1333 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))
1334 }
1335 _ => self.with_directory_and_extension(&self.out_directory, extension),
1336 }
1337 }
1338
1339 pub fn temp_path_for_cgu(&self, flavor: OutputType, codegen_unit_name: &str) -> PathBuf {
1343 let extension = flavor.extension();
1344 self.temp_path_ext_for_cgu(extension, codegen_unit_name)
1345 }
1346
1347 pub fn temp_path_dwo_for_cgu(&self, codegen_unit_name: &str) -> PathBuf {
1349 let p = self.temp_path_ext_for_cgu(DWARF_OBJECT_EXT, codegen_unit_name);
1350 if let Some(dwo_out) = &self.explicit_dwo_out_directory {
1351 let mut o = dwo_out.clone();
1352 o.push(p.file_name().unwrap());
1353 o
1354 } else {
1355 p
1356 }
1357 }
1358
1359 pub fn temp_path_ext_for_cgu(&self, ext: &str, codegen_unit_name: &str) -> PathBuf {
1362 let mut extension = codegen_unit_name.to_string();
1363
1364 if let Some(rng) = &self.invocation_temp {
1366 extension.push('.');
1367 extension.push_str(rng);
1368 }
1369
1370 if !ext.is_empty() {
1373 extension.push('.');
1374 extension.push_str(RUST_CGU_EXT);
1375 extension.push('.');
1376 extension.push_str(ext);
1377 }
1378
1379 let temps_directory = self.temps_directory.as_ref().unwrap_or(&self.out_directory);
1380 maybe_strip_file_name(self.with_directory_and_extension(temps_directory, &extension))
1381 }
1382
1383 pub fn temp_path_for_diagnostic(&self, ext: &str) -> PathBuf {
1384 let temps_directory = self.temps_directory.as_ref().unwrap_or(&self.out_directory);
1385 self.with_directory_and_extension(temps_directory, &ext)
1386 }
1387
1388 pub fn with_extension(&self, extension: &str) -> PathBuf {
1389 self.with_directory_and_extension(&self.out_directory, extension)
1390 }
1391
1392 pub fn with_directory_and_extension(&self, directory: &Path, extension: &str) -> PathBuf {
1393 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/f5cedb83a788ea9581097abc36a2a8503a7f541c/compiler/rustc_session/src/config.rs:1393",
"rustc_session::config", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/f5cedb83a788ea9581097abc36a2a8503a7f541c/compiler/rustc_session/src/config.rs"),
::tracing_core::__macro_support::Option::Some(1393u32),
::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);
1394 let mut path = directory.join(&self.filestem);
1395 path.set_extension(extension);
1396 path
1397 }
1398
1399 pub fn split_dwarf_path(
1402 &self,
1403 split_debuginfo_kind: SplitDebuginfo,
1404 split_dwarf_kind: SplitDwarfKind,
1405 cgu_name: &str,
1406 ) -> Option<PathBuf> {
1407 let obj_out = self.temp_path_for_cgu(OutputType::Object, cgu_name);
1408 let dwo_out = self.temp_path_dwo_for_cgu(cgu_name);
1409 match (split_debuginfo_kind, split_dwarf_kind) {
1410 (SplitDebuginfo::Off, SplitDwarfKind::Single | SplitDwarfKind::Split) => None,
1411 (SplitDebuginfo::Packed | SplitDebuginfo::Unpacked, SplitDwarfKind::Single) => {
1415 Some(obj_out)
1416 }
1417 (SplitDebuginfo::Packed | SplitDebuginfo::Unpacked, SplitDwarfKind::Split) => {
1419 Some(dwo_out)
1420 }
1421 }
1422 }
1423}
1424
1425pub fn parse_remap_path_scope(
1427 early_dcx: &EarlyDiagCtxt,
1428 matches: &getopts::Matches,
1429 unstable_opts: &UnstableOptions,
1430) -> RemapPathScopeComponents {
1431 if let Some(v) = matches.opt_str("remap-path-scope") {
1432 let mut slot = RemapPathScopeComponents::empty();
1433 for s in v.split(',') {
1434 slot |= match s {
1435 "macro" => RemapPathScopeComponents::MACRO,
1436 "diagnostics" => RemapPathScopeComponents::DIAGNOSTICS,
1437 "documentation" => {
1438 if !unstable_opts.unstable_options {
1439 early_dcx.early_fatal("remapping `documentation` path scope requested but `-Zunstable-options` not specified");
1440 }
1441
1442 RemapPathScopeComponents::DOCUMENTATION
1443 },
1444 "debuginfo" => RemapPathScopeComponents::DEBUGINFO,
1445 "coverage" => RemapPathScopeComponents::COVERAGE,
1446 "object" => RemapPathScopeComponents::OBJECT,
1447 "all" => RemapPathScopeComponents::all(),
1448 _ => early_dcx.early_fatal("argument for `--remap-path-scope` must be a comma separated list of scopes: `macro`, `diagnostics`, `documentation`, `debuginfo`, `coverage`, `object`, `all`"),
1449 }
1450 }
1451 slot
1452 } else {
1453 RemapPathScopeComponents::all()
1454 }
1455}
1456
1457#[derive(#[automatically_derived]impl ::core::clone::Clone for Sysroot {
#[inline]
fn clone(&self) -> Self {
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 default", &self.explicit, &&self.default)
}
}Debug)]
1458pub struct Sysroot {
1459 pub explicit: Option<PathBuf>,
1460 pub default: PathBuf,
1461}
1462
1463impl Sysroot {
1464 pub fn new(explicit: Option<PathBuf>) -> Sysroot {
1465 Sysroot { explicit, default: filesearch::default_sysroot() }
1466 }
1467
1468 pub fn path(&self) -> &Path {
1470 self.explicit.as_deref().unwrap_or(&self.default)
1471 }
1472
1473 pub fn all_paths(&self) -> impl Iterator<Item = &Path> {
1475 self.explicit.as_deref().into_iter().chain(iter::once(&*self.default))
1476 }
1477}
1478
1479pub fn host_tuple() -> &'static str {
1484 (::core::option::Option::Some("x86_64-unknown-linux-gnu")option_env!("CFG_COMPILER_HOST_TRIPLE")).expect("CFG_COMPILER_HOST_TRIPLE")
1488}
1489
1490fn file_path_mapping(
1491 remap_path_prefix: Vec<(PathBuf, PathBuf)>,
1492 remap_cwd_prefix: Option<&Path>,
1493 remap_path_scope: RemapPathScopeComponents,
1494) -> FilePathMapping {
1495 let cwd_remap = if let Some(to) = remap_cwd_prefix
1498 && let Ok(cwd) = std::env::current_dir()
1499 {
1500 Some((cwd, to.to_path_buf()))
1501 } else {
1502 None
1503 };
1504 FilePathMapping::new(remap_path_prefix.into_iter().chain(cwd_remap).collect(), remap_path_scope)
1507}
1508
1509impl Default for Options {
1510 fn default() -> Options {
1511 let unstable_opts = UnstableOptions::default();
1512
1513 let working_dir = {
1517 let working_dir = std::env::current_dir().unwrap();
1518 let file_mapping =
1519 file_path_mapping(Vec::new(), None, RemapPathScopeComponents::empty());
1520 file_mapping.to_real_filename(&RealFileName::empty(), &working_dir)
1521 };
1522
1523 Options {
1524 crate_types: Vec::new(),
1525 optimize: OptLevel::No,
1526 debuginfo: DebugInfo::None,
1527 lint_opts: Vec::new(),
1528 lint_cap: None,
1529 describe_lints: false,
1530 output_types: OutputTypes(BTreeMap::new()),
1531 search_paths: ::alloc::vec::Vec::new()vec![],
1532 sysroot: Sysroot::new(None),
1533 target_triple: TargetTuple::from_tuple(host_tuple()),
1534 test: false,
1535 incremental: None,
1536 unstable_opts,
1537 prints: Vec::new(),
1538 cg: Default::default(),
1539 error_format: ErrorOutputType::default(),
1540 diagnostic_width: None,
1541 externs: Externs(BTreeMap::new()),
1542 crate_name: None,
1543 libs: Vec::new(),
1544 unstable_features: UnstableFeatures::Disallow,
1545 debug_assertions: true,
1546 actually_rustdoc: false,
1547 resolve_doc_links: ResolveDocLinks::None,
1548 trimmed_def_paths: false,
1549 cli_forced_codegen_units: None,
1550 cli_forced_local_thinlto_off: false,
1551 remap_path_prefix: Vec::new(),
1552 remap_path_scope: RemapPathScopeComponents::all(),
1553 real_rust_source_base_dir: None,
1554 real_rustc_dev_source_base_dir: None,
1555 edition: DEFAULT_EDITION,
1556 json_artifact_notifications: false,
1557 json_timings: false,
1558 json_unused_externs: JsonUnusedExterns::No,
1559 json_future_incompat: false,
1560 pretty: None,
1561 working_dir,
1562 color: ColorConfig::Auto,
1563 verbose: false,
1564 target_modifiers: BTreeMap::default(),
1565 mitigation_coverage_map: Default::default(),
1566 jobs: Jobs {
1567 frontend: JobsMode::Sequential,
1568 backend: JobsMode::Sequential,
1569 linker: LinkerJobs::Default,
1570 },
1571 recommended_stack_size: DEFAULT_STACK_SIZE,
1572 }
1573 }
1574}
1575
1576impl Options {
1577 pub fn build_dep_graph(&self) -> bool {
1579 self.incremental.is_some()
1580 || self.unstable_opts.dump_dep_graph
1581 || self.unstable_opts.query_dep_graph
1582 }
1583
1584 pub fn file_path_mapping(&self) -> FilePathMapping {
1585 file_path_mapping(
1586 self.remap_path_prefix.clone(),
1587 self.unstable_opts.remap_cwd_prefix.as_deref(),
1588 self.remap_path_scope,
1589 )
1590 }
1591
1592 pub fn will_create_output_file(&self) -> bool {
1594 !self.unstable_opts.parse_crate_root_only && self.unstable_opts.ls.is_empty() }
1597
1598 #[inline]
1599 pub fn share_generics(&self) -> bool {
1600 match self.unstable_opts.share_generics {
1601 Some(setting) => setting,
1602 None => self.optimize.objective() != OptimizationObjective::Speed,
1605 }
1606 }
1607
1608 pub fn get_symbol_mangling_version(&self) -> SymbolManglingVersion {
1609 self.cg.symbol_mangling_version.unwrap_or(SymbolManglingVersion::V0)
1610 }
1611
1612 #[inline]
1613 pub fn autodiff_enabled(&self) -> bool {
1614 self.unstable_opts.autodiff.contains(&AutoDiff::Enable)
1615 }
1616}
1617
1618impl UnstableOptions {
1619 pub fn dcx_flags(&self, can_emit_warnings: bool) -> DiagCtxtFlags {
1620 DiagCtxtFlags {
1621 can_emit_warnings,
1622 treat_err_as_bug: self.treat_err_as_bug,
1623 eagerly_emit_delayed_bugs: self.eagerly_emit_delayed_bugs,
1624 macro_backtrace: self.macro_backtrace,
1625 deduplicate_diagnostics: self.deduplicate_diagnostics,
1626 track_diagnostics: self.track_diagnostics,
1627 }
1628 }
1629
1630 pub fn src_hash_algorithm(&self, target: &Target) -> SourceFileHashAlgorithm {
1631 self.src_hash_algorithm.unwrap_or_else(|| {
1632 if target.is_like_msvc {
1633 SourceFileHashAlgorithm::Sha256
1634 } else {
1635 SourceFileHashAlgorithm::Md5
1636 }
1637 })
1638 }
1639
1640 pub fn checksum_hash_algorithm(&self) -> Option<SourceFileHashAlgorithm> {
1641 self.checksum_hash_algorithm
1642 }
1643}
1644
1645#[derive(#[automatically_derived]impl ::core::marker::Copy for EntryFnType { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for EntryFnType {
}
#[automatically_derived]impl ::core::clone::Clone for EntryFnType {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<u8>;
*self
}
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
EntryFnType {
}
#[automatically_derived]impl ::core::cmp::PartialEq for EntryFnType {
#[inline]
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::Main { sigpipe: __self_0 }, Self::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 {
Self::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 {
Self::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) {
match *self {
EntryFnType::Main { sigpipe: ref __binding_0 } =>
0u8.stable_hash(__hcx, __hasher),
}
match *self {
EntryFnType::Main { sigpipe: ref __binding_0 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
1647pub enum EntryFnType {
1648 Main {
1649 sigpipe: u8,
1656 },
1657}
1658
1659#[derive(#[automatically_derived]impl ::core::clone::Clone for Passes {
#[inline]
fn clone(&self) -> Self {
match self {
Self::Some(__self_0) =>
Passes::Some(::core::clone::Clone::clone(__self_0)),
Self::All => Passes::All,
}
}
}Clone, #[automatically_derived]impl ::core::hash::Hash for Passes {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state);
match self {
Self::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 {
Self::Some(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Some",
&__self_0),
Self::All => ::core::fmt::Formatter::write_str(f, "All"),
}
}
}Debug, #[automatically_derived]impl ::core::marker::StructuralPartialEq for Passes {
}
#[automatically_derived]impl ::core::cmp::PartialEq for Passes {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::Some(__self_0), Self::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)]
1660pub enum Passes {
1661 Some(Vec<String>),
1662 All,
1663}
1664
1665impl Passes {
1666 fn is_empty(&self) -> bool {
1667 match *self {
1668 Passes::Some(ref v) => v.is_empty(),
1669 Passes::All => false,
1670 }
1671 }
1672
1673 pub(crate) fn extend(&mut self, passes: impl IntoIterator<Item = String>) {
1674 match *self {
1675 Passes::Some(ref mut v) => v.extend(passes),
1676 Passes::All => {}
1677 }
1678 }
1679}
1680
1681#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for PAuthKey {
}
#[automatically_derived]impl ::core::clone::Clone for PAuthKey {
#[inline]
fn clone(&self) -> Self { *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) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
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::marker::StructuralPartialEq for PAuthKey
{
}
#[automatically_derived]impl ::core::cmp::PartialEq for PAuthKey {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq)]
1682pub enum PAuthKey {
1683 A,
1684 B,
1685}
1686
1687#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for PacRet {
}
#[automatically_derived]impl ::core::clone::Clone for PacRet {
#[inline]
fn clone(&self) -> Self {
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 pc key", &self.leaf, &self.pc, &&self.key)
}
}Debug, #[automatically_derived]impl ::core::marker::StructuralPartialEq for PacRet {
}
#[automatically_derived]impl ::core::cmp::PartialEq for PacRet {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.leaf == other.leaf && self.pc == other.pc &&
self.key == other.key
}
}PartialEq)]
1688pub struct PacRet {
1689 pub leaf: bool,
1690 pub pc: bool,
1691 pub key: PAuthKey,
1692}
1693
1694#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for BranchProtection {
}
#[automatically_derived]impl ::core::clone::Clone for BranchProtection {
#[inline]
fn clone(&self) -> Self {
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 pac_ret gcs", &self.bti, &self.pac_ret,
&&self.gcs)
}
}Debug, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
BranchProtection {
}
#[automatically_derived]impl ::core::cmp::PartialEq for BranchProtection {
#[inline]
fn eq(&self, other: &Self) -> 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() -> Self {
BranchProtection {
bti: ::core::default::Default::default(),
pac_ret: ::core::default::Default::default(),
gcs: ::core::default::Default::default(),
}
}
}Default)]
1695pub struct BranchProtection {
1696 pub bti: bool,
1697 pub pac_ret: Option<PacRet>,
1698 pub gcs: bool,
1699}
1700
1701#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for PointerAuthOption {
}
#[automatically_derived]impl ::core::clone::Clone for PointerAuthOption {
#[inline]
fn clone(&self) -> Self { *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::debug_c_like_enum_write_str(f,
"Aarch64JumpTableHardening AuthTraps Calls ElfGot FunctionPointerTypeDiscrimination IndirectGotos InitFini InitFiniAddressDiscrimination Intrinsics ReturnAddresses TypeInfoVTPtrDisc VTPtrAddrDisc VTPtrTypeDisc",
match self {
PointerAuthOption::Aarch64JumpTableHardening => 0usize,
PointerAuthOption::AuthTraps => 26usize,
PointerAuthOption::Calls => 36usize,
PointerAuthOption::ElfGot => 42usize,
PointerAuthOption::FunctionPointerTypeDiscrimination =>
49usize,
PointerAuthOption::IndirectGotos => 83usize,
PointerAuthOption::InitFini => 97usize,
PointerAuthOption::InitFiniAddressDiscrimination => 106usize,
PointerAuthOption::Intrinsics => 136usize,
PointerAuthOption::ReturnAddresses => 147usize,
PointerAuthOption::TypeInfoVTPtrDisc => 163usize,
PointerAuthOption::VTPtrAddrDisc => 181usize,
PointerAuthOption::VTPtrTypeDisc => 195usize,
})
}
}Debug, #[automatically_derived]impl ::core::cmp::Eq for PointerAuthOption { }Eq, #[automatically_derived]impl ::core::hash::Hash for PointerAuthOption {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state)
}
}Hash, #[automatically_derived]impl ::core::cmp::Ord for PointerAuthOption {
#[inline]
fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self),
&::core::intrinsics::discriminant_value(other))
}
}Ord, #[automatically_derived]impl ::core::cmp::PartialOrd for PointerAuthOption {
#[inline]
fn partial_cmp(&self, other: &Self)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}PartialOrd, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
PointerAuthOption {
}
#[automatically_derived]impl ::core::cmp::PartialEq for PointerAuthOption {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq)]
1702pub enum PointerAuthOption {
1703 Aarch64JumpTableHardening,
1708 AuthTraps,
1709 Calls,
1710 ElfGot,
1711 FunctionPointerTypeDiscrimination,
1712 IndirectGotos,
1713 InitFini,
1714 InitFiniAddressDiscrimination,
1715 Intrinsics,
1716 ReturnAddresses,
1717 TypeInfoVTPtrDisc,
1718 VTPtrAddrDisc,
1719 VTPtrTypeDisc,
1720 }
1722impl PointerAuthOption {
1723 pub fn parse(s: &str) -> Option<Self> {
1724 match s {
1725 "aarch64-jump-table-hardening" => Some(Self::Aarch64JumpTableHardening),
1726 "auth-traps" => Some(Self::AuthTraps),
1727 "calls" => Some(Self::Calls),
1728 "elf-got" => Some(Self::ElfGot),
1729 "function-pointer-type-discrimination" => Some(Self::FunctionPointerTypeDiscrimination),
1730 "indirect-gotos" => Some(Self::IndirectGotos),
1731 "init-fini" => Some(Self::InitFini),
1732 "init-fini-address-discrimination" => Some(Self::InitFiniAddressDiscrimination),
1733 "intrinsics" => Some(Self::Intrinsics),
1734 "return-addresses" => Some(Self::ReturnAddresses),
1735 "typeinfo-vt-ptr-discrimination" => Some(Self::TypeInfoVTPtrDisc),
1736 "vt-ptr-addr-discrimination" => Some(Self::VTPtrAddrDisc),
1737 "vt-ptr-type-discrimination" => Some(Self::VTPtrTypeDisc),
1738 _ => None,
1739 }
1740 }
1741}
1742
1743#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for JobsMode {
}
#[automatically_derived]impl ::core::clone::Clone for JobsMode {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<NonZero<usize>>;
*self
}
}Clone, #[automatically_derived]impl ::core::marker::Copy for JobsMode { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for JobsMode
{
}
#[automatically_derived]impl ::core::cmp::PartialEq for JobsMode {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::Parallel(__self_0), Self::Parallel(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for JobsMode {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<NonZero<usize>>;
}
}Eq, #[automatically_derived]impl ::core::cmp::PartialOrd for JobsMode {
#[inline]
fn partial_cmp(&self, other: &Self)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}PartialOrd, #[automatically_derived]impl ::core::cmp::Ord for JobsMode {
#[inline]
fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
match (self, other) {
(Self::Parallel(__self_0), Self::Parallel(__arg1_0)) =>
::core::cmp::Ord::cmp(__self_0, __arg1_0),
_ =>
::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self),
&::core::intrinsics::discriminant_value(other)),
}
}
}Ord)]
1744pub enum JobsMode {
1745 Sequential,
1748 Parallel(NonZero<usize>),
1752}
1753
1754impl JobsMode {
1755 pub fn limit(self) -> NonZero<usize> {
1756 match self {
1757 JobsMode::Sequential => NonZero::new(1).unwrap(),
1758 JobsMode::Parallel(n) => n,
1759 }
1760 }
1761
1762 pub fn is_parallel(self) -> bool {
1763 #[allow(non_exhaustive_omitted_patterns)] match self {
JobsMode::Parallel(..) => true,
_ => false,
}matches!(self, JobsMode::Parallel(..))
1764 }
1765}
1766
1767#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for LinkerJobs {
}
#[automatically_derived]impl ::core::clone::Clone for LinkerJobs {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<JobsMode>;
*self
}
}Clone, #[automatically_derived]impl ::core::marker::Copy for LinkerJobs { }Copy)]
1768pub enum LinkerJobs {
1769 Default,
1771 Explicit(JobsMode),
1773}
1774
1775impl LinkerJobs {
1776 pub fn mode(self) -> JobsMode {
1777 match self {
1778 LinkerJobs::Default => JobsMode::Sequential,
1779 LinkerJobs::Explicit(n) => n,
1780 }
1781 }
1782}
1783
1784#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for Jobs {
}
#[automatically_derived]impl ::core::clone::Clone for Jobs {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<JobsMode>;
let _: ::core::clone::AssertParamIsClone<LinkerJobs>;
*self
}
}Clone, #[automatically_derived]impl ::core::marker::Copy for Jobs { }Copy)]
1785pub struct Jobs {
1786 pub frontend: JobsMode,
1787 pub backend: JobsMode,
1788 pub linker: LinkerJobs,
1789}
1790
1791fn parse_jobs_all(
1792 early_dcx: &EarlyDiagCtxt,
1793 matches: &getopts::Matches,
1794 zthreads: Option<&str>,
1795 zno_parallel_backend: bool,
1796 unstable: bool,
1797) -> Jobs {
1798 if zno_parallel_backend {
1799 early_dcx.early_fatal("`-Zno-parallel-backend` is removed, use `--jobs-backend=1` instead");
1800 }
1801 let mut available = None;
1802 let jobs = matches
1803 .opt_str("jobs")
1804 .map(|s| parse_jobs_one(early_dcx, "--jobs", &s, unstable, &mut available));
1805 let check_upper_limit = |value: JobsMode, opt_name| {
1806 if let Some(jobs) = jobs
1807 && value.limit() > jobs.limit()
1808 {
1809 early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}` cannot be larger than `--jobs`",
opt_name))
})format!("`{opt_name}` cannot be larger than `--jobs`"));
1810 }
1811 };
1812 let frontend = match matches.opt_str("jobs-frontend") {
1813 Some(jobs_frontend) => {
1814 let opt_name = "--jobs-frontend";
1815 let frontend =
1816 parse_jobs_one(early_dcx, opt_name, &jobs_frontend, unstable, &mut available);
1817 check_upper_limit(frontend, opt_name);
1818 if zthreads.is_some() {
1819 early_dcx.early_fatal("cannot use both `--jobs-frontend` and `-Zthreads`");
1820 }
1821 frontend
1822 }
1823 None => match zthreads {
1824 Some(zthreads) => {
1825 let opt_name = "-Zthreads";
1826 let frontend =
1827 parse_jobs_one(early_dcx, opt_name, zthreads, unstable, &mut available);
1828 check_upper_limit(frontend, opt_name);
1829 frontend
1830 }
1831 None => JobsMode::Sequential, },
1833 };
1834 let backend = match matches.opt_str("jobs-backend") {
1835 Some(jobs_backend) => {
1836 let opt_name = "--jobs-backend";
1837 let backend =
1838 parse_jobs_one(early_dcx, opt_name, &jobs_backend, unstable, &mut available);
1839 check_upper_limit(backend, opt_name);
1840 backend
1841 }
1842 None => match jobs {
1843 Some(n) => n,
1844 None => parse_jobs_one(early_dcx, "", "0", unstable, &mut available),
1846 },
1847 };
1848 let linker = match matches.opt_str("jobs-linker") {
1849 Some(jobs_linker) => {
1850 let opt_name = "--jobs-linker";
1851 let linker =
1852 parse_jobs_one(early_dcx, opt_name, &jobs_linker, unstable, &mut available);
1853 check_upper_limit(linker, opt_name);
1854 LinkerJobs::Explicit(linker)
1855 }
1856 None => match jobs {
1857 Some(n) => LinkerJobs::Explicit(n),
1858 None => LinkerJobs::Default, },
1860 };
1861
1862 Jobs { frontend, backend, linker }
1863}
1864
1865fn parse_jobs_one(
1867 early_dcx: &EarlyDiagCtxt,
1868 opt_name: &str,
1869 s: &str,
1870 unstable: bool,
1871 available: &mut Option<u8>,
1872) -> JobsMode {
1873 if s == "sync" {
1874 if !unstable {
1876 early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}=sync` requires `-Z unstable-options`",
opt_name))
})format!("`{opt_name}=sync` requires `-Z unstable-options`"));
1877 }
1878 return JobsMode::Parallel(NonZero::new(1).unwrap());
1879 }
1880 let n = match u8::from_str(s) {
1884 Ok(0) => *available.get_or_insert_with(|| match thread::available_parallelism() {
1885 Ok(n) => u8::try_from(n.get()).unwrap_or(u8::MAX),
1886 Err(_) => 1,
1887 }),
1888 Ok(n) => n,
1889 Err(_) => early_dcx
1890 .early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}`: expected a number from 0 to 255 or `sync`",
opt_name))
})format!("`{opt_name}`: expected a number from 0 to 255 or `sync`")),
1891 };
1892 match n {
1894 0 => ::core::panicking::unreachable_default_msg()unreachable!(),
1895 1 => JobsMode::Sequential,
1896 _ => JobsMode::Parallel(NonZero::new(usize::from(n)).unwrap()),
1897 }
1898}
1899
1900pub fn build_configuration(sess: &Session, mut user_cfg: Cfg) -> Cfg {
1901 cfg::disallow_cfgs(sess, &user_cfg);
1903
1904 user_cfg.extend(cfg::default_configuration(sess));
1907 user_cfg
1908}
1909
1910pub fn build_target_config(
1911 early_dcx: &EarlyDiagCtxt,
1912 target: &TargetTuple,
1913 sysroot: &Path,
1914 unstable_options: bool,
1915) -> Target {
1916 match Target::search(target, sysroot, unstable_options) {
1917 Ok((target, warnings)) => {
1918 for warning in warnings.warning_messages() {
1919 early_dcx.early_warn(warning)
1920 }
1921
1922 if !#[allow(non_exhaustive_omitted_patterns)] match target.pointer_width {
16 | 32 | 64 => true,
_ => false,
}matches!(target.pointer_width, 16 | 32 | 64) {
1923 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!(
1924 "target specification was invalid: unrecognized target-pointer-width {}",
1925 target.pointer_width
1926 ))
1927 }
1928 target
1929 }
1930 Err(e) => {
1931 let mut err =
1932 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}"));
1933 err.help("run `rustc --print target-list` for a list of built-in targets");
1934 let typed = target.tuple();
1935 let limit = typed.len() / 3 + 1;
1936 if let Some(suggestion) = rustc_target::spec::TARGETS
1937 .iter()
1938 .filter_map(|&t| {
1939 rustc_span::edit_distance::edit_distance_with_substrings(typed, t, limit)
1940 .map(|d| (d, t))
1941 })
1942 .min_by_key(|(d, _)| *d)
1943 .map(|(_, t)| t)
1944 {
1945 err.help(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("did you mean `{0}`?", suggestion))
})format!("did you mean `{suggestion}`?"));
1946 }
1947 err.emit_fatal()
1948 }
1949 }
1950}
1951
1952#[derive(#[automatically_derived]impl ::core::marker::Copy for OptionStability { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for OptionStability {
}
#[automatically_derived]impl ::core::clone::Clone for OptionStability {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
OptionStability {
}
#[automatically_derived]impl ::core::cmp::PartialEq for OptionStability {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for OptionStability { }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)]
1953pub enum OptionStability {
1954 Stable,
1955 Unstable,
1956}
1957
1958#[derive(#[automatically_derived]impl ::core::marker::Copy for OptionKind { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for OptionKind {
}
#[automatically_derived]impl ::core::clone::Clone for OptionKind {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
OptionKind {
}
#[automatically_derived]impl ::core::cmp::PartialEq for OptionKind {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for OptionKind { }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)]
1959pub enum OptionKind {
1960 Opt,
1964
1965 Multi,
1969
1970 Flag,
1975
1976 FlagMulti,
1981}
1982
1983pub struct RustcOptGroup {
1984 pub name: &'static str,
1992 stability: OptionStability,
1993 kind: OptionKind,
1994
1995 short_name: &'static str,
1996 long_name: &'static str,
1997 desc: &'static str,
1998 value_hint: &'static str,
1999
2000 pub is_verbose_help_only: bool,
2003}
2004
2005impl RustcOptGroup {
2006 pub fn is_stable(&self) -> bool {
2007 self.stability == OptionStability::Stable
2008 }
2009
2010 pub fn apply(&self, options: &mut getopts::Options) {
2011 let &Self { short_name, long_name, desc, value_hint, .. } = self;
2012 match self.kind {
2013 OptionKind::Opt => options.optopt(short_name, long_name, desc, value_hint),
2014 OptionKind::Multi => options.optmulti(short_name, long_name, desc, value_hint),
2015 OptionKind::Flag => options.optflag(short_name, long_name, desc),
2016 OptionKind::FlagMulti => options.optflagmulti(short_name, long_name, desc),
2017 };
2018 }
2019
2020 pub fn long_name(&self) -> &str {
2022 self.long_name
2023 }
2024}
2025
2026pub fn make_opt(
2027 stability: OptionStability,
2028 kind: OptionKind,
2029 short_name: &'static str,
2030 long_name: &'static str,
2031 desc: &'static str,
2032 value_hint: &'static str,
2033) -> RustcOptGroup {
2034 match kind {
2036 OptionKind::Opt | OptionKind::Multi => {}
2037 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, ""),
2038 }
2039 RustcOptGroup {
2040 name: cmp::max_by_key(short_name, long_name, |s| s.len()),
2041 stability,
2042 kind,
2043 short_name,
2044 long_name,
2045 desc,
2046 value_hint,
2047 is_verbose_help_only: false,
2048 }
2049}
2050
2051static EDITION_STRING: LazyLock<String> = LazyLock::new(|| {
2052 ::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!(
2053 "Specify which edition of the compiler to use when compiling code. \
2054The default is {DEFAULT_EDITION} and the latest stable edition is {LATEST_STABLE_EDITION}."
2055 )
2056});
2057
2058static EMIT_HELP: LazyLock<String> = LazyLock::new(|| {
2059 let mut result =
2060 String::from("Comma separated list of types of output for the compiler to emit.\n");
2061 result.push_str("Each TYPE has the default FILE name:\n");
2062
2063 for output in OutputType::iter_all() {
2064 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()));
2065 }
2066
2067 result
2068});
2069
2070pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
2080 use OptionKind::{Flag, FlagMulti, Multi, Opt};
2081 use OptionStability::{Stable, Unstable};
2082
2083 use self::make_opt as opt;
2084
2085 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![
2086 opt(Stable, Flag, "h", "help", "Display this message", ""),
2087 opt(
2088 Stable,
2089 Multi,
2090 "",
2091 "cfg",
2092 "Configure the compilation environment.\n\
2093 SPEC supports the syntax `<NAME>[=\"<VALUE>\"]`.",
2094 "<SPEC>",
2095 ),
2096 opt(Stable, Multi, "", "check-cfg", "Provide list of expected cfgs for checking", "<SPEC>"),
2097 opt(
2098 Stable,
2099 Multi,
2100 "L",
2101 "",
2102 "Add a directory to the library search path. \
2103 The optional KIND can be one of <dependency|crate|native|framework|all> (default: all).",
2104 "[<KIND>=]<PATH>",
2105 ),
2106 opt(
2107 Stable,
2108 Multi,
2109 "l",
2110 "",
2111 "Link the generated crate(s) to the specified native\n\
2112 library NAME. The optional KIND can be one of\n\
2113 <static|framework|dylib> (default: dylib).\n\
2114 Optional comma separated MODIFIERS\n\
2115 <bundle|verbatim|whole-archive|as-needed>\n\
2116 may be specified each with a prefix of either '+' to\n\
2117 enable or '-' to disable.",
2118 "[<KIND>[:<MODIFIERS>]=]<NAME>[:<RENAME>]",
2119 ),
2120 make_crate_type_option(),
2121 opt(Stable, Opt, "", "crate-name", "Specify the name of the crate being built", "<NAME>"),
2122 opt(Stable, Opt, "", "edition", &EDITION_STRING, EDITION_NAME_LIST),
2123 opt(Stable, Multi, "", "emit", &EMIT_HELP, "<TYPE>[=<FILE>]"),
2124 opt(Stable, Multi, "", "print", &print_request::PRINT_HELP, "<INFO>[=<FILE>]"),
2125 opt(Stable, FlagMulti, "g", "", "Equivalent to -C debuginfo=2", ""),
2126 opt(Stable, FlagMulti, "O", "", "Equivalent to -C opt-level=3", ""),
2127 opt(Stable, Opt, "o", "", "Write output to FILENAME", "<FILENAME>"),
2128 opt(Stable, Opt, "", "out-dir", "Write output to compiler-chosen filename in DIR", "<DIR>"),
2129 opt(
2130 Stable,
2131 Opt,
2132 "",
2133 "explain",
2134 "Provide a detailed explanation of an error message",
2135 "<OPT>",
2136 ),
2137 opt(Stable, Flag, "", "test", "Build a test harness", ""),
2138 opt(Stable, Opt, "", "target", "Target tuple for which the code is compiled", "<TARGET>"),
2139 opt(Stable, Multi, "A", "allow", "Set lint allowed", "<LINT>"),
2140 opt(Stable, Multi, "W", "warn", "Set lint warnings", "<LINT>"),
2141 opt(Stable, Multi, "", "force-warn", "Set lint force-warn", "<LINT>"),
2142 opt(Stable, Multi, "D", "deny", "Set lint denied", "<LINT>"),
2143 opt(Stable, Multi, "F", "forbid", "Set lint forbidden", "<LINT>"),
2144 opt(
2145 Stable,
2146 Multi,
2147 "",
2148 "cap-lints",
2149 "Set the most restrictive lint level. More restrictive lints are capped at this level",
2150 "<LEVEL>",
2151 ),
2152 opt(Stable, Multi, "C", "codegen", "Set a codegen option", "<OPT>[=<VALUE>]"),
2153 opt(Stable, Flag, "V", "version", "Print version info and exit", ""),
2154 opt(Stable, Flag, "v", "verbose", "Use verbose output", ""),
2155 ];
2156
2157 let verbose_only = [
2160 opt(
2161 Stable,
2162 Multi,
2163 "",
2164 "extern",
2165 "Specify where an external rust library is located",
2166 "<NAME>[=<PATH>]",
2167 ),
2168 opt(Stable, Opt, "", "sysroot", "Override the system root", "<PATH>"),
2169 opt(Unstable, Multi, "Z", "", "Set unstable / perma-unstable options", "<FLAG>"),
2170 opt(
2171 Stable,
2172 Opt,
2173 "",
2174 "error-format",
2175 "How errors and other messages are produced",
2176 "<human|json|short>",
2177 ),
2178 opt(Stable, Multi, "", "json", "Configure the JSON output of the compiler", "<CONFIG>"),
2179 opt(
2180 Stable,
2181 Opt,
2182 "",
2183 "color",
2184 "Configure coloring of output:
2185 * auto = colorize, if output goes to a tty (default);
2186 * always = always colorize output;
2187 * never = never colorize output",
2188 "<auto|always|never>",
2189 ),
2190 opt(
2191 Stable,
2192 Opt,
2193 "",
2194 "diagnostic-width",
2195 "Inform rustc of the width of the output so that diagnostics can be truncated to fit",
2196 "<WIDTH>",
2197 ),
2198 opt(
2199 Stable,
2200 Multi,
2201 "",
2202 "remap-path-prefix",
2203 "Remap source names in all output (compiler messages and output files)",
2204 "<FROM>=<TO>",
2205 ),
2206 opt(
2207 Stable,
2208 Opt,
2209 "",
2210 "remap-path-scope",
2211 "Defines which scopes of paths should be remapped by `--remap-path-prefix`",
2212 "<macro,diagnostics,debuginfo,coverage,object,all>",
2213 ),
2214 opt(Unstable, Opt, "j", "jobs", "Limit on the number of used parallel jobs", "<N>"),
2215 opt(
2216 Unstable,
2217 Opt,
2218 "",
2219 "jobs-frontend",
2220 "Limit on the number of parallel jobs used by frontend",
2221 "<N>",
2222 ),
2223 opt(
2224 Unstable,
2225 Opt,
2226 "",
2227 "jobs-backend",
2228 "Limit on the number of parallel jobs used by backend",
2229 "<N>",
2230 ),
2231 opt(
2232 Unstable,
2233 Opt,
2234 "",
2235 "jobs-linker",
2236 "Limit on the number of parallel jobs used by linker",
2237 "<N>",
2238 ),
2239 ];
2240 options.extend(verbose_only.into_iter().map(|mut opt| {
2241 opt.is_verbose_help_only = true;
2242 opt
2243 }));
2244
2245 options
2246}
2247
2248pub fn get_cmd_lint_options(
2249 early_dcx: &EarlyDiagCtxt,
2250 matches: &getopts::Matches,
2251) -> (Vec<(String, lint::Level)>, bool, Option<lint::Level>) {
2252 let mut lint_opts_with_position = ::alloc::vec::Vec::new()vec![];
2253 let mut describe_lints = false;
2254
2255 for level in [lint::Allow, lint::Warn, lint::ForceWarn, lint::Deny, lint::Forbid] {
2256 for (arg_pos, lint_name) in matches.opt_strs_pos(level.as_str()) {
2257 if lint_name == "help" {
2258 describe_lints = true;
2259 } else {
2260 lint_opts_with_position.push((arg_pos, lint_name.replace('-', "_"), level));
2261 }
2262 }
2263 }
2264
2265 lint_opts_with_position.sort_by_key(|x| x.0);
2266 let lint_opts = lint_opts_with_position
2267 .iter()
2268 .cloned()
2269 .map(|(_, lint_name, level)| (lint_name, level))
2270 .collect();
2271
2272 let lint_cap = matches.opt_str("cap-lints").map(|cap| {
2273 lint::Level::from_str(&cap)
2274 .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}`")))
2275 });
2276
2277 (lint_opts, describe_lints, lint_cap)
2278}
2279
2280pub fn parse_color(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> ColorConfig {
2282 match matches.opt_str("color").as_deref() {
2283 Some("auto") => ColorConfig::Auto,
2284 Some("always") => ColorConfig::Always,
2285 Some("never") => ColorConfig::Never,
2286
2287 None => ColorConfig::Auto,
2288
2289 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!(
2290 "argument for `--color` must be auto, \
2291 always or never (instead was `{arg}`)"
2292 )),
2293 }
2294}
2295
2296pub struct JsonConfig {
2298 pub json_rendered: HumanReadableErrorType,
2299 pub json_color: ColorConfig,
2300 json_artifact_notifications: bool,
2301 json_timings: bool,
2304 pub json_unused_externs: JsonUnusedExterns,
2305 json_future_incompat: bool,
2306}
2307
2308#[derive(#[automatically_derived]impl ::core::marker::Copy for JsonUnusedExterns { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for JsonUnusedExterns {
}
#[automatically_derived]impl ::core::clone::Clone for JsonUnusedExterns {
#[inline]
fn clone(&self) -> Self { *self }
}Clone)]
2310pub enum JsonUnusedExterns {
2311 No,
2313 Silent,
2315 Loud,
2317}
2318
2319impl JsonUnusedExterns {
2320 pub fn is_enabled(&self) -> bool {
2321 match self {
2322 JsonUnusedExterns::No => false,
2323 JsonUnusedExterns::Loud | JsonUnusedExterns::Silent => true,
2324 }
2325 }
2326
2327 pub fn is_loud(&self) -> bool {
2328 match self {
2329 JsonUnusedExterns::No | JsonUnusedExterns::Silent => false,
2330 JsonUnusedExterns::Loud => true,
2331 }
2332 }
2333}
2334
2335pub fn parse_json(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> JsonConfig {
2340 let mut json_rendered = HumanReadableErrorType { short: false, unicode: false };
2341 let mut json_color = ColorConfig::Never;
2342 let mut json_artifact_notifications = false;
2343 let mut json_unused_externs = JsonUnusedExterns::No;
2344 let mut json_future_incompat = false;
2345 let mut json_timings = false;
2346 for option in matches.opt_strs("json") {
2347 if matches.opt_str("color").is_some() {
2351 early_dcx.early_fatal("cannot specify the `--color` option with `--json`");
2352 }
2353
2354 for sub_option in option.split(',') {
2355 match sub_option {
2356 "diagnostic-short" => {
2357 json_rendered = HumanReadableErrorType { short: true, unicode: false };
2358 }
2359 "diagnostic-unicode" => {
2360 json_rendered = HumanReadableErrorType { short: false, unicode: true };
2361 }
2362 "diagnostic-rendered-ansi" => json_color = ColorConfig::Always,
2363 "artifacts" => json_artifact_notifications = true,
2364 "timings" => json_timings = true,
2365 "unused-externs" => json_unused_externs = JsonUnusedExterns::Loud,
2366 "unused-externs-silent" => json_unused_externs = JsonUnusedExterns::Silent,
2367 "future-incompat" => json_future_incompat = true,
2368 s => early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("unknown `--json` option `{0}`", s))
})format!("unknown `--json` option `{s}`")),
2369 }
2370 }
2371 }
2372
2373 JsonConfig {
2374 json_rendered,
2375 json_color,
2376 json_artifact_notifications,
2377 json_timings,
2378 json_unused_externs,
2379 json_future_incompat,
2380 }
2381}
2382
2383pub fn parse_error_format(
2385 early_dcx: &mut EarlyDiagCtxt,
2386 matches: &getopts::Matches,
2387 color_config: ColorConfig,
2388 json_color: ColorConfig,
2389 json_rendered: HumanReadableErrorType,
2390) -> ErrorOutputType {
2391 let default_kind = HumanReadableErrorType { short: false, unicode: false };
2392 let error_format = if matches.opts_present(&["error-format".to_owned()]) {
2397 match matches.opt_str("error-format").as_deref() {
2398 None | Some("human") => {
2399 ErrorOutputType::HumanReadable { color_config, kind: default_kind }
2400 }
2401 Some("json") => {
2402 ErrorOutputType::Json { pretty: false, json_rendered, color_config: json_color }
2403 }
2404 Some("pretty-json") => {
2405 ErrorOutputType::Json { pretty: true, json_rendered, color_config: json_color }
2406 }
2407 Some("short") => ErrorOutputType::HumanReadable {
2408 kind: HumanReadableErrorType { short: true, unicode: false },
2409 color_config,
2410 },
2411 Some("human-unicode") => ErrorOutputType::HumanReadable {
2412 kind: HumanReadableErrorType { short: false, unicode: true },
2413 color_config,
2414 },
2415 Some(arg) => {
2416 early_dcx.set_error_format(ErrorOutputType::HumanReadable {
2417 color_config,
2418 kind: default_kind,
2419 });
2420 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!(
2421 "argument for `--error-format` must be `human`, `human-unicode`, \
2422 `json`, `pretty-json` or `short` (instead was `{arg}`)"
2423 ))
2424 }
2425 }
2426 } else {
2427 ErrorOutputType::HumanReadable { color_config, kind: default_kind }
2428 };
2429
2430 match error_format {
2431 ErrorOutputType::Json { .. } => {}
2432
2433 _ if !matches.opt_strs("json").is_empty() => {
2437 early_dcx.early_fatal("using `--json` requires also using `--error-format=json`");
2438 }
2439
2440 _ => {}
2441 }
2442
2443 error_format
2444}
2445
2446pub fn parse_crate_edition(
2447 early_dcx: &EarlyDiagCtxt,
2448 matches: &getopts::Matches,
2449 has_input: bool,
2450) -> Edition {
2451 let is_nightly = nightly_options::match_is_nightly_build(matches);
2452 let edition_list = if is_nightly { EDITION_NAME_LIST } else { EDITION_NAME_LIST_STABLE };
2453 let edition = match matches.opt_str("edition") {
2454 Some(arg) => Edition::from_str(&arg).unwrap_or_else(|_| {
2455 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_list, arg))
})format!(
2456 "argument for `--edition` must be one of: {edition_list} (instead was `{arg}`)",
2457 ))
2458 }),
2459 None => {
2460 if has_input {
2461 {
::std::io::_eprint(format_args!("`--edition` is unspecified, defaulting to `{0}` while the latest is `{1}`; it must be one of: {2}\n\n",
DEFAULT_EDITION, LATEST_STABLE_EDITION, edition_list));
};eprintln!(
2462 "`--edition` is unspecified, defaulting to `{DEFAULT_EDITION}` while the \
2463 latest is `{LATEST_STABLE_EDITION}`; it must be one of: {edition_list}\n",
2464 );
2465 }
2466 DEFAULT_EDITION
2467 }
2468 };
2469
2470 if !edition.is_stable() && !nightly_options::unstable_options_enabled(matches) {
2471 let msg = if !is_nightly {
2472 ::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!(
2473 "the crate requires edition {edition}, but the latest edition supported by this \
2474 Rust version is {LATEST_STABLE_EDITION}"
2475 )
2476 } else {
2477 ::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")
2478 };
2479 early_dcx.early_fatal(msg)
2480 }
2481
2482 edition
2483}
2484
2485fn check_error_format_stability(
2486 early_dcx: &EarlyDiagCtxt,
2487 unstable_opts: &UnstableOptions,
2488 unstable_flags_enabled: bool,
2489 format: ErrorOutputType,
2490) {
2491 if unstable_opts.unstable_options || unstable_flags_enabled {
2492 return;
2493 }
2494 let format = match format {
2495 ErrorOutputType::Json { pretty: true, .. } => "pretty-json",
2496 ErrorOutputType::HumanReadable { kind, .. } => match kind {
2497 HumanReadableErrorType { unicode: true, .. } => "human-unicode",
2498 _ => return,
2499 },
2500 _ => return,
2501 };
2502 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"))
2503}
2504
2505fn parse_output_types(
2506 early_dcx: &EarlyDiagCtxt,
2507 unstable_opts: &UnstableOptions,
2508 matches: &getopts::Matches,
2509) -> OutputTypes {
2510 let mut output_types = BTreeMap::new();
2511 if !unstable_opts.parse_crate_root_only {
2512 for list in matches.opt_strs("emit") {
2513 for output_type in list.split(',') {
2514 let (shorthand, path) = split_out_file_name(output_type);
2515 let output_type = OutputType::from_shorthand(shorthand).unwrap_or_else(|| {
2516 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!(
2517 "unknown emission type: `{shorthand}` - expected one of: {display}",
2518 display = OutputType::shorthands_display(),
2519 ))
2520 });
2521 if output_type == OutputType::ThinLinkBitcode && !unstable_opts.unstable_options {
2522 early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} requested but -Zunstable-options not specified",
OutputType::ThinLinkBitcode.shorthand()))
})format!(
2523 "{} requested but -Zunstable-options not specified",
2524 OutputType::ThinLinkBitcode.shorthand()
2525 ));
2526 }
2527 output_types.insert(output_type, path);
2528 }
2529 }
2530 };
2531 if output_types.is_empty() {
2532 output_types.insert(OutputType::Exe, None);
2533 }
2534 OutputTypes(output_types)
2535}
2536
2537fn split_out_file_name(arg: &str) -> (&str, Option<OutFileName>) {
2538 match arg.split_once('=') {
2539 None => (arg, None),
2540 Some((kind, "-")) => (kind, Some(OutFileName::Stdout)),
2541 Some((kind, path)) => (kind, Some(OutFileName::Real(PathBuf::from(path)))),
2542 }
2543}
2544
2545fn should_override_cgus_and_disable_thinlto(
2546 early_dcx: &EarlyDiagCtxt,
2547 output_types: &OutputTypes,
2548 matches: &getopts::Matches,
2549 mut codegen_units: Option<usize>,
2550) -> (bool, Option<usize>) {
2551 let mut disable_local_thinlto = false;
2552 let incompatible: Vec<_> = output_types
2555 .0
2556 .iter()
2557 .map(|ot_path| ot_path.0)
2558 .filter(|ot| !ot.is_compatible_with_codegen_units_and_single_output_file())
2559 .map(|ot| ot.shorthand())
2560 .collect();
2561 if !incompatible.is_empty() {
2562 match codegen_units {
2563 Some(n) if n > 1 => {
2564 if matches.opt_present("o") {
2565 for ot in &incompatible {
2566 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!(
2567 "`--emit={ot}` with `-o` incompatible with \
2568 `-C codegen-units=N` for N > 1",
2569 ));
2570 }
2571 early_dcx.early_warn("resetting to default -C codegen-units=1");
2572 codegen_units = Some(1);
2573 disable_local_thinlto = true;
2574 }
2575 }
2576 _ => {
2577 codegen_units = Some(1);
2578 disable_local_thinlto = true;
2579 }
2580 }
2581 }
2582
2583 if codegen_units == Some(0) {
2584 early_dcx.early_fatal("value for codegen units must be a positive non-zero integer");
2585 }
2586
2587 (disable_local_thinlto, codegen_units)
2588}
2589
2590pub fn parse_target_triple(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> TargetTuple {
2591 match matches.opt_str("target") {
2592 Some(target) if target.ends_with(".json") => {
2593 let path = Path::new(&target);
2594 TargetTuple::from_path(path).unwrap_or_else(|_| {
2595 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"))
2596 })
2597 }
2598 Some(target) => TargetTuple::TargetTuple(target),
2599 _ => TargetTuple::from_tuple(host_tuple()),
2600 }
2601}
2602
2603fn parse_opt_level(
2604 early_dcx: &EarlyDiagCtxt,
2605 matches: &getopts::Matches,
2606 cg: &CodegenOptions,
2607) -> OptLevel {
2608 let max_o = matches.opt_positions("O").into_iter().max();
2615 let max_c = matches
2616 .opt_strs_pos("C")
2617 .into_iter()
2618 .flat_map(|(i, s)| {
2619 if let Some("opt-level") = s.split('=').next() { Some(i) } else { None }
2621 })
2622 .max();
2623 if max_o > max_c {
2624 OptLevel::Aggressive
2625 } else {
2626 match cg.opt_level.as_ref() {
2627 "0" => OptLevel::No,
2628 "1" => OptLevel::Less,
2629 "2" => OptLevel::More,
2630 "3" => OptLevel::Aggressive,
2631 "s" => OptLevel::Size,
2632 "z" => OptLevel::SizeMin,
2633 arg => {
2634 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!(
2635 "optimization level needs to be \
2636 between 0-3, s or z (instead was `{arg}`)"
2637 ));
2638 }
2639 }
2640 }
2641}
2642
2643fn select_debuginfo(matches: &getopts::Matches, cg: &CodegenOptions) -> DebugInfo {
2644 let max_g = matches.opt_positions("g").into_iter().max();
2645 let max_c = matches
2646 .opt_strs_pos("C")
2647 .into_iter()
2648 .flat_map(|(i, s)| {
2649 if let Some("debuginfo") = s.split('=').next() { Some(i) } else { None }
2651 })
2652 .max();
2653 if max_g > max_c { DebugInfo::Full } else { cg.debuginfo }
2654}
2655
2656pub fn parse_externs(
2657 early_dcx: &EarlyDiagCtxt,
2658 matches: &getopts::Matches,
2659 unstable_opts: &UnstableOptions,
2660) -> Externs {
2661 let is_unstable_enabled = unstable_opts.unstable_options;
2662 let mut externs: BTreeMap<String, ExternEntry> = BTreeMap::new();
2663 for arg in matches.opt_strs("extern") {
2664 let ExternOpt { crate_name: name, path, options } =
2665 split_extern_opt(early_dcx, unstable_opts, &arg).unwrap_or_else(|e| e.emit_fatal());
2666
2667 let entry = externs.entry(name.to_owned());
2668
2669 use std::collections::btree_map::Entry;
2670
2671 let entry = if let Some(path) = path {
2672 let path = CanonicalizedPath::new(path);
2674 match entry {
2675 Entry::Vacant(vacant) => {
2676 let files = BTreeSet::from_iter(iter::once(path));
2677 vacant.insert(ExternEntry::new(ExternLocation::ExactPaths(files)))
2678 }
2679 Entry::Occupied(occupied) => {
2680 let ext_ent = occupied.into_mut();
2681 match ext_ent {
2682 ExternEntry { location: ExternLocation::ExactPaths(files), .. } => {
2683 files.insert(path);
2684 }
2685 ExternEntry {
2686 location: location @ ExternLocation::FoundInLibrarySearchDirectories,
2687 ..
2688 } => {
2689 let files = BTreeSet::from_iter(iter::once(path));
2691 *location = ExternLocation::ExactPaths(files);
2692 }
2693 }
2694 ext_ent
2695 }
2696 }
2697 } else {
2698 match entry {
2700 Entry::Vacant(vacant) => {
2701 vacant.insert(ExternEntry::new(ExternLocation::FoundInLibrarySearchDirectories))
2702 }
2703 Entry::Occupied(occupied) => {
2704 occupied.into_mut()
2706 }
2707 }
2708 };
2709
2710 let mut is_private_dep = false;
2711 let mut add_prelude = true;
2712 let mut nounused_dep = false;
2713 let mut force = false;
2714 if let Some(opts) = options {
2715 if !is_unstable_enabled {
2716 early_dcx.early_fatal(
2717 "the `-Z unstable-options` flag must also be passed to \
2718 enable `--extern` options",
2719 );
2720 }
2721 for opt in opts.split(',') {
2722 match opt {
2723 "priv" => is_private_dep = true,
2724 "noprelude" => {
2725 if let ExternLocation::ExactPaths(_) = &entry.location {
2726 add_prelude = false;
2727 } else {
2728 early_dcx.early_fatal(
2729 "the `noprelude` --extern option requires a file path",
2730 );
2731 }
2732 }
2733 "nounused" => nounused_dep = true,
2734 "force" => force = true,
2735 _ => early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("unknown --extern option `{0}`",
opt))
})format!("unknown --extern option `{opt}`")),
2736 }
2737 }
2738 }
2739
2740 entry.is_private_dep |= is_private_dep;
2743 entry.nounused_dep |= nounused_dep;
2745 entry.force |= force;
2747 entry.add_prelude |= add_prelude;
2749 }
2750 Externs(externs)
2751}
2752
2753fn parse_remap_path_prefix(
2754 early_dcx: &EarlyDiagCtxt,
2755 matches: &getopts::Matches,
2756) -> Vec<(PathBuf, PathBuf)> {
2757 matches
2758 .opt_strs("remap-path-prefix")
2759 .into_iter()
2760 .map(|remap| match remap.rsplit_once('=') {
2761 None => {
2762 early_dcx.early_fatal("--remap-path-prefix must contain '=' between FROM and TO")
2763 }
2764 Some((from, to)) => (PathBuf::from(from), PathBuf::from(to)),
2765 })
2766 .collect()
2767}
2768
2769#[allow(rustc::bad_opt_access)]
2771pub fn build_session_options(
2772 early_dcx: &mut EarlyDiagCtxt,
2773 matches: &getopts::Matches,
2774 has_input: bool,
2775) -> Options {
2776 let color = parse_color(early_dcx, matches);
2777
2778 let edition = parse_crate_edition(early_dcx, matches, has_input);
2779
2780 let crate_name = matches.opt_str("crate-name");
2781 let unstable_features = UnstableFeatures::from_environment(crate_name.as_deref());
2782 let JsonConfig {
2783 json_rendered,
2784 json_color,
2785 json_artifact_notifications,
2786 json_timings,
2787 json_unused_externs,
2788 json_future_incompat,
2789 } = parse_json(early_dcx, matches);
2790
2791 let error_format = parse_error_format(early_dcx, matches, color, json_color, json_rendered);
2792
2793 early_dcx.set_error_format(error_format);
2794
2795 let diagnostic_width = matches.opt_get("diagnostic-width").unwrap_or_else(|_| {
2796 early_dcx.early_fatal("`--diagnostic-width` must be an positive integer");
2797 });
2798
2799 let unparsed_crate_types = matches.opt_strs("crate-type");
2800 let crate_types = parse_crate_types_from_list(unparsed_crate_types)
2801 .unwrap_or_else(|e| early_dcx.early_fatal(e));
2802
2803 let mut collected_options = Default::default();
2804
2805 let mut unstable_opts = UnstableOptions::build(early_dcx, matches, &mut collected_options);
2806
2807 if unstable_opts.assumptions_on_binders {
2811 let no_next_solver = matches
2814 .opt_strs("Z")
2815 .iter()
2816 .rfind(|arg| arg.starts_with("next-solver"))
2817 .is_some_and(|arg| *arg == "next-solver=no" || *arg == "next-solver=coherence");
2818 if no_next_solver {
2819 early_dcx.early_warn(
2820 "-Zassumptions-on-binders unconditionally enables the next trait solver; \
2821 `-Znext-solver=no` is ignored",
2822 );
2823 }
2824 unstable_opts.next_solver = NextSolverConfig::Globally;
2825 }
2826
2827 if unstable_opts.staticlib_hide_internal_symbols && !crate_types.contains(&CrateType::StaticLib)
2828 {
2829 early_dcx.early_warn(
2830 "-Zstaticlib-hide-internal-symbols has no effect without `--crate-type staticlib`",
2831 );
2832 }
2833
2834 if unstable_opts.staticlib_rename_internal_symbols
2835 && !crate_types.contains(&CrateType::StaticLib)
2836 {
2837 early_dcx.early_warn(
2838 "-Zstaticlib-rename-internal-symbols has no effect without `--crate-type staticlib`",
2839 );
2840 }
2841
2842 let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(early_dcx, matches);
2843
2844 if !unstable_opts.unstable_options && json_timings {
2845 early_dcx.early_fatal("--json=timings is unstable and requires using `-Zunstable-options`");
2846 }
2847
2848 check_error_format_stability(
2849 early_dcx,
2850 &unstable_opts,
2851 unstable_features.allow_unstable_compiler_flag("error-format"),
2852 error_format,
2853 );
2854
2855 let output_types = parse_output_types(early_dcx, &unstable_opts, matches);
2856
2857 let mut cg = CodegenOptions::build(early_dcx, matches, &mut collected_options);
2858 let (disable_local_thinlto, codegen_units) = should_override_cgus_and_disable_thinlto(
2859 early_dcx,
2860 &output_types,
2861 matches,
2862 cg.codegen_units,
2863 );
2864
2865 let incremental = cg.incremental.as_ref().map(PathBuf::from);
2866
2867 if cg.profile_generate.enabled() && cg.profile_use.is_some() {
2868 early_dcx.early_fatal("options `-C profile-generate` and `-C profile-use` are exclusive");
2869 }
2870
2871 if cg.profile_sample_use.is_some()
2872 && (cg.profile_generate.enabled() || cg.profile_use.is_some())
2873 {
2874 early_dcx.early_fatal(
2875 "option `-C profile-sample-use` cannot be used with `-C profile-generate` or `-C profile-use`",
2876 );
2877 }
2878
2879 match cg.symbol_mangling_version {
2882 None | Some(SymbolManglingVersion::V0) => {}
2884
2885 Some(SymbolManglingVersion::Legacy) => {
2887 if !unstable_opts.unstable_options {
2888 early_dcx.early_fatal(
2889 "`-C symbol-mangling-version=legacy` requires `-Z unstable-options`",
2890 );
2891 }
2892 }
2893 Some(SymbolManglingVersion::Hashed) => {
2894 if !unstable_opts.unstable_options {
2895 early_dcx.early_fatal(
2896 "`-C symbol-mangling-version=hashed` requires `-Z unstable-options`",
2897 );
2898 }
2899 }
2900 }
2901
2902 if cg.instrument_coverage != InstrumentCoverage::No {
2903 if cg.profile_generate.enabled() || cg.profile_use.is_some() {
2904 early_dcx.early_fatal(
2905 "option `-C instrument-coverage` is not compatible with either `-C profile-use` \
2906 or `-C profile-generate`",
2907 );
2908 }
2909
2910 match cg.symbol_mangling_version {
2915 None => cg.symbol_mangling_version = Some(SymbolManglingVersion::V0),
2916 Some(SymbolManglingVersion::Legacy) => {
2917 early_dcx.early_warn(
2918 "-C instrument-coverage requires symbol mangling version `v0`, \
2919 but `-C symbol-mangling-version=legacy` was specified",
2920 );
2921 }
2922 Some(SymbolManglingVersion::V0) => {}
2923 Some(SymbolManglingVersion::Hashed) => {
2924 early_dcx.early_warn(
2925 "-C instrument-coverage requires symbol mangling version `v0`, \
2926 but `-C symbol-mangling-version=hashed` was specified",
2927 );
2928 }
2929 }
2930 }
2931
2932 if let Ok(graphviz_font) = std::env::var("RUSTC_GRAPHVIZ_FONT") {
2933 unstable_opts.graphviz_font = graphviz_font;
2936 }
2937
2938 if !cg.embed_bitcode {
2939 match cg.lto {
2940 LtoCli::No | LtoCli::Unspecified => {}
2941 LtoCli::Yes | LtoCli::NoParam | LtoCli::Thin | LtoCli::Fat => {
2942 early_dcx.early_fatal("options `-C embed-bitcode=no` and `-C lto` are incompatible")
2943 }
2944 }
2945 }
2946
2947 let unstable_options_enabled = nightly_options::unstable_options_enabled(matches);
2948 if !unstable_options_enabled && cg.force_frame_pointers == FramePointer::NonLeaf {
2949 early_dcx.early_fatal(
2950 "`-Cforce-frame-pointers=non-leaf` or `always` also requires `-Zunstable-options` \
2951 and a nightly compiler",
2952 )
2953 }
2954
2955 if !unstable_options_enabled && !unstable_opts.offload.is_empty() {
2956 early_dcx.early_fatal(
2957 "`-Zoffload=Enable` also requires `-Zunstable-options` and a nightly compiler",
2958 )
2959 }
2960
2961 let target_triple = parse_target_triple(early_dcx, matches);
2962
2963 if !unstable_options_enabled {
2966 if let Err(error) = cg.link_self_contained.check_unstable_variants(&target_triple) {
2967 early_dcx.early_fatal(error);
2968 }
2969
2970 if let Some(flavor) = cg.linker_flavor {
2971 if flavor.is_unstable() {
2972 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!(
2973 "the linker flavor `{}` is unstable, the `-Z unstable-options` flag must also \
2974 be passed to use the unstable values",
2975 flavor.desc()
2976 ));
2977 }
2978 }
2979 }
2980
2981 if let Some(erroneous_components) = cg.link_self_contained.check_consistency() {
2984 let names: String = erroneous_components
2985 .into_iter()
2986 .map(|c| c.as_str().unwrap())
2987 .intersperse(", ")
2988 .collect();
2989 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!(
2990 "some `-C link-self-contained` components were both enabled and disabled: {names}"
2991 ));
2992 }
2993
2994 let prints = print_request::collect_print_requests(
2995 early_dcx,
2996 &mut cg,
2997 &unstable_opts,
2998 matches,
2999 PrintCategory::ALL_VARIANTS,
3000 );
3001
3002 if unstable_opts.retpoline_external_thunk {
3004 unstable_opts.retpoline = true;
3005 collected_options.target_modifiers.insert(
3006 OptionsTargetModifiers::UnstableOptions(UnstableOptionsTargetModifiers::Retpoline),
3007 "true".to_string(),
3008 );
3009 }
3010
3011 let cg = cg;
3012
3013 let opt_level = parse_opt_level(early_dcx, matches, &cg);
3014 let debug_assertions = cg.debug_assertions.unwrap_or(opt_level == OptLevel::No);
3018 let debuginfo = select_debuginfo(matches, &cg);
3019
3020 if !unstable_options_enabled {
3021 if let Err(error) = cg.linker_features.check_unstable_variants(&target_triple) {
3022 early_dcx.early_fatal(error);
3023 }
3024 }
3025
3026 if !unstable_options_enabled && cg.panic == Some(PanicStrategy::ImmediateAbort) {
3027 early_dcx.early_fatal(
3028 "`-Cpanic=immediate-abort` requires `-Zunstable-options` and a nightly compiler",
3029 )
3030 }
3031
3032 let libs = parse_native_libs(early_dcx, &unstable_opts, &unstable_features, matches);
3034
3035 let test = matches.opt_present("test");
3036
3037 if !cg.remark.is_empty() && debuginfo == DebugInfo::None {
3038 early_dcx.early_warn("-C remark requires \"-C debuginfo=n\" to show source locations");
3039 }
3040
3041 if cg.remark.is_empty() && unstable_opts.remark_dir.is_some() {
3042 early_dcx
3043 .early_warn("using -Z remark-dir without enabling remarks using e.g. -C remark=all");
3044 }
3045
3046 if cg.embed_metadata.is_some() && unstable_opts.embed_metadata.is_some() {
3047 early_dcx.early_fatal("can't use both -Z embed-metadata and -C embed-metadata");
3048 }
3049
3050 let externs = parse_externs(early_dcx, matches, &unstable_opts);
3051
3052 let remap_path_prefix = parse_remap_path_prefix(early_dcx, matches);
3053 let remap_path_scope = parse_remap_path_scope(early_dcx, matches, &unstable_opts);
3054
3055 let pretty = parse_pretty(early_dcx, &unstable_opts);
3056
3057 if unstable_opts.dump_dep_graph && !unstable_opts.query_dep_graph {
3059 early_dcx.early_fatal("can't dump dependency graph without `-Z query-dep-graph`");
3060 }
3061
3062 let sysroot = Sysroot::new(matches.opt_str("sysroot").map(PathBuf::from));
3063
3064 let real_source_base_dir = |suffix: &str, confirm: &str| {
3065 let mut candidate = sysroot.path().join(suffix);
3066 if let Ok(metadata) = candidate.symlink_metadata() {
3067 if metadata.file_type().is_symlink() {
3071 if let Ok(symlink_dest) = std::fs::read_link(&candidate) {
3072 candidate = symlink_dest;
3073 }
3074 }
3075 }
3076
3077 candidate.join(confirm).is_file().then_some(candidate)
3079 };
3080
3081 let real_rust_source_base_dir =
3082 real_source_base_dir("lib/rustlib/src/rust", "library/std/src/lib.rs");
3084
3085 let real_rustc_dev_source_base_dir =
3086 real_source_base_dir("lib/rustlib/rustc-src/rust", "compiler/rustc/src/main.rs");
3088
3089 let search_paths: Vec<SearchPath> = {
3094 let mut seen_search_paths = FxHashSet::default();
3095 let search_path_matches: Vec<String> = matches.opt_strs("L");
3096 search_path_matches
3097 .iter()
3098 .filter(|p| seen_search_paths.insert(*p))
3099 .map(|path| {
3100 SearchPath::from_cli_opt(
3101 sysroot.path(),
3102 &target_triple,
3103 early_dcx,
3104 &path,
3105 unstable_opts.unstable_options,
3106 )
3107 })
3108 .collect()
3109 };
3110
3111 let working_dir = {
3114 let working_dir = std::env::current_dir().unwrap_or_else(|e| {
3115 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}"));
3116 });
3117
3118 let file_mapping = file_path_mapping(
3119 remap_path_prefix.clone(),
3120 unstable_opts.remap_cwd_prefix.as_deref(),
3121 remap_path_scope,
3122 );
3123 file_mapping.to_real_filename(&RealFileName::empty(), &working_dir)
3124 };
3125
3126 let verbose = matches.opt_present("verbose") || unstable_opts.verbose_internals;
3127
3128 let jobs = parse_jobs_all(
3129 early_dcx,
3130 matches,
3131 unstable_opts.threads.as_deref(),
3132 unstable_opts.no_parallel_backend,
3133 unstable_opts.unstable_options,
3134 );
3135
3136 Options {
3137 crate_types,
3138 optimize: opt_level,
3139 debuginfo,
3140 lint_opts,
3141 lint_cap,
3142 describe_lints,
3143 output_types,
3144 search_paths,
3145 sysroot,
3146 target_triple,
3147 test,
3148 incremental,
3149 unstable_opts,
3150 prints,
3151 cg,
3152 error_format,
3153 diagnostic_width,
3154 externs,
3155 unstable_features,
3156 crate_name,
3157 libs,
3158 debug_assertions,
3159 actually_rustdoc: false,
3160 resolve_doc_links: ResolveDocLinks::ExportedMetadata,
3161 trimmed_def_paths: false,
3162 cli_forced_codegen_units: codegen_units,
3163 cli_forced_local_thinlto_off: disable_local_thinlto,
3164 remap_path_prefix,
3165 remap_path_scope,
3166 real_rust_source_base_dir,
3167 real_rustc_dev_source_base_dir,
3168 edition,
3169 json_artifact_notifications,
3170 json_timings,
3171 json_unused_externs,
3172 json_future_incompat,
3173 pretty,
3174 working_dir,
3175 color,
3176 verbose,
3177 target_modifiers: collected_options.target_modifiers,
3178 mitigation_coverage_map: collected_options.mitigations,
3179 jobs,
3180 recommended_stack_size: DEFAULT_STACK_SIZE,
3181 }
3182}
3183
3184fn parse_pretty(early_dcx: &EarlyDiagCtxt, unstable_opts: &UnstableOptions) -> Option<PpMode> {
3185 use PpMode::*;
3186
3187 let first = match unstable_opts.unpretty.as_deref()? {
3188 "normal" => Source(PpSourceMode::Normal),
3189 "expanded" => Source(PpSourceMode::Expanded),
3190 "expanded,identified" => Source(PpSourceMode::ExpandedIdentified),
3191 "expanded,hygiene" => Source(PpSourceMode::ExpandedHygiene),
3192 "ast-tree" => AstTree,
3193 "ast-tree,expanded" => AstTreeExpanded,
3194 "hir" => Hir(PpHirMode::Normal),
3195 "hir,identified" => Hir(PpHirMode::Identified),
3196 "hir,typed" => Hir(PpHirMode::Typed),
3197 "hir-tree" => HirTree,
3198 "thir-tree" => ThirTree,
3199 "thir-flat" => ThirFlat,
3200 "mir" => Mir,
3201 "stable-mir" => StableMir,
3202 "mir-cfg" => MirCFG,
3203 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!(
3204 "argument to `unpretty` must be one of `normal`, \
3205 `expanded`, `expanded,identified`, `expanded,hygiene`, \
3206 `ast-tree`, `ast-tree,expanded`, `hir`, `hir,identified`, \
3207 `hir,typed`, `hir-tree`, `thir-tree`, `thir-flat`, `mir`, `stable-mir`, or \
3208 `mir-cfg`; got {name}"
3209 )),
3210 };
3211 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/f5cedb83a788ea9581097abc36a2a8503a7f541c/compiler/rustc_session/src/config.rs:3211",
"rustc_session::config", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/f5cedb83a788ea9581097abc36a2a8503a7f541c/compiler/rustc_session/src/config.rs"),
::tracing_core::__macro_support::Option::Some(3211u32),
::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:?}");
3212 Some(first)
3213}
3214
3215pub fn make_crate_type_option() -> RustcOptGroup {
3216 make_opt(
3217 OptionStability::Stable,
3218 OptionKind::Multi,
3219 "",
3220 "crate-type",
3221 "Comma separated list of types of crates
3222 for the compiler to emit",
3223 "<bin|lib|rlib|dylib|cdylib|staticlib|proc-macro>",
3224 )
3225}
3226
3227pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateType>, String> {
3228 let mut crate_types: Vec<CrateType> = Vec::new();
3229 for unparsed_crate_type in &list_list {
3230 for part in unparsed_crate_type.split(',') {
3231 let new_part = match part {
3232 "lib" => CrateType::default(),
3233 "rlib" => CrateType::Rlib,
3234 "staticlib" => CrateType::StaticLib,
3235 "dylib" => CrateType::Dylib,
3236 "cdylib" => CrateType::Cdylib,
3237 "bin" => CrateType::Executable,
3238 "proc-macro" => CrateType::ProcMacro,
3239 "sdylib" => CrateType::Sdylib,
3240 _ => {
3241 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!(
3242 "unknown crate type: `{part}`, expected one of: \
3243 `lib`, `rlib`, `staticlib`, `dylib`, `cdylib`, `bin`, `proc-macro`",
3244 ));
3245 }
3246 };
3247 if !crate_types.contains(&new_part) {
3248 crate_types.push(new_part)
3249 }
3250 }
3251 }
3252
3253 Ok(crate_types)
3254}
3255
3256pub mod nightly_options {
3257 use rustc_feature::UnstableFeatures;
3258
3259 use super::{OptionStability, RustcOptGroup};
3260 use crate::EarlyDiagCtxt;
3261
3262 pub fn unstable_options_enabled(matches: &getopts::Matches) -> bool {
3264 let unstable_features =
3265 UnstableFeatures::from_environment(matches.opt_str("crate-name").as_deref());
3266 unstable_features.allow_unstable_compiler_flag("unstable-options")
3267 && matches.opt_strs("Z").iter().any(|x| *x == "unstable-options")
3268 }
3269
3270 pub fn match_is_nightly_build(matches: &getopts::Matches) -> bool {
3271 let krate = matches.opt_str("crate-name");
3272 UnstableFeatures::from_environment(krate.as_deref()).is_nightly_build()
3273 }
3274
3275 pub fn check_nightly_options(
3276 early_dcx: &EarlyDiagCtxt,
3277 matches: &getopts::Matches,
3278 flags: &[RustcOptGroup],
3279 ) {
3280 let has_z_unstable_option = matches.opt_strs("Z").iter().any(|x| *x == "unstable-options");
3281 let unstable_features =
3282 UnstableFeatures::from_environment(matches.opt_str("crate-name").as_deref());
3283 let mut nightly_options_on_stable = 0;
3284
3285 for opt in flags.iter() {
3286 if opt.stability == OptionStability::Stable {
3287 continue;
3288 }
3289 if !matches.opt_present(opt.name) {
3290 continue;
3291 }
3292 if opt.name != "Z" && !has_z_unstable_option {
3293 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!(
3294 "the `-Z unstable-options` flag must also be passed to enable \
3295 the flag `{}`",
3296 opt.name
3297 ));
3298 }
3299
3300 if opt.name == "Z" {
3304 let values = matches.opt_strs(opt.name);
3308 let disallowed_flags = values
3309 .iter()
3310 .map(|flag| flag.split_once("=").map(|(k, _)| k).unwrap_or(flag))
3311 .filter(|flag| !unstable_features.allow_unstable_compiler_flag(flag))
3312 .collect::<Vec<_>>();
3313 if disallowed_flags.is_empty() {
3314 continue;
3315 }
3316
3317 if #[allow(non_exhaustive_omitted_patterns)] match unstable_features {
UnstableFeatures::AllowSelectedUnstableCompilerFlagsOnly { .. } => true,
_ => false,
}matches!(
3323 unstable_features,
3324 UnstableFeatures::AllowSelectedUnstableCompilerFlagsOnly { .. }
3325 ) {
3326 for flag in disallowed_flags {
3327 let _ = early_dcx.early_err(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("the -Z{0} option was not allowed through `-allow-unstable-compiler-flags`",
flag))
})format!("the -Z{flag} option was not allowed through `-allow-unstable-compiler-flags`"));
3328 }
3329 }
3330 } else if unstable_features.allow_unstable_compiler_flag(opt.name) {
3331 continue;
3332 }
3333
3334 nightly_options_on_stable += 1;
3335 let msg = ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("the option `{0}` is only accepted on the nightly compiler",
opt.name))
})format!("the option `{}` is only accepted on the nightly compiler", opt.name);
3336 let _ = early_dcx.early_err(msg);
3338 }
3339
3340 if nightly_options_on_stable > 0 {
3341 let (s, were) = if nightly_options_on_stable > 1 { ("s", "were") } else { ("", "was") };
3342 let mut err = early_dcx.early_struct_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} nightly option{1} {2} parsed",
nightly_options_on_stable, s, were))
})format!(
3343 "{nightly_options_on_stable} nightly option{s} {were} parsed",
3344 ));
3345 err.help("consider switching to a nightly toolchain: `rustup default nightly`");
3346 err.note(
3347 "selecting a toolchain with `+toolchain` arguments require a rustup proxy; \
3348 see <https://rust-lang.github.io/rustup/concepts/index.html>",
3349 );
3350 err.note(
3351 "for more information about Rust's stability policy, see \
3352 <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html#unstable-features>",
3353 );
3354 err.emit();
3355 }
3356 }
3357}
3358
3359#[derive(#[automatically_derived]impl ::core::marker::Copy for PpSourceMode { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for PpSourceMode {
}
#[automatically_derived]impl ::core::clone::Clone for PpSourceMode {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
PpSourceMode {
}
#[automatically_derived]impl ::core::cmp::PartialEq for PpSourceMode {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}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)]
3360pub enum PpSourceMode {
3361 Normal,
3363 Expanded,
3365 ExpandedIdentified,
3367 ExpandedHygiene,
3369}
3370
3371#[derive(#[automatically_derived]impl ::core::marker::Copy for PpHirMode { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for PpHirMode {
}
#[automatically_derived]impl ::core::clone::Clone for PpHirMode {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for PpHirMode
{
}
#[automatically_derived]impl ::core::cmp::PartialEq for PpHirMode {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}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)]
3372pub enum PpHirMode {
3373 Normal,
3375 Identified,
3377 Typed,
3379}
3380
3381#[derive(#[automatically_derived]impl ::core::marker::Copy for PpMode { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for PpMode {
}
#[automatically_derived]impl ::core::clone::Clone for PpMode {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<PpSourceMode>;
let _: ::core::clone::AssertParamIsClone<PpHirMode>;
*self
}
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for PpMode {
}
#[automatically_derived]impl ::core::cmp::PartialEq for PpMode {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::Source(__self_0), Self::Source(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::Hir(__self_0), Self::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 {
Self::Source(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Source", &__self_0),
Self::AstTree => ::core::fmt::Formatter::write_str(f, "AstTree"),
Self::AstTreeExpanded =>
::core::fmt::Formatter::write_str(f, "AstTreeExpanded"),
Self::Hir(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f, "Hir",
&__self_0),
Self::HirTree => ::core::fmt::Formatter::write_str(f, "HirTree"),
Self::ThirTree =>
::core::fmt::Formatter::write_str(f, "ThirTree"),
Self::ThirFlat =>
::core::fmt::Formatter::write_str(f, "ThirFlat"),
Self::Mir => ::core::fmt::Formatter::write_str(f, "Mir"),
Self::MirCFG => ::core::fmt::Formatter::write_str(f, "MirCFG"),
Self::StableMir =>
::core::fmt::Formatter::write_str(f, "StableMir"),
}
}
}Debug)]
3382pub enum PpMode {
3384 Source(PpSourceMode),
3387 AstTree,
3389 AstTreeExpanded,
3391 Hir(PpHirMode),
3393 HirTree,
3395 ThirTree,
3397 ThirFlat,
3399 Mir,
3401 MirCFG,
3403 StableMir,
3405}
3406
3407impl PpMode {
3408 pub fn needs_ast_map(&self) -> bool {
3409 use PpMode::*;
3410 use PpSourceMode::*;
3411 match *self {
3412 Source(Normal) | AstTree => false,
3413
3414 Source(Expanded | ExpandedIdentified | ExpandedHygiene)
3415 | AstTreeExpanded
3416 | Hir(_)
3417 | HirTree
3418 | ThirTree
3419 | ThirFlat
3420 | Mir
3421 | MirCFG
3422 | StableMir => true,
3423 }
3424 }
3425
3426 pub fn needs_analysis(&self) -> bool {
3427 use PpMode::*;
3428 #[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)
3429 }
3430}
3431
3432#[derive(#[automatically_derived]impl ::core::clone::Clone for WasiExecModel {
#[inline]
fn clone(&self) -> Self {
match self {
Self::Command => WasiExecModel::Command,
Self::Reactor => WasiExecModel::Reactor,
}
}
}Clone, #[automatically_derived]impl ::core::hash::Hash for WasiExecModel {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state)
}
}Hash, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
WasiExecModel {
}
#[automatically_derived]impl ::core::cmp::PartialEq for WasiExecModel {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for WasiExecModel { }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)]
3433pub enum WasiExecModel {
3434 Command,
3435 Reactor,
3436}
3437
3438pub(crate) mod dep_tracking {
3457 use std::collections::BTreeMap;
3458 use std::hash::Hash;
3459 use std::num::NonZero;
3460 use std::path::PathBuf;
3461
3462 use rustc_abi::Align;
3463 use rustc_ast::attr::version::RustcVersion;
3464 use rustc_data_structures::fx::FxIndexMap;
3465 use rustc_data_structures::stable_hash::{DummyStableHashCtxt, StableHash, StableHasher};
3466 use rustc_errors::LanguageIdentifier;
3467 use rustc_feature::UnstableFeatures;
3468 use rustc_hashes::Hash64;
3469 use rustc_span::edition::Edition;
3470 use rustc_span::{RealFileName, RemapPathScopeComponents};
3471 use rustc_structures::CollapseMacroDebuginfo;
3472 use rustc_target::spec::{
3473 CodeModel, FramePointer, MergeFunctions, OnBrokenPipe, PanicStrategy, RelocModel,
3474 RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, SymbolVisibility, TargetTuple,
3475 TlsModel,
3476 };
3477
3478 use super::{
3479 AnnotateMoves, AutoDiff, BranchProtection, CFGuard, CFProtection, CodegenRetagOptions,
3480 CoverageOptions, CrateType, DebugInfo, DebugInfoCompression, ErrorOutputType, FmtDebug,
3481 FunctionReturn, InliningThreshold, InstrumentCoverage, InstrumentMcount,
3482 InstrumentMcountOpts, InstrumentXRay, LinkerPluginLto, LocationDetail, LtoCli,
3483 MirStripDebugInfo, NextSolverConfig, Offload, OptLevel, OutFileName, OutputType,
3484 OutputTypes, PatchableFunctionEntry, PointerAuthOption, Polonius, ResolveDocLinks,
3485 SourceFileHashAlgorithm, SplitDwarfKind, SwitchWithOptPath, SymbolManglingVersion,
3486 WasiExecModel,
3487 };
3488 use crate::lint;
3489 use crate::utils::NativeLib;
3490
3491 pub(crate) trait DepTrackingHash {
3492 fn hash(
3493 &self,
3494 hasher: &mut StableHasher,
3495 error_format: ErrorOutputType,
3496 for_crate_hash: bool,
3497 );
3498 }
3499
3500 macro_rules! impl_dep_tracking_hash_via_hash {
3501 ($($t:ty),+ $(,)?) => {$(
3502 impl DepTrackingHash for $t {
3503 fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType, _for_crate_hash: bool) {
3504 Hash::hash(self, hasher);
3505 }
3506 }
3507 )+};
3508 }
3509
3510 impl<T: DepTrackingHash> DepTrackingHash for Option<T> {
3511 fn hash(
3512 &self,
3513 hasher: &mut StableHasher,
3514 error_format: ErrorOutputType,
3515 for_crate_hash: bool,
3516 ) {
3517 match self {
3518 Some(x) => {
3519 Hash::hash(&1, hasher);
3520 DepTrackingHash::hash(x, hasher, error_format, for_crate_hash);
3521 }
3522 None => Hash::hash(&0, hasher),
3523 }
3524 }
3525 }
3526
3527 impl DepTrackingHash for () {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for Align {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for AnnotateMoves {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for AutoDiff {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for BranchProtection {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for CFGuard {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for CFProtection {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for CodeModel {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for CodegenRetagOptions {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for CollapseMacroDebuginfo {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for CoverageOptions {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for CrateType {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for DebugInfo {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for DebugInfoCompression {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for Edition {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for FmtDebug {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for FramePointer {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for FunctionReturn {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for Hash64 {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for InliningThreshold {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for InstrumentCoverage {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for InstrumentMcount {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for InstrumentMcountOpts {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for InstrumentXRay {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for LanguageIdentifier {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for LinkerPluginLto {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for LocationDetail {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for LtoCli {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for MergeFunctions {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for MirStripDebugInfo {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for NativeLib {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for NextSolverConfig {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for NonZero<usize> {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for Offload {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for OnBrokenPipe {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for OptLevel {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for OutFileName {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for OutputType {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for PanicStrategy {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for PatchableFunctionEntry {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for PointerAuthOption {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for Polonius {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for RelocModel {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for RelroLevel {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for RemapPathScopeComponents {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for ResolveDocLinks {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for RustcVersion {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for SanitizerSet {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for SourceFileHashAlgorithm {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for SplitDebuginfo {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for SplitDwarfKind {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for StackProtector {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for String {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for SwitchWithOptPath {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for SymbolManglingVersion {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for SymbolVisibility {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for TargetTuple {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for TlsModel {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for UnstableFeatures {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for WasiExecModel {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for bool {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for lint::Level {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for u32 {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for u64 {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}
impl DepTrackingHash for usize {
fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType,
_for_crate_hash: bool) {
Hash::hash(self, hasher);
}
}impl_dep_tracking_hash_via_hash!(
3528 (),
3530 Align,
3531 AnnotateMoves,
3532 AutoDiff,
3533 BranchProtection,
3534 CFGuard,
3535 CFProtection,
3536 CodeModel,
3537 CodegenRetagOptions,
3538 CollapseMacroDebuginfo,
3539 CoverageOptions,
3540 CrateType,
3541 DebugInfo,
3542 DebugInfoCompression,
3543 Edition,
3544 FmtDebug,
3545 FramePointer,
3546 FunctionReturn,
3547 Hash64,
3548 InliningThreshold,
3549 InstrumentCoverage,
3550 InstrumentMcount,
3551 InstrumentMcountOpts,
3552 InstrumentXRay,
3553 LanguageIdentifier,
3554 LinkerPluginLto,
3555 LocationDetail,
3556 LtoCli,
3557 MergeFunctions,
3558 MirStripDebugInfo,
3559 NativeLib,
3560 NextSolverConfig,
3561 NonZero<usize>,
3562 Offload,
3563 OnBrokenPipe,
3564 OptLevel,
3565 OutFileName,
3566 OutputType,
3567 PanicStrategy,
3568 PatchableFunctionEntry,
3569 PointerAuthOption,
3570 Polonius,
3571 RelocModel,
3572 RelroLevel,
3573 RemapPathScopeComponents,
3574 ResolveDocLinks,
3575 RustcVersion,
3576 SanitizerSet,
3577 SourceFileHashAlgorithm,
3578 SplitDebuginfo,
3579 SplitDwarfKind,
3580 StackProtector,
3581 String,
3582 SwitchWithOptPath,
3583 SymbolManglingVersion,
3584 SymbolVisibility,
3585 TargetTuple,
3586 TlsModel,
3587 UnstableFeatures,
3588 WasiExecModel,
3589 bool,
3590 lint::Level,
3591 u32,
3592 u64,
3593 usize,
3594 );
3596
3597 impl<T1, T2> DepTrackingHash for (T1, T2)
3598 where
3599 T1: DepTrackingHash,
3600 T2: DepTrackingHash,
3601 {
3602 fn hash(
3603 &self,
3604 hasher: &mut StableHasher,
3605 error_format: ErrorOutputType,
3606 for_crate_hash: bool,
3607 ) {
3608 Hash::hash(&0, hasher);
3609 DepTrackingHash::hash(&self.0, hasher, error_format, for_crate_hash);
3610 Hash::hash(&1, hasher);
3611 DepTrackingHash::hash(&self.1, hasher, error_format, for_crate_hash);
3612 }
3613 }
3614
3615 impl<T1, T2, T3> DepTrackingHash for (T1, T2, T3)
3616 where
3617 T1: DepTrackingHash,
3618 T2: DepTrackingHash,
3619 T3: DepTrackingHash,
3620 {
3621 fn hash(
3622 &self,
3623 hasher: &mut StableHasher,
3624 error_format: ErrorOutputType,
3625 for_crate_hash: bool,
3626 ) {
3627 Hash::hash(&0, hasher);
3628 DepTrackingHash::hash(&self.0, hasher, error_format, for_crate_hash);
3629 Hash::hash(&1, hasher);
3630 DepTrackingHash::hash(&self.1, hasher, error_format, for_crate_hash);
3631 Hash::hash(&2, hasher);
3632 DepTrackingHash::hash(&self.2, hasher, error_format, for_crate_hash);
3633 }
3634 }
3635
3636 impl<T: DepTrackingHash> DepTrackingHash for Vec<T> {
3637 fn hash(
3638 &self,
3639 hasher: &mut StableHasher,
3640 error_format: ErrorOutputType,
3641 for_crate_hash: bool,
3642 ) {
3643 Hash::hash(&self.len(), hasher);
3644 for (index, elem) in self.iter().enumerate() {
3645 Hash::hash(&index, hasher);
3646 DepTrackingHash::hash(elem, hasher, error_format, for_crate_hash);
3647 }
3648 }
3649 }
3650
3651 impl<T: DepTrackingHash, V: DepTrackingHash> DepTrackingHash for FxIndexMap<T, V> {
3652 fn hash(
3653 &self,
3654 hasher: &mut StableHasher,
3655 error_format: ErrorOutputType,
3656 for_crate_hash: bool,
3657 ) {
3658 Hash::hash(&self.len(), hasher);
3659 for (key, value) in self.iter() {
3660 DepTrackingHash::hash(key, hasher, error_format, for_crate_hash);
3661 DepTrackingHash::hash(value, hasher, error_format, for_crate_hash);
3662 }
3663 }
3664 }
3665
3666 impl DepTrackingHash for OutputTypes {
3667 fn hash(
3668 &self,
3669 hasher: &mut StableHasher,
3670 error_format: ErrorOutputType,
3671 for_crate_hash: bool,
3672 ) {
3673 Hash::hash(&self.0.len(), hasher);
3674 for (key, val) in &self.0 {
3675 DepTrackingHash::hash(key, hasher, error_format, for_crate_hash);
3676 if !for_crate_hash {
3677 DepTrackingHash::hash(val, hasher, error_format, for_crate_hash);
3678 }
3679 }
3680 }
3681 }
3682
3683 impl DepTrackingHash for PathBuf {
3684 fn hash(
3685 &self,
3686 hasher: &mut StableHasher,
3687 _error_format: ErrorOutputType,
3688 _for_crate_hash: bool,
3689 ) {
3690 self.stable_hash(&mut DummyStableHashCtxt, hasher);
3691 }
3692 }
3693
3694 impl DepTrackingHash for RealFileName {
3695 fn hash(
3696 &self,
3697 hasher: &mut StableHasher,
3698 _error_format: ErrorOutputType,
3699 _for_crate_hash: bool,
3700 ) {
3701 self.stable_hash(&mut DummyStableHashCtxt, hasher);
3702 }
3703 }
3704
3705 pub(crate) fn stable_hash(
3707 sub_hashes: BTreeMap<&'static str, &dyn DepTrackingHash>,
3708 hasher: &mut StableHasher,
3709 error_format: ErrorOutputType,
3710 for_crate_hash: bool,
3711 ) {
3712 for (key, sub_hash) in sub_hashes {
3713 Hash::hash(&key.len(), hasher);
3716 Hash::hash(key, hasher);
3717 sub_hash.hash(hasher, error_format, for_crate_hash);
3718 }
3719 }
3720}
3721
3722#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for ProcMacroExecutionStrategy {
}
#[automatically_derived]impl ::core::clone::Clone for
ProcMacroExecutionStrategy {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for
ProcMacroExecutionStrategy {
}Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
ProcMacroExecutionStrategy {
}
#[automatically_derived]impl ::core::cmp::PartialEq for
ProcMacroExecutionStrategy {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::hash::Hash for ProcMacroExecutionStrategy
{
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
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)]
3724pub enum ProcMacroExecutionStrategy {
3725 SameThread,
3727
3728 CrossThread,
3730}
3731
3732#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for DumpMonoStatsFormat {
}
#[automatically_derived]impl ::core::clone::Clone for DumpMonoStatsFormat {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for DumpMonoStatsFormat { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
DumpMonoStatsFormat {
}
#[automatically_derived]impl ::core::cmp::PartialEq for DumpMonoStatsFormat {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::hash::Hash for DumpMonoStatsFormat {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
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)]
3734pub enum DumpMonoStatsFormat {
3735 Markdown,
3737 Json,
3739}
3740
3741impl DumpMonoStatsFormat {
3742 pub fn extension(self) -> &'static str {
3743 match self {
3744 Self::Markdown => "md",
3745 Self::Json => "json",
3746 }
3747 }
3748}
3749
3750#[derive(#[automatically_derived]impl ::core::clone::Clone for PatchableFunctionEntry {
#[inline]
fn clone(&self) -> Self {
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::marker::StructuralPartialEq for
PatchableFunctionEntry {
}
#[automatically_derived]impl ::core::cmp::PartialEq for PatchableFunctionEntry
{
#[inline]
fn eq(&self, other: &Self) -> 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 entry section", &self.prefix,
&self.entry, &&self.section)
}
}Debug, #[automatically_derived]impl ::core::default::Default for
PatchableFunctionEntry {
#[inline]
fn default() -> Self {
PatchableFunctionEntry {
prefix: ::core::default::Default::default(),
entry: ::core::default::Default::default(),
section: ::core::default::Default::default(),
}
}
}Default)]
3753pub struct PatchableFunctionEntry {
3754 prefix: u8,
3756 entry: u8,
3758 section: Option<String>,
3760}
3761
3762impl PatchableFunctionEntry {
3763 pub fn from_parts(
3764 total_nops: u8,
3765 prefix_nops: u8,
3766 section: Option<String>,
3767 ) -> Option<PatchableFunctionEntry> {
3768 if total_nops < prefix_nops {
3769 None
3770 } else if section.as_ref().map(|x| x.contains('\0') || x.is_empty()).unwrap_or(false) {
3772 None
3773 } else {
3774 Some(Self { prefix: prefix_nops, entry: total_nops - prefix_nops, section })
3775 }
3776 }
3777 pub fn prefix(&self) -> u8 {
3778 self.prefix
3779 }
3780 pub fn entry(&self) -> u8 {
3781 self.entry
3782 }
3783 pub fn section(&self) -> Option<&str> {
3784 self.section.as_ref().map(|x| x.as_str())
3785 }
3786}
3787
3788#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for Polonius {
}
#[automatically_derived]impl ::core::clone::Clone for Polonius {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for Polonius { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for Polonius
{
}
#[automatically_derived]impl ::core::cmp::PartialEq for Polonius {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::hash::Hash for Polonius {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
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)]
3791pub enum Polonius {
3792 Off,
3794
3795 Legacy,
3797
3798 Next,
3800}
3801
3802impl Default for Polonius {
3803 fn default() -> Self {
3804 Self::DEFAULT
3805 }
3806}
3807
3808impl Polonius {
3809 pub(crate) const DEFAULT: Self =
3810 if ::core::option::Option::Some("1")option_env!("CFG_DEFAULT_POLONIUS_NEXT").is_some() { Self::Next } else { Self::Off };
3811
3812 pub fn is_legacy_enabled(&self) -> bool {
3814 #[allow(non_exhaustive_omitted_patterns)] match self {
Polonius::Legacy => true,
_ => false,
}matches!(self, Polonius::Legacy)
3815 }
3816
3817 pub fn is_next_enabled(&self) -> bool {
3819 #[allow(non_exhaustive_omitted_patterns)] match self {
Polonius::Next => true,
_ => false,
}matches!(self, Polonius::Next)
3820 }
3821}
3822
3823#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for InliningThreshold {
}
#[automatically_derived]impl ::core::clone::Clone for InliningThreshold {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<usize>;
*self
}
}Clone, #[automatically_derived]impl ::core::marker::Copy for InliningThreshold { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
InliningThreshold {
}
#[automatically_derived]impl ::core::cmp::PartialEq for InliningThreshold {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::Sometimes(__self_0), Self::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) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state);
match self {
Self::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 {
Self::Always => ::core::fmt::Formatter::write_str(f, "Always"),
Self::Sometimes(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Sometimes", &__self_0),
Self::Never => ::core::fmt::Formatter::write_str(f, "Never"),
}
}
}Debug)]
3824pub enum InliningThreshold {
3825 Always,
3826 Sometimes(usize),
3827 Never,
3828}
3829
3830impl Default for InliningThreshold {
3831 fn default() -> Self {
3832 Self::Sometimes(100)
3833 }
3834}
3835
3836#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for FunctionReturn {
}
#[automatically_derived]impl ::core::clone::Clone for FunctionReturn {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for FunctionReturn { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
FunctionReturn {
}
#[automatically_derived]impl ::core::cmp::PartialEq for FunctionReturn {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::hash::Hash for FunctionReturn {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
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() -> Self { Self::Keep }
}Default)]
3838pub enum FunctionReturn {
3839 #[default]
3841 Keep,
3842
3843 ThunkExtern,
3845}
3846
3847#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for MirIncludeSpans {
}
#[automatically_derived]impl ::core::clone::Clone for MirIncludeSpans {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for MirIncludeSpans { }Copy, #[automatically_derived]impl ::core::default::Default for MirIncludeSpans {
#[inline]
fn default() -> Self { Self::Nll }
}Default, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
MirIncludeSpans {
}
#[automatically_derived]impl ::core::cmp::PartialEq for MirIncludeSpans {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}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)]
3850pub enum MirIncludeSpans {
3851 Off,
3852 On,
3853 #[default]
3856 Nll,
3857}
3858
3859impl MirIncludeSpans {
3860 pub fn is_enabled(self) -> bool {
3865 self == MirIncludeSpans::On
3866 }
3867}