1use std::collections::btree_map::Iter as BTreeMapIter;
5use std::collections::{BTreeMap, BTreeSet};
6use std::ffi::OsStr;
7use std::hash::Hash;
8use std::num::NonZero;
9use std::path::{Path, PathBuf};
10use std::str::{self, FromStr};
11use std::sync::LazyLock;
12use std::{cmp, fs, iter, thread};
13
14use externs::{ExternOpt, split_extern_opt};
15use rustc_data_structures::fx::FxHashSet;
16use rustc_data_structures::stable_hash::StableHasher;
17use rustc_errors::emitter::HumanReadableErrorType;
18use rustc_errors::{ColorConfig, DiagCtxtFlags};
19use rustc_feature::UnstableFeatures;
20use rustc_hashes::Hash64;
21use rustc_macros::{BlobDecodable, Decodable, Encodable, StableHash};
22use rustc_span::edition::{
23 DEFAULT_EDITION, EDITION_NAME_LIST, EDITION_NAME_LIST_STABLE, Edition, LATEST_STABLE_EDITION,
24};
25use rustc_span::source_map::FilePathMapping;
26use rustc_span::{
27 FileName, RealFileName, RemapPathScopeComponents, SourceFileHashAlgorithm, Symbol, sym,
28};
29use rustc_structures::CrateType;
30use rustc_target::spec::{
31 FramePointer, LinkSelfContainedComponents, LinkerFeatures, PanicStrategy, SplitDebuginfo,
32 Target, TargetTuple,
33};
34use tracing::debug;
35
36pub use crate::config::cfg::{Cfg, CheckCfg, ExpectedValues};
37use crate::config::native_libs::parse_native_libs;
38pub use crate::config::print_request::{
39 PrintCategory, PrintKind, PrintRequest, collect_print_requests,
40};
41use crate::diagnostics::FileWriteFail;
42use crate::macros::AllVariants;
43pub use crate::options::*;
44use crate::output::{ErrorOutputType, OutputType, OutputTypes, ResolveDocLinks};
45use crate::search_paths::SearchPath;
46use crate::utils::CanonicalizedPath;
47use crate::{EarlyDiagCtxt, Session, filesearch, lint};
48
49mod cfg;
50mod externs;
51mod native_libs;
52mod print_request;
53pub mod sigpipe;
54
55pub const DEFAULT_STACK_SIZE: usize = 17 * 1024 * 1024;
57
58pub const NATIVE_CPU: &str = "native";
60
61#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for Strip {
}
#[automatically_derived]impl ::core::clone::Clone for Strip {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
63pub enum Strip {
64 None,
66
67 Debuginfo,
69
70 Symbols,
72}
73
74#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for CFGuard {
}
#[automatically_derived]impl ::core::clone::Clone for CFGuard {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
76pub enum CFGuard {
77 Disabled,
79
80 NoChecks,
82
83 Checks,
85}
86
87#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for CFProtection {
}
#[automatically_derived]impl ::core::clone::Clone for CFProtection {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
89pub enum CFProtection {
90 None,
92
93 Branch,
95
96 Return,
98
99 Full,
101}
102
103#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for OptLevel {
}
#[automatically_derived]impl ::core::clone::Clone for OptLevel {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for OptLevel { }Copy, #[automatically_derived]impl ::core::fmt::Debug for OptLevel {
#[inline]
#[rustc_trivial_field_reads]
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)]
104pub enum OptLevel {
105 No,
107 Less,
109 More,
111 Aggressive,
113 Size,
115 SizeMin,
117}
118
119impl OptLevel {
120 pub fn mir_opt_level(&self) -> usize {
123 match self {
124 OptLevel::No => 1,
125 _ => 2,
126 }
127 }
128
129 pub fn objective(&self) -> OptimizationObjective {
131 match self {
132 OptLevel::No => OptimizationObjective::None,
133 OptLevel::Less => OptimizationObjective::Balanced,
134 OptLevel::More | OptLevel::Aggressive => OptimizationObjective::Speed,
135 OptLevel::Size | OptLevel::SizeMin => OptimizationObjective::Size,
136 }
137 }
138}
139
140#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for OptimizationObjective {
}
#[automatically_derived]impl ::core::clone::Clone for OptimizationObjective {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for OptimizationObjective {
}Copy, #[automatically_derived]impl ::core::fmt::Debug for OptimizationObjective {
#[inline]
#[rustc_trivial_field_reads]
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)]
146pub enum OptimizationObjective {
147 None,
149 Balanced,
151 Speed,
153 Size,
155}
156
157#[derive(#[automatically_derived]impl ::core::clone::Clone for Lto {
#[inline]
#[rustc_trivial_field_reads]
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)]
162pub enum Lto {
163 No,
165
166 Thin,
168
169 ThinLocal,
172
173 Fat,
175}
176
177#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for LtoCli {
}
#[automatically_derived]impl ::core::clone::Clone for LtoCli {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
179pub enum LtoCli {
180 No,
182 Yes,
184 NoParam,
186 Thin,
188 Fat,
190 Unspecified,
192}
193
194#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for InstrumentCoverage {
}
#[automatically_derived]impl ::core::clone::Clone for InstrumentCoverage {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
196pub enum InstrumentCoverage {
197 No,
199 Yes,
201}
202
203#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for CoverageOptions {
}
#[automatically_derived]impl ::core::clone::Clone for CoverageOptions {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
205pub struct CoverageOptions {
206 pub level: CoverageLevel,
207
208 pub discard_all_spans_in_codegen: bool,
214}
215
216#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for CoverageLevel {
}
#[automatically_derived]impl ::core::clone::Clone for CoverageLevel {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
218pub enum CoverageLevel {
219 #[default]
221 Block,
222 Branch,
224 Condition,
240}
241
242#[derive(#[automatically_derived]impl ::core::clone::Clone for Offload {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
244pub enum Offload {
245 Device(String),
252 Host(String),
254 Test,
256 HostMetadata(String),
259}
260
261#[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]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]impl ::core::fmt::Debug for CodegenRetagOptions {
#[inline]
#[rustc_trivial_field_reads]
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)]
263pub struct CodegenRetagOptions {
264 pub no_precise_im: bool,
266 pub no_precise_pin: bool,
268}
269
270#[derive(#[automatically_derived]impl ::core::clone::Clone for AutoDiff {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
272pub enum AutoDiff {
273 Enable,
275
276 PrintTA,
278 PrintTAFn(String),
280 PrintAA,
282 PrintPerf,
284 PrintSteps,
286 PrintModBefore,
288 PrintModAfter,
290 PrintModFinal,
292
293 PrintPasses,
295 NoPostopt,
297 LooseTypes,
300 Inline,
302 NoTT,
304}
305
306#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for AnnotateMoves {
}
#[automatically_derived]impl ::core::clone::Clone for AnnotateMoves {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
308pub enum AnnotateMoves {
309 Disabled,
311 Enabled(Option<u64>),
314}
315
316#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for InstrumentMcountOpts {
}
#[automatically_derived]impl ::core::clone::Clone for InstrumentMcountOpts {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
317pub struct InstrumentMcountOpts {
318 pub no_call: bool,
320 pub record: bool,
322}
323
324#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for InstrumentMcount {
}
#[automatically_derived]impl ::core::clone::Clone for InstrumentMcount {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
326pub enum InstrumentMcount {
327 Disabled,
329 Mcount(InstrumentMcountOpts),
331 Fentry(InstrumentMcountOpts),
333}
334
335#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for InstrumentXRay {
}
#[automatically_derived]impl ::core::clone::Clone for InstrumentXRay {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_fields_finish(f,
"InstrumentXRay always never ignore_loops instruction_threshold skip_entry skip_exit",
&[&self.always, &self.never, &self.ignore_loops,
&self.instruction_threshold, &self.skip_entry,
&&self.skip_exit])
}
}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)]
337pub struct InstrumentXRay {
338 pub always: bool,
340 pub never: bool,
342 pub ignore_loops: bool,
345 pub instruction_threshold: Option<usize>,
348 pub skip_entry: bool,
350 pub skip_exit: bool,
352}
353
354#[derive(#[automatically_derived]impl ::core::clone::Clone for LinkerPluginLto {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
355pub enum LinkerPluginLto {
356 LinkerPlugin(PathBuf),
357 LinkerPluginAuto,
358 Disabled,
359}
360
361impl LinkerPluginLto {
362 pub fn enabled(&self) -> bool {
363 match *self {
364 LinkerPluginLto::LinkerPlugin(_) | LinkerPluginLto::LinkerPluginAuto => true,
365 LinkerPluginLto::Disabled => false,
366 }
367 }
368}
369
370#[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]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
386pub struct LinkSelfContained {
387 pub explicitly_set: Option<bool>,
390
391 enabled_components: LinkSelfContainedComponents,
394
395 disabled_components: LinkSelfContainedComponents,
398}
399
400impl LinkSelfContained {
401 pub(crate) fn handle_cli_component(&mut self, component: &str) -> Option<()> {
404 if let Some(component_to_enable) = component.strip_prefix('+') {
409 self.explicitly_set = None;
410 self.enabled_components
411 .insert(LinkSelfContainedComponents::from_str(component_to_enable).ok()?);
412 Some(())
413 } else if let Some(component_to_disable) = component.strip_prefix('-') {
414 self.explicitly_set = None;
415 self.disabled_components
416 .insert(LinkSelfContainedComponents::from_str(component_to_disable).ok()?);
417 Some(())
418 } else {
419 None
420 }
421 }
422
423 pub(crate) fn set_all_explicitly(&mut self, enabled: bool) {
426 self.explicitly_set = Some(enabled);
427
428 if enabled {
429 self.enabled_components = LinkSelfContainedComponents::all();
430 self.disabled_components = LinkSelfContainedComponents::empty();
431 } else {
432 self.enabled_components = LinkSelfContainedComponents::empty();
433 self.disabled_components = LinkSelfContainedComponents::all();
434 }
435 }
436
437 pub fn on() -> Self {
439 let mut on = LinkSelfContained::default();
440 on.set_all_explicitly(true);
441 on
442 }
443
444 fn check_unstable_variants(&self, target_tuple: &TargetTuple) -> Result<(), String> {
448 if self.explicitly_set.is_some() {
449 return Ok(());
450 }
451
452 let has_minus_linker = self.disabled_components.is_linker_enabled();
454 if has_minus_linker && target_tuple.tuple() != "x86_64-unknown-linux-gnu" {
455 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!(
456 "`-C link-self-contained=-linker` is unstable on the `{target_tuple}` \
457 target. The `-Z unstable-options` flag must also be passed to use it on this target",
458 ));
459 }
460
461 let unstable_enabled = self.enabled_components;
463 let unstable_disabled = self.disabled_components - LinkSelfContainedComponents::LINKER;
464 if !unstable_enabled.union(unstable_disabled).is_empty() {
465 return Err(String::from(
466 "only `-C link-self-contained` values `y`/`yes`/`on`/`n`/`no`/`off`/`-linker` \
467 are stable, the `-Z unstable-options` flag must also be passed to use \
468 the unstable values",
469 ));
470 }
471
472 Ok(())
473 }
474
475 pub fn is_linker_enabled(&self) -> bool {
478 self.enabled_components.contains(LinkSelfContainedComponents::LINKER)
479 }
480
481 pub fn is_linker_disabled(&self) -> bool {
484 self.disabled_components.contains(LinkSelfContainedComponents::LINKER)
485 }
486
487 fn check_consistency(&self) -> Option<LinkSelfContainedComponents> {
490 if self.explicitly_set.is_some() {
491 None
492 } else {
493 let common = self.enabled_components.intersection(self.disabled_components);
494 if common.is_empty() { None } else { Some(common) }
495 }
496 }
497}
498
499#[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]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
508pub struct LinkerFeaturesCli {
509 pub enabled: LinkerFeatures,
511
512 pub disabled: LinkerFeatures,
514}
515
516impl LinkerFeaturesCli {
517 pub(crate) fn handle_cli_feature(&mut self, feature: &str) -> Option<()> {
520 match feature {
526 "+lld" => {
527 self.enabled.insert(LinkerFeatures::LLD);
528 self.disabled.remove(LinkerFeatures::LLD);
529 Some(())
530 }
531 "-lld" => {
532 self.disabled.insert(LinkerFeatures::LLD);
533 self.enabled.remove(LinkerFeatures::LLD);
534 Some(())
535 }
536 _ => None,
537 }
538 }
539
540 pub(crate) fn check_unstable_variants(&self, target_tuple: &TargetTuple) -> Result<(), String> {
545 let has_minus_lld = self.disabled.is_lld_enabled();
547 if has_minus_lld && target_tuple.tuple() != "x86_64-unknown-linux-gnu" {
548 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!(
549 "`-C linker-features=-lld` is unstable on the `{target_tuple}` \
550 target. The `-Z unstable-options` flag must also be passed to use it on this target",
551 ));
552 }
553
554 let unstable_enabled = self.enabled;
556 let unstable_disabled = self.disabled - LinkerFeatures::LLD;
557 if !unstable_enabled.union(unstable_disabled).is_empty() {
558 let unstable_features: Vec<_> = unstable_enabled
559 .iter()
560 .map(|f| ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("+{0}", f.as_str().unwrap()))
})format!("+{}", f.as_str().unwrap()))
561 .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())))
562 .collect();
563 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!(
564 "`-C linker-features={}` is unstable, and also requires the \
565 `-Z unstable-options` flag to be used",
566 unstable_features.join(","),
567 ));
568 }
569
570 Ok(())
571 }
572}
573
574#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for IncrementalStateAssertion {
}
#[automatically_derived]impl ::core::clone::Clone for
IncrementalStateAssertion {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
576pub enum IncrementalStateAssertion {
577 Loaded,
582 NotLoaded,
584}
585
586#[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]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
588pub struct LocationDetail {
589 pub file: bool,
590 pub line: bool,
591 pub column: bool,
592}
593
594impl LocationDetail {
595 pub(crate) fn all() -> Self {
596 Self { file: true, line: true, column: true }
597 }
598}
599
600#[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]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
602pub enum FmtDebug {
603 Full,
605 Shallow,
607 None,
609}
610
611impl FmtDebug {
612 pub(crate) fn all() -> [Symbol; 3] {
613 [sym::full, sym::none, sym::shallow]
614 }
615}
616
617#[derive(#[automatically_derived]impl ::core::clone::Clone for SwitchWithOptPath {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
618pub enum SwitchWithOptPath {
619 Enabled(Option<PathBuf>),
620 Disabled,
621}
622
623impl SwitchWithOptPath {
624 pub fn enabled(&self) -> bool {
625 match *self {
626 SwitchWithOptPath::Enabled(_) => true,
627 SwitchWithOptPath::Disabled => false,
628 }
629 }
630}
631
632#[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]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for SymbolManglingVersion {
#[inline]
#[rustc_trivial_field_reads]
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)]
633#[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)]
634pub enum SymbolManglingVersion {
635 Legacy,
636 V0,
637 Hashed,
638}
639
640#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for DebugInfo {
}
#[automatically_derived]impl ::core::clone::Clone for DebugInfo {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for DebugInfo { }Copy, #[automatically_derived]impl ::core::fmt::Debug for DebugInfo {
#[inline]
#[rustc_trivial_field_reads]
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)]
641pub enum DebugInfo {
642 None,
643 LineDirectivesOnly,
644 LineTablesOnly,
645 Limited,
646 Full,
647}
648
649#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for DebugInfoCompression {
}
#[automatically_derived]impl ::core::clone::Clone for DebugInfoCompression {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for DebugInfoCompression { }Copy, #[automatically_derived]impl ::core::fmt::Debug for DebugInfoCompression {
#[inline]
#[rustc_trivial_field_reads]
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)]
650pub enum DebugInfoCompression {
651 None,
652 Zlib,
653 Zstd,
654}
655
656#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for MirStripDebugInfo {
}
#[automatically_derived]impl ::core::clone::Clone for MirStripDebugInfo {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for MirStripDebugInfo { }Copy, #[automatically_derived]impl ::core::fmt::Debug for MirStripDebugInfo {
#[inline]
#[rustc_trivial_field_reads]
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)]
657pub enum MirStripDebugInfo {
658 None,
659 LocalsInTinyFunctions,
660 AllLocals,
661}
662
663#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for SplitDwarfKind {
}
#[automatically_derived]impl ::core::clone::Clone for SplitDwarfKind {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for SplitDwarfKind { }Copy, #[automatically_derived]impl ::core::fmt::Debug for SplitDwarfKind {
#[inline]
#[rustc_trivial_field_reads]
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)]
673pub enum SplitDwarfKind {
674 Single,
677 Split,
680}
681
682impl FromStr for SplitDwarfKind {
683 type Err = ();
684
685 fn from_str(s: &str) -> Result<Self, ()> {
686 Ok(match s {
687 "single" => SplitDwarfKind::Single,
688 "split" => SplitDwarfKind::Split,
689 _ => return Err(()),
690 })
691 }
692}
693
694#[derive(#[automatically_derived]impl ::core::clone::Clone for Externs {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self { Externs(::core::clone::Clone::clone(&self.0)) }
}Clone)]
698pub struct Externs(BTreeMap<String, ExternEntry>);
699
700#[derive(#[automatically_derived]impl ::core::clone::Clone for ExternEntry {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
701pub struct ExternEntry {
702 pub location: ExternLocation,
703 pub is_private_dep: bool,
709 pub add_prelude: bool,
714 pub nounused_dep: bool,
719 pub force: bool,
725}
726
727#[derive(#[automatically_derived]impl ::core::clone::Clone for ExternLocation {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
728pub enum ExternLocation {
729 FoundInLibrarySearchDirectories,
733 ExactPaths(BTreeSet<CanonicalizedPath>),
740}
741
742impl Externs {
743 pub fn new(data: BTreeMap<String, ExternEntry>) -> Externs {
745 Externs(data)
746 }
747
748 pub fn get(&self, key: &str) -> Option<&ExternEntry> {
749 self.0.get(key)
750 }
751
752 pub fn iter(&self) -> BTreeMapIter<'_, String, ExternEntry> {
753 self.0.iter()
754 }
755}
756
757impl ExternEntry {
758 fn new(location: ExternLocation) -> ExternEntry {
759 ExternEntry {
760 location,
761 is_private_dep: false,
762 add_prelude: false,
763 nounused_dep: false,
764 force: false,
765 }
766 }
767
768 pub fn files(&self) -> Option<impl Iterator<Item = &CanonicalizedPath>> {
769 match &self.location {
770 ExternLocation::ExactPaths(set) => Some(set.iter()),
771 _ => None,
772 }
773 }
774}
775
776#[derive(#[automatically_derived]impl ::core::fmt::Debug for NextSolverConfig {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
778pub enum NextSolverConfig {
779 Coherence,
780 Globally,
781}
782
783impl Default for NextSolverConfig {
786 fn default() -> Self {
787 if ::core::option::Option::Some("1")option_env!("CFG_DEFAULT_NEXT_SOLVER_GLOBALLY").is_some() {
788 Self::Globally
789 } else {
790 Self::Coherence
791 }
792 }
793}
794
795#[derive(#[automatically_derived]impl ::core::clone::Clone for Input {
#[inline]
#[rustc_trivial_field_reads]
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)]
796pub enum Input {
797 File(PathBuf),
799 DocTestStr {
801 file: PathBuf,
803 line: isize,
805 input: String,
807 },
808 Str {
810 name: FileName,
812 input: String,
814 },
815}
816
817impl Input {
818 pub fn filestem(&self) -> &str {
819 if let Input::File(ifile) = self {
820 if let Some(name) = ifile.file_stem().and_then(OsStr::to_str) {
823 return name;
824 }
825 }
826 "rust_out"
827 }
828
829 pub fn file_name(&self, session: &Session) -> FileName {
830 match *self {
831 Input::File(ref ifile) => FileName::Real(
832 session
833 .psess
834 .source_map()
835 .path_mapping()
836 .to_real_filename(session.psess.source_map().working_dir(), ifile.as_path()),
837 ),
838 Input::DocTestStr { ref file, line, .. } => FileName::DocTest(
839 session
840 .psess
841 .source_map()
842 .path_mapping()
843 .to_real_filename(session.psess.source_map().working_dir(), file.as_path()),
844 line,
845 ),
846 Input::Str { ref name, .. } => name.clone(),
847 }
848 }
849
850 pub fn opt_path(&self) -> Option<&Path> {
851 match self {
852 Input::File(file) => Some(file),
853 Input::DocTestStr { file, .. } => Some(file),
854 Input::Str { name, .. } => match name {
855 FileName::Real(real) => real.local_path(),
856 FileName::CfgSpec(_) => None,
857 FileName::Anon(_) => None,
858 FileName::MacroExpansion(_) => None,
859 FileName::ProcMacroSourceCode(_) => None,
860 FileName::CliCrateAttr(_) => None,
861 FileName::Custom(_) => None,
862 FileName::DocTest(path, _) => path.local_path(),
863 FileName::InlineAsm(_) => None,
864 },
865 }
866 }
867}
868
869#[derive(#[automatically_derived]impl ::core::clone::Clone for OutFileName {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
870pub enum OutFileName {
871 Real(PathBuf),
872 Stdout,
873}
874
875impl OutFileName {
876 pub fn parent(&self) -> Option<&Path> {
877 match *self {
878 OutFileName::Real(ref path) => path.parent(),
879 OutFileName::Stdout => None,
880 }
881 }
882
883 pub fn filestem(&self) -> Option<&OsStr> {
884 match *self {
885 OutFileName::Real(ref path) => path.file_stem(),
886 OutFileName::Stdout => Some(OsStr::new("stdout")),
887 }
888 }
889
890 pub fn is_stdout(&self) -> bool {
891 match *self {
892 OutFileName::Real(_) => false,
893 OutFileName::Stdout => true,
894 }
895 }
896
897 pub fn is_tty(&self) -> bool {
898 use std::io::IsTerminal;
899 match *self {
900 OutFileName::Real(_) => false,
901 OutFileName::Stdout => std::io::stdout().is_terminal(),
902 }
903 }
904
905 pub fn as_path(&self) -> &Path {
906 match *self {
907 OutFileName::Real(ref path) => path.as_ref(),
908 OutFileName::Stdout => Path::new("stdout"),
909 }
910 }
911
912 pub fn file_for_writing(
918 &self,
919 outputs: &OutputFilenames,
920 flavor: OutputType,
921 codegen_unit_name: &str,
922 ) -> PathBuf {
923 match *self {
924 OutFileName::Real(ref path) => path.clone(),
925 OutFileName::Stdout => outputs.temp_path_for_cgu(flavor, codegen_unit_name),
926 }
927 }
928
929 pub fn overwrite(&self, content: &str, sess: &Session) {
930 match self {
931 OutFileName::Stdout => { ::std::io::_print(format_args!("{0}", content)); }print!("{content}"),
932 OutFileName::Real(path) => {
933 if let Err(e) = fs::write(path, content) {
934 sess.dcx().emit_fatal(FileWriteFail { path, err: e.to_string() });
935 }
936 }
937 }
938 }
939}
940
941#[derive(#[automatically_derived]impl ::core::clone::Clone for OutputFilenames {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_fields_finish(f,
"OutputFilenames out_directory crate_stem filestem single_output_file temps_directory invocation_temp explicit_dwo_out_directory outputs",
&[&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])
}
}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)]
942pub struct OutputFilenames {
943 pub(crate) out_directory: PathBuf,
944 crate_stem: String,
946 filestem: String,
948 pub single_output_file: Option<OutFileName>,
949 temps_directory: Option<PathBuf>,
950
951 #[stable_hash(ignore)]
959 invocation_temp: Option<String>,
960
961 explicit_dwo_out_directory: Option<PathBuf>,
962 pub outputs: OutputTypes,
963}
964
965pub const RLINK_EXT: &str = "rlink";
966pub const RUST_CGU_EXT: &str = "rcgu";
967pub const DWARF_OBJECT_EXT: &str = "dwo";
968pub const MAX_FILENAME_LENGTH: usize = 143; fn maybe_strip_file_name(mut path: PathBuf) -> PathBuf {
974 if path.file_name().map_or(0, |name| name.len()) > MAX_FILENAME_LENGTH {
975 let filename = path.file_name().unwrap().to_string_lossy();
976 let hash_len = 64 / 4; let hyphen_len = 1; let allowed_suffix = MAX_FILENAME_LENGTH.saturating_sub(hash_len + hyphen_len);
981
982 let stripped_bytes = filename.len().saturating_sub(allowed_suffix);
984
985 let split_at = filename.ceil_char_boundary(stripped_bytes);
987
988 let mut hasher = StableHasher::new();
989 filename[..split_at].hash(&mut hasher);
990 let hash = hasher.finish::<Hash64>();
991
992 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..]));
993 }
994 path
995}
996impl OutputFilenames {
997 pub fn new(
998 out_directory: PathBuf,
999 out_crate_name: String,
1000 out_filestem: String,
1001 single_output_file: Option<OutFileName>,
1002 temps_directory: Option<PathBuf>,
1003 invocation_temp: Option<String>,
1004 explicit_dwo_out_directory: Option<PathBuf>,
1005 extra: String,
1006 outputs: OutputTypes,
1007 ) -> Self {
1008 OutputFilenames {
1009 out_directory,
1010 single_output_file,
1011 temps_directory,
1012 invocation_temp,
1013 explicit_dwo_out_directory,
1014 outputs,
1015 crate_stem: ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}{1}", out_crate_name, extra))
})format!("{out_crate_name}{extra}"),
1016 filestem: ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}{1}", out_filestem, extra))
})format!("{out_filestem}{extra}"),
1017 }
1018 }
1019
1020 pub fn path(&self, flavor: OutputType) -> OutFileName {
1021 self.outputs
1022 .get(&flavor)
1023 .and_then(|p| p.to_owned())
1024 .or_else(|| self.single_output_file.clone())
1025 .unwrap_or_else(|| OutFileName::Real(self.output_path(flavor)))
1026 }
1027
1028 pub fn interface_path(&self) -> PathBuf {
1029 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6c709eb428d472a3c3d93681c1ba37d44a1c27cf/compiler/rustc_session/src/config.rs:1029",
"rustc_session::config", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6c709eb428d472a3c3d93681c1ba37d44a1c27cf/compiler/rustc_session/src/config.rs"),
::tracing_core::__macro_support::Option::Some(1029u32),
::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);
1030 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))
1031 }
1032
1033 fn output_path(&self, flavor: OutputType) -> PathBuf {
1036 let extension = flavor.extension();
1037 match flavor {
1038 OutputType::Metadata => {
1039 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6c709eb428d472a3c3d93681c1ba37d44a1c27cf/compiler/rustc_session/src/config.rs:1039",
"rustc_session::config", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6c709eb428d472a3c3d93681c1ba37d44a1c27cf/compiler/rustc_session/src/config.rs"),
::tracing_core::__macro_support::Option::Some(1039u32),
::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);
1040 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))
1041 }
1042 _ => self.with_directory_and_extension(&self.out_directory, extension),
1043 }
1044 }
1045
1046 pub fn temp_path_for_cgu(&self, flavor: OutputType, codegen_unit_name: &str) -> PathBuf {
1050 let extension = flavor.extension();
1051 self.temp_path_ext_for_cgu(extension, codegen_unit_name)
1052 }
1053
1054 pub fn temp_path_dwo_for_cgu(&self, codegen_unit_name: &str) -> PathBuf {
1056 let p = self.temp_path_ext_for_cgu(DWARF_OBJECT_EXT, codegen_unit_name);
1057 if let Some(dwo_out) = &self.explicit_dwo_out_directory {
1058 let mut o = dwo_out.clone();
1059 o.push(p.file_name().unwrap());
1060 o
1061 } else {
1062 p
1063 }
1064 }
1065
1066 pub fn temp_path_ext_for_cgu(&self, ext: &str, codegen_unit_name: &str) -> PathBuf {
1069 let mut extension = codegen_unit_name.to_string();
1070
1071 if let Some(rng) = &self.invocation_temp {
1073 extension.push('.');
1074 extension.push_str(rng);
1075 }
1076
1077 if !ext.is_empty() {
1080 extension.push('.');
1081 extension.push_str(RUST_CGU_EXT);
1082 extension.push('.');
1083 extension.push_str(ext);
1084 }
1085
1086 let temps_directory = self.temps_directory.as_ref().unwrap_or(&self.out_directory);
1087 maybe_strip_file_name(self.with_directory_and_extension(temps_directory, &extension))
1088 }
1089
1090 pub fn temp_path_for_diagnostic(&self, ext: &str) -> PathBuf {
1091 let temps_directory = self.temps_directory.as_ref().unwrap_or(&self.out_directory);
1092 self.with_directory_and_extension(temps_directory, &ext)
1093 }
1094
1095 pub fn with_extension(&self, extension: &str) -> PathBuf {
1096 self.with_directory_and_extension(&self.out_directory, extension)
1097 }
1098
1099 pub fn with_directory_and_extension(&self, directory: &Path, extension: &str) -> PathBuf {
1100 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6c709eb428d472a3c3d93681c1ba37d44a1c27cf/compiler/rustc_session/src/config.rs:1100",
"rustc_session::config", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6c709eb428d472a3c3d93681c1ba37d44a1c27cf/compiler/rustc_session/src/config.rs"),
::tracing_core::__macro_support::Option::Some(1100u32),
::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);
1101 let mut path = directory.join(&self.filestem);
1102 path.set_extension(extension);
1103 path
1104 }
1105
1106 pub fn split_dwarf_path(
1109 &self,
1110 split_debuginfo_kind: SplitDebuginfo,
1111 split_dwarf_kind: SplitDwarfKind,
1112 cgu_name: &str,
1113 ) -> Option<PathBuf> {
1114 let obj_out = self.temp_path_for_cgu(OutputType::Object, cgu_name);
1115 let dwo_out = self.temp_path_dwo_for_cgu(cgu_name);
1116 match (split_debuginfo_kind, split_dwarf_kind) {
1117 (SplitDebuginfo::Off, SplitDwarfKind::Single | SplitDwarfKind::Split) => None,
1118 (SplitDebuginfo::Packed | SplitDebuginfo::Unpacked, SplitDwarfKind::Single) => {
1122 Some(obj_out)
1123 }
1124 (SplitDebuginfo::Packed | SplitDebuginfo::Unpacked, SplitDwarfKind::Split) => {
1126 Some(dwo_out)
1127 }
1128 }
1129 }
1130}
1131
1132pub fn parse_remap_path_scope(
1134 early_dcx: &EarlyDiagCtxt,
1135 matches: &getopts::Matches,
1136 unstable_opts: &UnstableOptions,
1137) -> RemapPathScopeComponents {
1138 if let Some(v) = matches.opt_str("remap-path-scope") {
1139 let mut slot = RemapPathScopeComponents::empty();
1140 for s in v.split(',') {
1141 slot |= match s {
1142 "macro" => RemapPathScopeComponents::MACRO,
1143 "diagnostics" => RemapPathScopeComponents::DIAGNOSTICS,
1144 "documentation" => {
1145 if !unstable_opts.unstable_options {
1146 early_dcx.early_fatal("remapping `documentation` path scope requested but `-Zunstable-options` not specified");
1147 }
1148
1149 RemapPathScopeComponents::DOCUMENTATION
1150 }
1151 "debuginfo" => RemapPathScopeComponents::DEBUGINFO,
1152 "coverage" => RemapPathScopeComponents::COVERAGE,
1153 "object" => RemapPathScopeComponents::OBJECT,
1154 "all" => RemapPathScopeComponents::all(),
1155 _ => early_dcx.early_fatal("argument for `--remap-path-scope` must be a comma separated list of scopes: `macro`, `diagnostics`, `documentation`, `debuginfo`, `coverage`, `object`, `all`"),
1156 }
1157 }
1158 slot
1159 } else {
1160 RemapPathScopeComponents::all()
1161 }
1162}
1163
1164#[derive(#[automatically_derived]impl ::core::clone::Clone for Sysroot {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
1165pub struct Sysroot {
1166 pub explicit: Option<PathBuf>,
1167 pub default: PathBuf,
1168}
1169
1170impl Sysroot {
1171 pub fn new(explicit: Option<PathBuf>) -> Sysroot {
1172 Sysroot { explicit, default: filesearch::default_sysroot() }
1173 }
1174
1175 pub fn path(&self) -> &Path {
1177 self.explicit.as_deref().unwrap_or(&self.default)
1178 }
1179
1180 pub fn all_paths(&self) -> impl Iterator<Item = &Path> {
1182 self.explicit.as_deref().into_iter().chain(iter::once(&*self.default))
1183 }
1184}
1185
1186pub fn host_tuple() -> &'static str {
1191 (::core::option::Option::Some("x86_64-unknown-linux-gnu")option_env!("CFG_COMPILER_HOST_TRIPLE")).expect("CFG_COMPILER_HOST_TRIPLE")
1195}
1196
1197fn file_path_mapping(
1198 remap_path_prefix: Vec<(PathBuf, PathBuf)>,
1199 remap_cwd_prefix: Option<&Path>,
1200 remap_path_scope: RemapPathScopeComponents,
1201) -> FilePathMapping {
1202 let cwd_remap = if let Some(to) = remap_cwd_prefix
1205 && let Ok(cwd) = std::env::current_dir()
1206 {
1207 Some((cwd, to.to_path_buf()))
1208 } else {
1209 None
1210 };
1211 FilePathMapping::new(remap_path_prefix.into_iter().chain(cwd_remap).collect(), remap_path_scope)
1214}
1215
1216impl Default for Options {
1217 fn default() -> Options {
1218 let unstable_opts = UnstableOptions::default();
1219
1220 let working_dir = {
1224 let working_dir = std::env::current_dir().unwrap();
1225 let file_mapping =
1226 file_path_mapping(Vec::new(), None, RemapPathScopeComponents::empty());
1227 file_mapping.to_real_filename(&RealFileName::empty(), &working_dir)
1228 };
1229
1230 Options {
1231 crate_types: Vec::new(),
1232 optimize: OptLevel::No,
1233 debuginfo: DebugInfo::None,
1234 lint_opts: Vec::new(),
1235 lint_cap: None,
1236 describe_lints: false,
1237 output_types: OutputTypes(BTreeMap::new()),
1238 search_paths: ::alloc::vec::Vec::new()vec![],
1239 sysroot: Sysroot::new(None),
1240 target_triple: TargetTuple::from_tuple(host_tuple()),
1241 test: false,
1242 incremental: None,
1243 unstable_opts,
1244 prints: Vec::new(),
1245 cg: Default::default(),
1246 error_format: ErrorOutputType::default(),
1247 diagnostic_width: None,
1248 externs: Externs(BTreeMap::new()),
1249 crate_name: None,
1250 libs: Vec::new(),
1251 unstable_features: UnstableFeatures::Disallow,
1252 debug_assertions: true,
1253 actually_rustdoc: false,
1254 resolve_doc_links: ResolveDocLinks::None,
1255 trimmed_def_paths: false,
1256 cli_forced_codegen_units: None,
1257 cli_forced_local_thinlto_off: false,
1258 remap_path_prefix: Vec::new(),
1259 remap_path_scope: RemapPathScopeComponents::all(),
1260 real_rust_source_base_dir: None,
1261 real_rustc_dev_source_base_dir: None,
1262 edition: DEFAULT_EDITION,
1263 json_artifact_notifications: false,
1264 json_timings: false,
1265 json_unused_externs: JsonUnusedExterns::No,
1266 json_future_incompat: false,
1267 pretty: None,
1268 working_dir,
1269 color: ColorConfig::Auto,
1270 verbose: false,
1271 target_modifiers: BTreeMap::default(),
1272 mitigation_coverage_map: Default::default(),
1273 jobs: Jobs {
1274 frontend: JobsMode::Sequential,
1275 backend: JobsMode::Sequential,
1276 linker: LinkerJobs::Default,
1277 },
1278 recommended_stack_size: DEFAULT_STACK_SIZE,
1279 }
1280 }
1281}
1282
1283impl Options {
1284 pub fn build_dep_graph(&self) -> bool {
1286 self.incremental.is_some()
1287 || self.unstable_opts.dump_dep_graph
1288 || self.unstable_opts.query_dep_graph
1289 }
1290
1291 pub fn file_path_mapping(&self) -> FilePathMapping {
1292 file_path_mapping(
1293 self.remap_path_prefix.clone(),
1294 self.unstable_opts.remap_cwd_prefix.as_deref(),
1295 self.remap_path_scope,
1296 )
1297 }
1298
1299 pub fn will_create_output_file(&self) -> bool {
1301 !self.unstable_opts.parse_crate_root_only && self.unstable_opts.ls.is_empty() }
1304
1305 #[inline]
1306 pub fn share_generics(&self) -> bool {
1307 match self.unstable_opts.share_generics {
1308 Some(setting) => setting,
1309 None => self.optimize.objective() != OptimizationObjective::Speed,
1312 }
1313 }
1314
1315 pub fn get_symbol_mangling_version(&self) -> SymbolManglingVersion {
1316 self.cg.symbol_mangling_version.unwrap_or(SymbolManglingVersion::V0)
1317 }
1318
1319 #[inline]
1320 pub fn autodiff_enabled(&self) -> bool {
1321 self.unstable_opts.autodiff.contains(&AutoDiff::Enable)
1322 }
1323}
1324
1325impl UnstableOptions {
1326 pub fn dcx_flags(&self, can_emit_warnings: bool) -> DiagCtxtFlags {
1327 DiagCtxtFlags {
1328 can_emit_warnings,
1329 treat_err_as_bug: self.treat_err_as_bug,
1330 eagerly_emit_delayed_bugs: self.eagerly_emit_delayed_bugs,
1331 macro_backtrace: self.macro_backtrace,
1332 deduplicate_diagnostics: self.deduplicate_diagnostics,
1333 track_diagnostics: self.track_diagnostics,
1334 }
1335 }
1336
1337 pub fn src_hash_algorithm(&self, target: &Target) -> SourceFileHashAlgorithm {
1338 self.src_hash_algorithm.unwrap_or_else(|| {
1339 if target.is_like_msvc {
1340 SourceFileHashAlgorithm::Sha256
1341 } else {
1342 SourceFileHashAlgorithm::Md5
1343 }
1344 })
1345 }
1346
1347 pub fn checksum_hash_algorithm(&self) -> Option<SourceFileHashAlgorithm> {
1348 self.checksum_hash_algorithm
1349 }
1350}
1351
1352#[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]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
1354pub enum EntryFnType {
1355 Main {
1356 sigpipe: u8,
1363 },
1364}
1365
1366#[derive(#[automatically_derived]impl ::core::clone::Clone for Passes {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
1367pub enum Passes {
1368 Some(Vec<String>),
1369 All,
1370}
1371
1372impl Passes {
1373 fn is_empty(&self) -> bool {
1374 match *self {
1375 Passes::Some(ref v) => v.is_empty(),
1376 Passes::All => false,
1377 }
1378 }
1379
1380 pub(crate) fn extend(&mut self, passes: impl IntoIterator<Item = String>) {
1381 match *self {
1382 Passes::Some(ref mut v) => v.extend(passes),
1383 Passes::All => {}
1384 }
1385 }
1386}
1387
1388#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for PAuthKey {
}
#[automatically_derived]impl ::core::clone::Clone for PAuthKey {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
1389pub enum PAuthKey {
1390 A,
1391 B,
1392}
1393
1394#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for PacRet {
}
#[automatically_derived]impl ::core::clone::Clone for PacRet {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
1395pub struct PacRet {
1396 pub leaf: bool,
1397 pub pc: bool,
1398 pub key: PAuthKey,
1399}
1400
1401#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for BranchProtection {
}
#[automatically_derived]impl ::core::clone::Clone for BranchProtection {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
1402pub struct BranchProtection {
1403 pub bti: bool,
1404 pub pac_ret: Option<PacRet>,
1405 pub gcs: bool,
1406}
1407
1408#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for PointerAuthOption {
}
#[automatically_derived]impl ::core::clone::Clone for PointerAuthOption {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for PointerAuthOption { }Copy, #[automatically_derived]impl ::core::fmt::Debug for PointerAuthOption {
#[inline]
#[rustc_trivial_field_reads]
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)]
1409pub enum PointerAuthOption {
1410 Aarch64JumpTableHardening,
1415 AuthTraps,
1416 Calls,
1417 ElfGot,
1418 FunctionPointerTypeDiscrimination,
1419 IndirectGotos,
1420 InitFini,
1421 InitFiniAddressDiscrimination,
1422 Intrinsics,
1423 ReturnAddresses,
1424 TypeInfoVTPtrDisc,
1425 VTPtrAddrDisc,
1426 VTPtrTypeDisc,
1427 }
1429impl PointerAuthOption {
1430 pub fn parse(s: &str) -> Option<Self> {
1431 match s {
1432 "aarch64-jump-table-hardening" => Some(Self::Aarch64JumpTableHardening),
1433 "auth-traps" => Some(Self::AuthTraps),
1434 "calls" => Some(Self::Calls),
1435 "elf-got" => Some(Self::ElfGot),
1436 "function-pointer-type-discrimination" => Some(Self::FunctionPointerTypeDiscrimination),
1437 "indirect-gotos" => Some(Self::IndirectGotos),
1438 "init-fini" => Some(Self::InitFini),
1439 "init-fini-address-discrimination" => Some(Self::InitFiniAddressDiscrimination),
1440 "intrinsics" => Some(Self::Intrinsics),
1441 "return-addresses" => Some(Self::ReturnAddresses),
1442 "typeinfo-vt-ptr-discrimination" => Some(Self::TypeInfoVTPtrDisc),
1443 "vt-ptr-addr-discrimination" => Some(Self::VTPtrAddrDisc),
1444 "vt-ptr-type-discrimination" => Some(Self::VTPtrTypeDisc),
1445 _ => None,
1446 }
1447 }
1448}
1449
1450#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for JobsMode {
}
#[automatically_derived]impl ::core::clone::Clone for JobsMode {
#[inline]
#[rustc_trivial_field_reads]
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)]
1451pub enum JobsMode {
1452 Sequential,
1455 Parallel(NonZero<usize>),
1459}
1460
1461impl JobsMode {
1462 pub fn limit(self) -> NonZero<usize> {
1463 match self {
1464 JobsMode::Sequential => NonZero::new(1).unwrap(),
1465 JobsMode::Parallel(n) => n,
1466 }
1467 }
1468
1469 pub fn is_parallel(self) -> bool {
1470 #[allow(non_exhaustive_omitted_patterns)] match self {
JobsMode::Parallel(..) => true,
_ => false,
}matches!(self, JobsMode::Parallel(..))
1471 }
1472}
1473
1474#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for LinkerJobs {
}
#[automatically_derived]impl ::core::clone::Clone for LinkerJobs {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<JobsMode>;
*self
}
}Clone, #[automatically_derived]impl ::core::marker::Copy for LinkerJobs { }Copy)]
1475pub enum LinkerJobs {
1476 Default,
1478 Explicit(JobsMode),
1480}
1481
1482impl LinkerJobs {
1483 pub fn mode(self) -> JobsMode {
1484 match self {
1485 LinkerJobs::Default => JobsMode::Sequential,
1486 LinkerJobs::Explicit(n) => n,
1487 }
1488 }
1489}
1490
1491#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for Jobs {
}
#[automatically_derived]impl ::core::clone::Clone for Jobs {
#[inline]
#[rustc_trivial_field_reads]
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)]
1492pub struct Jobs {
1493 pub frontend: JobsMode,
1494 pub backend: JobsMode,
1495 pub linker: LinkerJobs,
1496}
1497
1498fn parse_jobs_all(
1499 early_dcx: &EarlyDiagCtxt,
1500 matches: &getopts::Matches,
1501 zthreads: Option<&str>,
1502 zno_parallel_backend: bool,
1503 unstable: bool,
1504) -> Jobs {
1505 if zno_parallel_backend {
1506 early_dcx.early_fatal("`-Zno-parallel-backend` is removed, use `--jobs-backend=1` instead");
1507 }
1508 let mut available = None;
1509 let jobs = matches
1510 .opt_str("jobs")
1511 .map(|s| parse_jobs_one(early_dcx, "--jobs", &s, unstable, &mut available));
1512 let check_upper_limit = |value: JobsMode, opt_name| {
1513 if let Some(jobs) = jobs
1514 && value.limit() > jobs.limit()
1515 {
1516 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`"));
1517 }
1518 };
1519 let frontend = match matches.opt_str("jobs-frontend") {
1520 Some(jobs_frontend) => {
1521 let opt_name = "--jobs-frontend";
1522 let frontend =
1523 parse_jobs_one(early_dcx, opt_name, &jobs_frontend, unstable, &mut available);
1524 check_upper_limit(frontend, opt_name);
1525 if zthreads.is_some() {
1526 early_dcx.early_fatal("cannot use both `--jobs-frontend` and `-Zthreads`");
1527 }
1528 frontend
1529 }
1530 None => match zthreads {
1531 Some(zthreads) => {
1532 let opt_name = "-Zthreads";
1533 let frontend =
1534 parse_jobs_one(early_dcx, opt_name, zthreads, unstable, &mut available);
1535 check_upper_limit(frontend, opt_name);
1536 frontend
1537 }
1538 None => {
1539 if let Some(default_frontend_jobs) = ::core::option::Option::Some("2")option_env!("CFG_DEFAULT_FRONTEND_JOBS") {
1541 let mut frontend_jobs = parse_jobs_one(
1542 early_dcx,
1543 "CFG_DEFAULT_FRONTEND_JOBS",
1544 default_frontend_jobs,
1545 true,
1546 &mut available,
1547 );
1548
1549 if let Some(jobs) = jobs
1554 && frontend_jobs.limit() > jobs.limit()
1555 {
1556 frontend_jobs = jobs;
1557 }
1558 frontend_jobs
1559 } else {
1560 JobsMode::Sequential }
1562 }
1563 },
1564 };
1565
1566 let backend = match matches.opt_str("jobs-backend") {
1567 Some(jobs_backend) => {
1568 let opt_name = "--jobs-backend";
1569 let backend =
1570 parse_jobs_one(early_dcx, opt_name, &jobs_backend, unstable, &mut available);
1571 check_upper_limit(backend, opt_name);
1572 backend
1573 }
1574 None => match jobs {
1575 Some(n) => n,
1576 None => parse_jobs_one(early_dcx, "", "0", unstable, &mut available),
1578 },
1579 };
1580 let linker = match matches.opt_str("jobs-linker") {
1581 Some(jobs_linker) => {
1582 let opt_name = "--jobs-linker";
1583 let linker =
1584 parse_jobs_one(early_dcx, opt_name, &jobs_linker, unstable, &mut available);
1585 check_upper_limit(linker, opt_name);
1586 LinkerJobs::Explicit(linker)
1587 }
1588 None => match jobs {
1589 Some(n) => LinkerJobs::Explicit(n),
1590 None => LinkerJobs::Default, },
1592 };
1593
1594 Jobs { frontend, backend, linker }
1595}
1596
1597fn parse_jobs_one(
1599 early_dcx: &EarlyDiagCtxt,
1600 opt_name: &str,
1601 s: &str,
1602 unstable: bool,
1603 available: &mut Option<u8>,
1604) -> JobsMode {
1605 if s == "sync" {
1606 if !unstable {
1608 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`"));
1609 }
1610 return JobsMode::Parallel(NonZero::new(1).unwrap());
1611 }
1612 let n = match u8::from_str(s) {
1616 Ok(0) => *available.get_or_insert_with(|| match thread::available_parallelism() {
1617 Ok(n) => u8::try_from(n.get()).unwrap_or(u8::MAX),
1618 Err(_) => 1,
1619 }),
1620 Ok(n) => n,
1621 Err(_) => early_dcx
1622 .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`")),
1623 };
1624 match n {
1626 0 => ::core::panicking::unreachable_default_msg()unreachable!(),
1627 1 => JobsMode::Sequential,
1628 _ => JobsMode::Parallel(NonZero::new(usize::from(n)).unwrap()),
1629 }
1630}
1631
1632pub fn build_configuration(sess: &Session, mut user_cfg: Cfg) -> Cfg {
1633 cfg::disallow_cfgs(sess, &user_cfg);
1635
1636 user_cfg.extend(cfg::default_configuration(sess));
1639 user_cfg
1640}
1641
1642pub fn build_target_config(
1643 early_dcx: &EarlyDiagCtxt,
1644 target: &TargetTuple,
1645 sysroot: &Path,
1646 unstable_options: bool,
1647) -> Target {
1648 match Target::search(target, sysroot, unstable_options) {
1649 Ok((target, warnings)) => {
1650 for warning in warnings.warning_messages() {
1651 early_dcx.early_warn(warning)
1652 }
1653
1654 if !#[allow(non_exhaustive_omitted_patterns)] match target.pointer_width {
16 | 32 | 64 => true,
_ => false,
}matches!(target.pointer_width, 16 | 32 | 64) {
1655 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!(
1656 "target specification was invalid: unrecognized target-pointer-width {}",
1657 target.pointer_width
1658 ))
1659 }
1660 target
1661 }
1662 Err(e) => {
1663 let mut err =
1664 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}"));
1665 err.help("run `rustc --print target-list` for a list of built-in targets");
1666 let typed = target.tuple();
1667 let limit = typed.len() / 3 + 1;
1668 if let Some(suggestion) = rustc_target::spec::TARGETS
1669 .iter()
1670 .filter_map(|&t| {
1671 rustc_span::edit_distance::edit_distance_with_substrings(typed, t, limit)
1672 .map(|d| (d, t))
1673 })
1674 .min_by_key(|(d, _)| *d)
1675 .map(|(_, t)| t)
1676 {
1677 err.help(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("did you mean `{0}`?", suggestion))
})format!("did you mean `{suggestion}`?"));
1678 }
1679 err.emit_fatal()
1680 }
1681 }
1682}
1683
1684#[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]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
1685pub enum OptionStability {
1686 Stable,
1687 Unstable,
1688}
1689
1690#[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]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
1691pub enum OptionKind {
1692 Opt,
1696
1697 Multi,
1701
1702 Flag,
1707
1708 FlagMulti,
1713}
1714
1715pub struct RustcOptGroup {
1716 pub name: &'static str,
1724 stability: OptionStability,
1725 kind: OptionKind,
1726
1727 short_name: &'static str,
1728 long_name: &'static str,
1729 desc: &'static str,
1730 value_hint: &'static str,
1731
1732 pub is_verbose_help_only: bool,
1735}
1736
1737impl RustcOptGroup {
1738 pub fn is_stable(&self) -> bool {
1739 self.stability == OptionStability::Stable
1740 }
1741
1742 pub fn apply(&self, options: &mut getopts::Options) {
1743 let &Self { short_name, long_name, desc, value_hint, .. } = self;
1744 match self.kind {
1745 OptionKind::Opt => options.optopt(short_name, long_name, desc, value_hint),
1746 OptionKind::Multi => options.optmulti(short_name, long_name, desc, value_hint),
1747 OptionKind::Flag => options.optflag(short_name, long_name, desc),
1748 OptionKind::FlagMulti => options.optflagmulti(short_name, long_name, desc),
1749 };
1750 }
1751
1752 pub fn long_name(&self) -> &str {
1754 self.long_name
1755 }
1756}
1757
1758pub fn make_opt(
1759 stability: OptionStability,
1760 kind: OptionKind,
1761 short_name: &'static str,
1762 long_name: &'static str,
1763 desc: &'static str,
1764 value_hint: &'static str,
1765) -> RustcOptGroup {
1766 match kind {
1768 OptionKind::Opt | OptionKind::Multi => {}
1769 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, ""),
1770 }
1771 RustcOptGroup {
1772 name: cmp::max_by_key(short_name, long_name, |s| s.len()),
1773 stability,
1774 kind,
1775 short_name,
1776 long_name,
1777 desc,
1778 value_hint,
1779 is_verbose_help_only: false,
1780 }
1781}
1782
1783static EDITION_STRING: LazyLock<String> = LazyLock::new(|| {
1784 ::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!(
1785 "Specify which edition of the compiler to use when compiling code. \
1786The default is {DEFAULT_EDITION} and the latest stable edition is {LATEST_STABLE_EDITION}."
1787 )
1788});
1789
1790static EMIT_HELP: LazyLock<String> = LazyLock::new(|| {
1791 let mut result =
1792 String::from("Comma separated list of types of output for the compiler to emit.\n");
1793 result.push_str("Each TYPE has the default FILE name:\n");
1794
1795 for output in OutputType::iter_all() {
1796 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()));
1797 }
1798
1799 result
1800});
1801
1802pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
1812 use OptionKind::{Flag, FlagMulti, Multi, Opt};
1813 use OptionStability::{Stable, Unstable};
1814
1815 use self::make_opt as opt;
1816
1817 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![
1818 opt(Stable, Flag, "h", "help", "Display this message", ""),
1819 opt(
1820 Stable,
1821 Multi,
1822 "",
1823 "cfg",
1824 "Configure the compilation environment.\n\
1825 SPEC supports the syntax `<NAME>[=\"<VALUE>\"]`.",
1826 "<SPEC>",
1827 ),
1828 opt(Stable, Multi, "", "check-cfg", "Provide list of expected cfgs for checking", "<SPEC>"),
1829 opt(
1830 Stable,
1831 Multi,
1832 "L",
1833 "",
1834 "Add a directory to the library search path. \
1835 The optional KIND can be one of <dependency|crate|native|framework|all> (default: all).",
1836 "[<KIND>=]<PATH>",
1837 ),
1838 opt(
1839 Stable,
1840 Multi,
1841 "l",
1842 "",
1843 "Link the generated crate(s) to the specified native\n\
1844 library NAME. The optional KIND can be one of\n\
1845 <static|framework|dylib> (default: dylib).\n\
1846 Optional comma separated MODIFIERS\n\
1847 <bundle|verbatim|whole-archive|as-needed>\n\
1848 may be specified each with a prefix of either '+' to\n\
1849 enable or '-' to disable.",
1850 "[<KIND>[:<MODIFIERS>]=]<NAME>[:<RENAME>]",
1851 ),
1852 make_crate_type_option(),
1853 opt(Stable, Opt, "", "crate-name", "Specify the name of the crate being built", "<NAME>"),
1854 opt(Stable, Opt, "", "edition", &EDITION_STRING, EDITION_NAME_LIST),
1855 opt(Stable, Multi, "", "emit", &EMIT_HELP, "<TYPE>[=<FILE>]"),
1856 opt(Stable, Multi, "", "print", &print_request::PRINT_HELP, "<INFO>[=<FILE>]"),
1857 opt(Stable, FlagMulti, "g", "", "Equivalent to -C debuginfo=2", ""),
1858 opt(Stable, FlagMulti, "O", "", "Equivalent to -C opt-level=3", ""),
1859 opt(Stable, Opt, "o", "", "Write output to FILENAME", "<FILENAME>"),
1860 opt(Stable, Opt, "", "out-dir", "Write output to compiler-chosen filename in DIR", "<DIR>"),
1861 opt(
1862 Stable,
1863 Opt,
1864 "",
1865 "explain",
1866 "Provide a detailed explanation of an error message",
1867 "<OPT>",
1868 ),
1869 opt(Stable, Flag, "", "test", "Build a test harness", ""),
1870 opt(Stable, Opt, "", "target", "Target tuple for which the code is compiled", "<TARGET>"),
1871 opt(Stable, Multi, "A", "allow", "Set lint allowed", "<LINT>"),
1872 opt(Stable, Multi, "W", "warn", "Set lint warnings", "<LINT>"),
1873 opt(Stable, Multi, "", "force-warn", "Set lint force-warn", "<LINT>"),
1874 opt(Stable, Multi, "D", "deny", "Set lint denied", "<LINT>"),
1875 opt(Stable, Multi, "F", "forbid", "Set lint forbidden", "<LINT>"),
1876 opt(
1877 Stable,
1878 Multi,
1879 "",
1880 "cap-lints",
1881 "Set the most restrictive lint level. More restrictive lints are capped at this level",
1882 "<LEVEL>",
1883 ),
1884 opt(Stable, Multi, "C", "codegen", "Set a codegen option", "<OPT>[=<VALUE>]"),
1885 opt(Stable, Flag, "V", "version", "Print version info and exit", ""),
1886 opt(Stable, Flag, "v", "verbose", "Use verbose output", ""),
1887 ];
1888
1889 let verbose_only = [
1892 opt(
1893 Stable,
1894 Multi,
1895 "",
1896 "extern",
1897 "Specify where an external rust library is located",
1898 "<NAME>[=<PATH>]",
1899 ),
1900 opt(Stable, Opt, "", "sysroot", "Override the system root", "<PATH>"),
1901 opt(Unstable, Multi, "Z", "", "Set unstable / perma-unstable options", "<FLAG>"),
1902 opt(
1903 Stable,
1904 Opt,
1905 "",
1906 "error-format",
1907 "How errors and other messages are produced",
1908 "<human|json|short>",
1909 ),
1910 opt(Stable, Multi, "", "json", "Configure the JSON output of the compiler", "<CONFIG>"),
1911 opt(
1912 Stable,
1913 Opt,
1914 "",
1915 "color",
1916 "Configure coloring of output:
1917 * auto = colorize, if output goes to a tty (default);
1918 * always = always colorize output;
1919 * never = never colorize output",
1920 "<auto|always|never>",
1921 ),
1922 opt(
1923 Stable,
1924 Opt,
1925 "",
1926 "diagnostic-width",
1927 "Inform rustc of the width of the output so that diagnostics can be truncated to fit",
1928 "<WIDTH>",
1929 ),
1930 opt(
1931 Stable,
1932 Multi,
1933 "",
1934 "remap-path-prefix",
1935 "Remap source names in all output (compiler messages and output files)",
1936 "<FROM>=<TO>",
1937 ),
1938 opt(
1939 Stable,
1940 Opt,
1941 "",
1942 "remap-path-scope",
1943 "Defines which scopes of paths should be remapped by `--remap-path-prefix`",
1944 "<macro,diagnostics,debuginfo,coverage,object,all>",
1945 ),
1946 opt(Unstable, Opt, "j", "jobs", "Limit on the number of used parallel jobs", "<N>"),
1947 opt(
1948 Unstable,
1949 Opt,
1950 "",
1951 "jobs-frontend",
1952 "Limit on the number of parallel jobs used by frontend",
1953 "<N>",
1954 ),
1955 opt(
1956 Unstable,
1957 Opt,
1958 "",
1959 "jobs-backend",
1960 "Limit on the number of parallel jobs used by backend",
1961 "<N>",
1962 ),
1963 opt(
1964 Unstable,
1965 Opt,
1966 "",
1967 "jobs-linker",
1968 "Limit on the number of parallel jobs used by linker",
1969 "<N>",
1970 ),
1971 ];
1972 options.extend(verbose_only.into_iter().map(|mut opt| {
1973 opt.is_verbose_help_only = true;
1974 opt
1975 }));
1976
1977 options
1978}
1979
1980pub fn get_cmd_lint_options(
1981 early_dcx: &EarlyDiagCtxt,
1982 matches: &getopts::Matches,
1983) -> (Vec<(String, lint::Level)>, bool, Option<lint::Level>) {
1984 let mut lint_opts_with_position = ::alloc::vec::Vec::new()vec![];
1985 let mut describe_lints = false;
1986
1987 for level in [lint::Allow, lint::Warn, lint::ForceWarn, lint::Deny, lint::Forbid] {
1988 for (arg_pos, lint_name) in matches.opt_strs_pos(level.as_str()) {
1989 if lint_name == "help" {
1990 describe_lints = true;
1991 } else {
1992 lint_opts_with_position.push((arg_pos, lint_name.replace('-', "_"), level));
1993 }
1994 }
1995 }
1996
1997 lint_opts_with_position.sort_by_key(|x| x.0);
1998 let lint_opts = lint_opts_with_position
1999 .iter()
2000 .cloned()
2001 .map(|(_, lint_name, level)| (lint_name, level))
2002 .collect();
2003
2004 let lint_cap = matches.opt_str("cap-lints").map(|cap| {
2005 lint::Level::from_str(&cap)
2006 .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}`")))
2007 });
2008
2009 (lint_opts, describe_lints, lint_cap)
2010}
2011
2012pub fn parse_color(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> ColorConfig {
2014 match matches.opt_str("color").as_deref() {
2015 Some("auto") => ColorConfig::Auto,
2016 Some("always") => ColorConfig::Always,
2017 Some("never") => ColorConfig::Never,
2018
2019 None => ColorConfig::Auto,
2020
2021 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!(
2022 "argument for `--color` must be auto, \
2023 always or never (instead was `{arg}`)"
2024 )),
2025 }
2026}
2027
2028pub struct JsonConfig {
2030 pub json_rendered: HumanReadableErrorType,
2031 pub json_color: ColorConfig,
2032 json_artifact_notifications: bool,
2033 json_timings: bool,
2036 pub json_unused_externs: JsonUnusedExterns,
2037 json_future_incompat: bool,
2038}
2039
2040#[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]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self { *self }
}Clone)]
2042pub enum JsonUnusedExterns {
2043 No,
2045 Silent,
2047 Loud,
2049}
2050
2051impl JsonUnusedExterns {
2052 pub fn is_enabled(&self) -> bool {
2053 match self {
2054 JsonUnusedExterns::No => false,
2055 JsonUnusedExterns::Loud | JsonUnusedExterns::Silent => true,
2056 }
2057 }
2058
2059 pub fn is_loud(&self) -> bool {
2060 match self {
2061 JsonUnusedExterns::No | JsonUnusedExterns::Silent => false,
2062 JsonUnusedExterns::Loud => true,
2063 }
2064 }
2065}
2066
2067pub fn parse_json(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> JsonConfig {
2072 let mut json_rendered =
2073 HumanReadableErrorType { no_graphics: false, short: false, unicode: false };
2074 let mut json_color = ColorConfig::Never;
2075 let mut json_artifact_notifications = false;
2076 let mut json_unused_externs = JsonUnusedExterns::No;
2077 let mut json_future_incompat = false;
2078 let mut json_timings = false;
2079 for option in matches.opt_strs("json") {
2080 if matches.opt_str("color").is_some() {
2084 early_dcx.early_fatal("cannot specify the `--color` option with `--json`");
2085 }
2086
2087 for sub_option in option.split(',') {
2088 match sub_option {
2089 "diagnostic-short" => {
2090 json_rendered =
2091 HumanReadableErrorType { no_graphics: false, short: true, unicode: false };
2092 }
2093 "diagnostic-no-graphics" => {
2094 json_rendered =
2095 HumanReadableErrorType { no_graphics: true, short: false, unicode: false };
2096 }
2097 "diagnostic-unicode" => {
2098 json_rendered =
2099 HumanReadableErrorType { no_graphics: false, short: false, unicode: true };
2100 }
2101 "diagnostic-rendered-ansi" => json_color = ColorConfig::Always,
2102 "artifacts" => json_artifact_notifications = true,
2103 "timings" => json_timings = true,
2104 "unused-externs" => json_unused_externs = JsonUnusedExterns::Loud,
2105 "unused-externs-silent" => json_unused_externs = JsonUnusedExterns::Silent,
2106 "future-incompat" => json_future_incompat = true,
2107 s => early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("unknown `--json` option `{0}`", s))
})format!("unknown `--json` option `{s}`")),
2108 }
2109 }
2110 }
2111
2112 JsonConfig {
2113 json_rendered,
2114 json_color,
2115 json_artifact_notifications,
2116 json_timings,
2117 json_unused_externs,
2118 json_future_incompat,
2119 }
2120}
2121
2122pub fn parse_error_format(
2124 early_dcx: &mut EarlyDiagCtxt,
2125 matches: &getopts::Matches,
2126 color_config: ColorConfig,
2127 json_color: ColorConfig,
2128 json_rendered: HumanReadableErrorType,
2129) -> ErrorOutputType {
2130 let default_kind = HumanReadableErrorType { no_graphics: false, short: false, unicode: false };
2131 let error_format = if matches.opts_present(&["error-format".to_owned()]) {
2136 match matches.opt_str("error-format").as_deref() {
2137 None | Some("human") => {
2138 ErrorOutputType::HumanReadable { color_config, kind: default_kind }
2139 }
2140 Some("json") => {
2141 ErrorOutputType::Json { pretty: false, json_rendered, color_config: json_color }
2142 }
2143 Some("pretty-json") => {
2144 ErrorOutputType::Json { pretty: true, json_rendered, color_config: json_color }
2145 }
2146 Some("short") => ErrorOutputType::HumanReadable {
2147 kind: HumanReadableErrorType { no_graphics: false, short: true, unicode: false },
2148 color_config,
2149 },
2150 Some("human-no-graphics") => ErrorOutputType::HumanReadable {
2151 kind: HumanReadableErrorType { no_graphics: true, short: false, unicode: false },
2152 color_config,
2153 },
2154 Some("human-unicode") => ErrorOutputType::HumanReadable {
2155 kind: HumanReadableErrorType { no_graphics: false, short: false, unicode: true },
2156 color_config,
2157 },
2158 Some(arg) => {
2159 early_dcx.set_error_format(ErrorOutputType::HumanReadable {
2160 color_config,
2161 kind: default_kind,
2162 });
2163 early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("argument for `--error-format` must be `human`, `human-no-graphics`, `human-unicode`, `json`, `pretty-json` or `short` (instead was `{0}`)",
arg))
})format!(
2164 "argument for `--error-format` must be `human`, `human-no-graphics`, \
2165 `human-unicode`, `json`, `pretty-json` or `short` (instead was `{arg}`)"
2166 ))
2167 }
2168 }
2169 } else {
2170 ErrorOutputType::HumanReadable { color_config, kind: default_kind }
2171 };
2172
2173 match error_format {
2174 ErrorOutputType::Json { .. } => {}
2175
2176 _ if !matches.opt_strs("json").is_empty() => {
2180 early_dcx.early_fatal("using `--json` requires also using `--error-format=json`");
2181 }
2182
2183 _ => {}
2184 }
2185
2186 error_format
2187}
2188
2189pub fn parse_crate_edition(
2190 early_dcx: &EarlyDiagCtxt,
2191 matches: &getopts::Matches,
2192 has_input: bool,
2193) -> Edition {
2194 let is_nightly = nightly_options::match_is_nightly_build(matches);
2195 let edition_list = if is_nightly { EDITION_NAME_LIST } else { EDITION_NAME_LIST_STABLE };
2196 let edition = match matches.opt_str("edition") {
2197 Some(arg) => Edition::from_str(&arg).unwrap_or_else(|_| {
2198 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!(
2199 "argument for `--edition` must be one of: {edition_list} (instead was `{arg}`)",
2200 ))
2201 }),
2202 None => {
2203 if has_input {
2204 {
::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!(
2205 "`--edition` is unspecified, defaulting to `{DEFAULT_EDITION}` while the \
2206 latest is `{LATEST_STABLE_EDITION}`; it must be one of: {edition_list}\n",
2207 );
2208 }
2209 DEFAULT_EDITION
2210 }
2211 };
2212
2213 if !edition.is_stable() && !nightly_options::unstable_options_enabled(matches) {
2214 let msg = if !is_nightly {
2215 ::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!(
2216 "the crate requires edition {edition}, but the latest edition supported by this \
2217 Rust version is {LATEST_STABLE_EDITION}"
2218 )
2219 } else {
2220 ::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")
2221 };
2222 early_dcx.early_fatal(msg)
2223 }
2224
2225 edition
2226}
2227
2228fn check_error_format_stability(
2229 early_dcx: &EarlyDiagCtxt,
2230 unstable_opts: &UnstableOptions,
2231 unstable_flags_enabled: bool,
2232 format: ErrorOutputType,
2233) {
2234 if unstable_opts.unstable_options || unstable_flags_enabled {
2235 return;
2236 }
2237 let format = match format {
2238 ErrorOutputType::Json { pretty: true, .. } => "pretty-json",
2239 ErrorOutputType::HumanReadable { kind, .. } => match kind {
2240 HumanReadableErrorType { no_graphics: true, .. } => "human-no-graphics",
2241 HumanReadableErrorType { unicode: true, .. } => "human-unicode",
2242 _ => return,
2243 },
2244 _ => return,
2245 };
2246 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"))
2247}
2248
2249fn parse_output_types(
2250 early_dcx: &EarlyDiagCtxt,
2251 unstable_opts: &UnstableOptions,
2252 matches: &getopts::Matches,
2253) -> OutputTypes {
2254 let mut output_types = BTreeMap::new();
2255 if !unstable_opts.parse_crate_root_only {
2256 for list in matches.opt_strs("emit") {
2257 for output_type in list.split(',') {
2258 let (shorthand, path) = split_out_file_name(output_type);
2259 let output_type = OutputType::from_shorthand(shorthand).unwrap_or_else(|| {
2260 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!(
2261 "unknown emission type: `{shorthand}` - expected one of: {display}",
2262 display = OutputType::shorthands_display(),
2263 ))
2264 });
2265 if output_type == OutputType::ThinLinkBitcode && !unstable_opts.unstable_options {
2266 early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} requested but -Zunstable-options not specified",
OutputType::ThinLinkBitcode.shorthand()))
})format!(
2267 "{} requested but -Zunstable-options not specified",
2268 OutputType::ThinLinkBitcode.shorthand()
2269 ));
2270 }
2271 output_types.insert(output_type, path);
2272 }
2273 }
2274 };
2275 if output_types.is_empty() {
2276 output_types.insert(OutputType::Exe, None);
2277 }
2278 OutputTypes(output_types)
2279}
2280
2281fn split_out_file_name(arg: &str) -> (&str, Option<OutFileName>) {
2282 match arg.split_once('=') {
2283 None => (arg, None),
2284 Some((kind, "-")) => (kind, Some(OutFileName::Stdout)),
2285 Some((kind, path)) => (kind, Some(OutFileName::Real(PathBuf::from(path)))),
2286 }
2287}
2288
2289fn should_override_cgus_and_disable_thinlto(
2290 early_dcx: &EarlyDiagCtxt,
2291 output_types: &OutputTypes,
2292 matches: &getopts::Matches,
2293 mut codegen_units: Option<usize>,
2294) -> (bool, Option<usize>) {
2295 let mut disable_local_thinlto = false;
2296 let incompatible: Vec<_> = output_types
2299 .0
2300 .iter()
2301 .map(|ot_path| ot_path.0)
2302 .filter(|ot| !ot.is_compatible_with_codegen_units_and_single_output_file())
2303 .map(|ot| ot.shorthand())
2304 .collect();
2305 if !incompatible.is_empty() {
2306 match codegen_units {
2307 Some(n) if n > 1 => {
2308 if matches.opt_present("o") {
2309 for ot in &incompatible {
2310 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!(
2311 "`--emit={ot}` with `-o` incompatible with \
2312 `-C codegen-units=N` for N > 1",
2313 ));
2314 }
2315 early_dcx.early_warn("resetting to default -C codegen-units=1");
2316 codegen_units = Some(1);
2317 disable_local_thinlto = true;
2318 }
2319 }
2320 _ => {
2321 codegen_units = Some(1);
2322 disable_local_thinlto = true;
2323 }
2324 }
2325 }
2326
2327 if codegen_units == Some(0) {
2328 early_dcx.early_fatal("value for codegen units must be a positive non-zero integer");
2329 }
2330
2331 (disable_local_thinlto, codegen_units)
2332}
2333
2334pub fn parse_target_triple(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> TargetTuple {
2335 match matches.opt_str("target") {
2336 Some(target) if target.ends_with(".json") => {
2337 let path = Path::new(&target);
2338 TargetTuple::from_path(path).unwrap_or_else(|_| {
2339 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"))
2340 })
2341 }
2342 Some(target) => TargetTuple::TargetTuple(target),
2343 _ => TargetTuple::from_tuple(host_tuple()),
2344 }
2345}
2346
2347fn parse_opt_level(
2348 early_dcx: &EarlyDiagCtxt,
2349 matches: &getopts::Matches,
2350 cg: &CodegenOptions,
2351) -> OptLevel {
2352 let max_o = matches.opt_positions("O").into_iter().max();
2359 let max_c = matches
2360 .opt_strs_pos("C")
2361 .into_iter()
2362 .flat_map(|(i, s)| {
2363 if let Some("opt-level") = s.split('=').next() { Some(i) } else { None }
2365 })
2366 .max();
2367 if max_o > max_c {
2368 OptLevel::Aggressive
2369 } else {
2370 match cg.opt_level.as_ref() {
2371 "0" => OptLevel::No,
2372 "1" => OptLevel::Less,
2373 "2" => OptLevel::More,
2374 "3" => OptLevel::Aggressive,
2375 "s" => OptLevel::Size,
2376 "z" => OptLevel::SizeMin,
2377 arg => {
2378 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!(
2379 "optimization level needs to be \
2380 between 0-3, s or z (instead was `{arg}`)"
2381 ));
2382 }
2383 }
2384 }
2385}
2386
2387fn select_debuginfo(matches: &getopts::Matches, cg: &CodegenOptions) -> DebugInfo {
2388 let max_g = matches.opt_positions("g").into_iter().max();
2389 let max_c = matches
2390 .opt_strs_pos("C")
2391 .into_iter()
2392 .flat_map(|(i, s)| {
2393 if let Some("debuginfo") = s.split('=').next() { Some(i) } else { None }
2395 })
2396 .max();
2397 if max_g > max_c { DebugInfo::Full } else { cg.debuginfo }
2398}
2399
2400pub fn parse_externs(
2401 early_dcx: &EarlyDiagCtxt,
2402 matches: &getopts::Matches,
2403 unstable_opts: &UnstableOptions,
2404) -> Externs {
2405 let is_unstable_enabled = unstable_opts.unstable_options;
2406 let mut externs: BTreeMap<String, ExternEntry> = BTreeMap::new();
2407 for arg in matches.opt_strs("extern") {
2408 let ExternOpt { crate_name: name, path, options } =
2409 split_extern_opt(early_dcx, unstable_opts, &arg).unwrap_or_else(|e| e.emit_fatal());
2410
2411 let entry = externs.entry(name.to_owned());
2412
2413 use std::collections::btree_map::Entry;
2414
2415 let entry = if let Some(path) = path {
2416 let path = CanonicalizedPath::new(path);
2418 match entry {
2419 Entry::Vacant(vacant) => {
2420 let files = BTreeSet::from_iter(iter::once(path));
2421 vacant.insert(ExternEntry::new(ExternLocation::ExactPaths(files)))
2422 }
2423 Entry::Occupied(occupied) => {
2424 let ext_ent = occupied.into_mut();
2425 match ext_ent {
2426 ExternEntry { location: ExternLocation::ExactPaths(files), .. } => {
2427 files.insert(path);
2428 }
2429 ExternEntry {
2430 location: location @ ExternLocation::FoundInLibrarySearchDirectories,
2431 ..
2432 } => {
2433 let files = BTreeSet::from_iter(iter::once(path));
2435 *location = ExternLocation::ExactPaths(files);
2436 }
2437 }
2438 ext_ent
2439 }
2440 }
2441 } else {
2442 match entry {
2444 Entry::Vacant(vacant) => {
2445 vacant.insert(ExternEntry::new(ExternLocation::FoundInLibrarySearchDirectories))
2446 }
2447 Entry::Occupied(occupied) => {
2448 occupied.into_mut()
2450 }
2451 }
2452 };
2453
2454 let mut is_private_dep = false;
2455 let mut add_prelude = true;
2456 let mut nounused_dep = false;
2457 let mut force = false;
2458 if let Some(opts) = options {
2459 if !is_unstable_enabled {
2460 early_dcx.early_fatal(
2461 "the `-Z unstable-options` flag must also be passed to \
2462 enable `--extern` options",
2463 );
2464 }
2465 for opt in opts.split(',') {
2466 match opt {
2467 "priv" => is_private_dep = true,
2468 "noprelude" => {
2469 if let ExternLocation::ExactPaths(_) = &entry.location {
2470 add_prelude = false;
2471 } else {
2472 early_dcx.early_fatal(
2473 "the `noprelude` --extern option requires a file path",
2474 );
2475 }
2476 }
2477 "nounused" => nounused_dep = true,
2478 "force" => force = true,
2479 _ => early_dcx.early_fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("unknown --extern option `{0}`",
opt))
})format!("unknown --extern option `{opt}`")),
2480 }
2481 }
2482 }
2483
2484 entry.is_private_dep |= is_private_dep;
2487 entry.nounused_dep |= nounused_dep;
2489 entry.force |= force;
2491 entry.add_prelude |= add_prelude;
2493 }
2494 Externs(externs)
2495}
2496
2497fn parse_remap_path_prefix(
2498 early_dcx: &EarlyDiagCtxt,
2499 matches: &getopts::Matches,
2500) -> Vec<(PathBuf, PathBuf)> {
2501 matches
2502 .opt_strs("remap-path-prefix")
2503 .into_iter()
2504 .map(|remap| match remap.rsplit_once('=') {
2505 None => {
2506 early_dcx.early_fatal("--remap-path-prefix must contain '=' between FROM and TO")
2507 }
2508 Some((from, to)) => (PathBuf::from(from), PathBuf::from(to)),
2509 })
2510 .collect()
2511}
2512
2513#[allow(rustc::bad_opt_access)]
2515pub fn build_session_options(
2516 early_dcx: &mut EarlyDiagCtxt,
2517 matches: &getopts::Matches,
2518 has_input: bool,
2519) -> Options {
2520 let color = parse_color(early_dcx, matches);
2521
2522 let edition = parse_crate_edition(early_dcx, matches, has_input);
2523
2524 let crate_name = matches.opt_str("crate-name");
2525 let unstable_features = UnstableFeatures::from_environment(crate_name.as_deref());
2526 let JsonConfig {
2527 json_rendered,
2528 json_color,
2529 json_artifact_notifications,
2530 json_timings,
2531 json_unused_externs,
2532 json_future_incompat,
2533 } = parse_json(early_dcx, matches);
2534
2535 let error_format = parse_error_format(early_dcx, matches, color, json_color, json_rendered);
2536
2537 early_dcx.set_error_format(error_format);
2538
2539 let diagnostic_width = matches.opt_get("diagnostic-width").unwrap_or_else(|_| {
2540 early_dcx.early_fatal("`--diagnostic-width` must be an positive integer");
2541 });
2542
2543 let unparsed_crate_types = matches.opt_strs("crate-type");
2544 let crate_types = parse_crate_types_from_list(unparsed_crate_types)
2545 .unwrap_or_else(|e| early_dcx.early_fatal(e));
2546
2547 let mut collected_options = Default::default();
2548
2549 let mut unstable_opts = UnstableOptions::build(early_dcx, matches, &mut collected_options);
2550
2551 if unstable_opts.assumptions_on_binders {
2555 let no_next_solver = matches
2558 .opt_strs("Z")
2559 .iter()
2560 .rfind(|arg| arg.starts_with("next-solver"))
2561 .is_some_and(|arg| *arg == "next-solver=no" || *arg == "next-solver=coherence");
2562 if no_next_solver {
2563 early_dcx.early_warn(
2564 "-Zassumptions-on-binders unconditionally enables the next trait solver; \
2565 `-Znext-solver=no` is ignored",
2566 );
2567 }
2568 unstable_opts.next_solver = NextSolverConfig::Globally;
2569 }
2570
2571 if unstable_opts.staticlib_hide_internal_symbols && !crate_types.contains(&CrateType::StaticLib)
2572 {
2573 early_dcx.early_warn(
2574 "-Zstaticlib-hide-internal-symbols has no effect without `--crate-type staticlib`",
2575 );
2576 }
2577
2578 if unstable_opts.staticlib_rename_internal_symbols
2579 && !crate_types.contains(&CrateType::StaticLib)
2580 {
2581 early_dcx.early_warn(
2582 "-Zstaticlib-rename-internal-symbols has no effect without `--crate-type staticlib`",
2583 );
2584 }
2585
2586 let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(early_dcx, matches);
2587
2588 if !unstable_opts.unstable_options && json_timings {
2589 early_dcx.early_fatal("--json=timings is unstable and requires using `-Zunstable-options`");
2590 }
2591
2592 check_error_format_stability(
2593 early_dcx,
2594 &unstable_opts,
2595 unstable_features.allow_unstable_compiler_flag("error-format"),
2596 error_format,
2597 );
2598
2599 let output_types = parse_output_types(early_dcx, &unstable_opts, matches);
2600
2601 let mut cg = CodegenOptions::build(early_dcx, matches, &mut collected_options);
2602 let (disable_local_thinlto, codegen_units) = should_override_cgus_and_disable_thinlto(
2603 early_dcx,
2604 &output_types,
2605 matches,
2606 cg.codegen_units,
2607 );
2608
2609 let incremental = cg.incremental.as_ref().map(PathBuf::from);
2610
2611 if cg.profile_generate.enabled() && cg.profile_use.is_some() {
2612 early_dcx.early_fatal("options `-C profile-generate` and `-C profile-use` are exclusive");
2613 }
2614
2615 if cg.profile_sample_use.is_some()
2616 && (cg.profile_generate.enabled() || cg.profile_use.is_some())
2617 {
2618 early_dcx.early_fatal(
2619 "option `-C profile-sample-use` cannot be used with `-C profile-generate` or `-C profile-use`",
2620 );
2621 }
2622
2623 match cg.symbol_mangling_version {
2626 None | Some(SymbolManglingVersion::V0) => {}
2628
2629 Some(SymbolManglingVersion::Legacy) => {
2631 if !unstable_opts.unstable_options {
2632 early_dcx.early_fatal(
2633 "`-C symbol-mangling-version=legacy` requires `-Z unstable-options`",
2634 );
2635 }
2636 }
2637 Some(SymbolManglingVersion::Hashed) => {
2638 if !unstable_opts.unstable_options {
2639 early_dcx.early_fatal(
2640 "`-C symbol-mangling-version=hashed` requires `-Z unstable-options`",
2641 );
2642 }
2643 }
2644 }
2645
2646 if cg.instrument_coverage != InstrumentCoverage::No {
2647 if cg.profile_generate.enabled() || cg.profile_use.is_some() {
2648 early_dcx.early_fatal(
2649 "option `-C instrument-coverage` is not compatible with either `-C profile-use` \
2650 or `-C profile-generate`",
2651 );
2652 }
2653
2654 match cg.symbol_mangling_version {
2659 None => cg.symbol_mangling_version = Some(SymbolManglingVersion::V0),
2660 Some(SymbolManglingVersion::Legacy) => {
2661 early_dcx.early_warn(
2662 "-C instrument-coverage requires symbol mangling version `v0`, \
2663 but `-C symbol-mangling-version=legacy` was specified",
2664 );
2665 }
2666 Some(SymbolManglingVersion::V0) => {}
2667 Some(SymbolManglingVersion::Hashed) => {
2668 early_dcx.early_warn(
2669 "-C instrument-coverage requires symbol mangling version `v0`, \
2670 but `-C symbol-mangling-version=hashed` was specified",
2671 );
2672 }
2673 }
2674 }
2675
2676 if let Ok(graphviz_font) = std::env::var("RUSTC_GRAPHVIZ_FONT") {
2677 unstable_opts.graphviz_font = graphviz_font;
2680 }
2681
2682 if !cg.embed_bitcode {
2683 match cg.lto {
2684 LtoCli::No | LtoCli::Unspecified => {}
2685 LtoCli::Yes | LtoCli::NoParam | LtoCli::Thin | LtoCli::Fat => {
2686 early_dcx.early_fatal("options `-C embed-bitcode=no` and `-C lto` are incompatible")
2687 }
2688 }
2689 }
2690
2691 let unstable_options_enabled = nightly_options::unstable_options_enabled(matches);
2692 if !unstable_options_enabled && cg.force_frame_pointers == FramePointer::NonLeaf {
2693 early_dcx.early_fatal(
2694 "`-Cforce-frame-pointers=non-leaf` or `always` also requires `-Zunstable-options` \
2695 and a nightly compiler",
2696 )
2697 }
2698
2699 if !unstable_options_enabled && !unstable_opts.offload.is_empty() {
2700 early_dcx.early_fatal(
2701 "`-Zoffload=Enable` also requires `-Zunstable-options` and a nightly compiler",
2702 )
2703 }
2704
2705 let target_triple = parse_target_triple(early_dcx, matches);
2706
2707 if !unstable_options_enabled {
2710 if let Err(error) = cg.link_self_contained.check_unstable_variants(&target_triple) {
2711 early_dcx.early_fatal(error);
2712 }
2713
2714 if let Some(flavor) = cg.linker_flavor {
2715 if flavor.is_unstable() {
2716 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!(
2717 "the linker flavor `{}` is unstable, the `-Z unstable-options` flag must also \
2718 be passed to use the unstable values",
2719 flavor.desc()
2720 ));
2721 }
2722 }
2723 }
2724
2725 if let Some(erroneous_components) = cg.link_self_contained.check_consistency() {
2728 let names: String = erroneous_components
2729 .into_iter()
2730 .map(|c| c.as_str().unwrap())
2731 .intersperse(", ")
2732 .collect();
2733 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!(
2734 "some `-C link-self-contained` components were both enabled and disabled: {names}"
2735 ));
2736 }
2737
2738 let prints = print_request::collect_print_requests(
2739 early_dcx,
2740 &mut cg,
2741 &unstable_opts,
2742 matches,
2743 PrintCategory::ALL_VARIANTS,
2744 );
2745
2746 if unstable_opts.retpoline_external_thunk {
2748 unstable_opts.retpoline = true;
2749 collected_options.target_modifiers.insert(
2750 OptionsTargetModifiers::UnstableOptions(UnstableOptionsTargetModifiers::Retpoline),
2751 "true".to_string(),
2752 );
2753 }
2754
2755 let cg = cg;
2756
2757 let opt_level = parse_opt_level(early_dcx, matches, &cg);
2758 let debug_assertions = cg.debug_assertions.unwrap_or(opt_level == OptLevel::No);
2762 let debuginfo = select_debuginfo(matches, &cg);
2763
2764 if !unstable_options_enabled {
2765 if let Err(error) = cg.linker_features.check_unstable_variants(&target_triple) {
2766 early_dcx.early_fatal(error);
2767 }
2768 }
2769
2770 if !unstable_options_enabled && cg.panic == Some(PanicStrategy::ImmediateAbort) {
2771 early_dcx.early_fatal(
2772 "`-Cpanic=immediate-abort` requires `-Zunstable-options` and a nightly compiler",
2773 )
2774 }
2775
2776 let libs = parse_native_libs(early_dcx, &unstable_opts, &unstable_features, matches);
2778
2779 let test = matches.opt_present("test");
2780
2781 if !cg.remark.is_empty() && debuginfo == DebugInfo::None {
2782 early_dcx.early_warn("-C remark requires \"-C debuginfo=n\" to show source locations");
2783 }
2784
2785 if cg.remark.is_empty() && unstable_opts.remark_dir.is_some() {
2786 early_dcx
2787 .early_warn("using -Z remark-dir without enabling remarks using e.g. -C remark=all");
2788 }
2789
2790 if cg.embed_metadata.is_some() && unstable_opts.embed_metadata.is_some() {
2791 early_dcx.early_fatal("can't use both -Z embed-metadata and -C embed-metadata");
2792 }
2793
2794 let externs = parse_externs(early_dcx, matches, &unstable_opts);
2795
2796 let remap_path_prefix = parse_remap_path_prefix(early_dcx, matches);
2797 let remap_path_scope = parse_remap_path_scope(early_dcx, matches, &unstable_opts);
2798
2799 let pretty = parse_pretty(early_dcx, &unstable_opts);
2800
2801 if unstable_opts.dump_dep_graph && !unstable_opts.query_dep_graph {
2803 early_dcx.early_fatal("can't dump dependency graph without `-Z query-dep-graph`");
2804 }
2805
2806 let sysroot = Sysroot::new(matches.opt_str("sysroot").map(PathBuf::from));
2807
2808 let real_source_base_dir = |suffix: &str, confirm: &str| {
2809 let mut candidate = sysroot.path().join(suffix);
2810 if let Ok(metadata) = candidate.symlink_metadata() {
2811 if metadata.file_type().is_symlink() {
2815 if let Ok(symlink_dest) = std::fs::read_link(&candidate) {
2816 candidate = symlink_dest;
2817 }
2818 }
2819 }
2820
2821 candidate.join(confirm).is_file().then_some(candidate)
2823 };
2824
2825 let real_rust_source_base_dir =
2826 real_source_base_dir("lib/rustlib/src/rust", "library/std/src/lib.rs");
2828
2829 let real_rustc_dev_source_base_dir =
2830 real_source_base_dir("lib/rustlib/rustc-src/rust", "compiler/rustc/src/main.rs");
2832
2833 let search_paths: Vec<SearchPath> = {
2838 let mut seen_search_paths = FxHashSet::default();
2839 let search_path_matches: Vec<String> = matches.opt_strs("L");
2840 search_path_matches
2841 .iter()
2842 .filter(|p| seen_search_paths.insert(*p))
2843 .map(|path| {
2844 SearchPath::from_cli_opt(
2845 sysroot.path(),
2846 &target_triple,
2847 early_dcx,
2848 &path,
2849 unstable_opts.unstable_options,
2850 )
2851 })
2852 .collect()
2853 };
2854
2855 let working_dir = {
2858 let working_dir = std::env::current_dir().unwrap_or_else(|e| {
2859 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}"));
2860 });
2861
2862 let file_mapping = file_path_mapping(
2863 remap_path_prefix.clone(),
2864 unstable_opts.remap_cwd_prefix.as_deref(),
2865 remap_path_scope,
2866 );
2867 file_mapping.to_real_filename(&RealFileName::empty(), &working_dir)
2868 };
2869
2870 let verbose = matches.opt_present("verbose") || unstable_opts.verbose_internals;
2871
2872 let jobs = parse_jobs_all(
2873 early_dcx,
2874 matches,
2875 unstable_opts.threads.as_deref(),
2876 unstable_opts.no_parallel_backend,
2877 unstable_opts.unstable_options,
2878 );
2879
2880 Options {
2881 crate_types,
2882 optimize: opt_level,
2883 debuginfo,
2884 lint_opts,
2885 lint_cap,
2886 describe_lints,
2887 output_types,
2888 search_paths,
2889 sysroot,
2890 target_triple,
2891 test,
2892 incremental,
2893 unstable_opts,
2894 prints,
2895 cg,
2896 error_format,
2897 diagnostic_width,
2898 externs,
2899 unstable_features,
2900 crate_name,
2901 libs,
2902 debug_assertions,
2903 actually_rustdoc: false,
2904 resolve_doc_links: ResolveDocLinks::ExportedMetadata,
2905 trimmed_def_paths: false,
2906 cli_forced_codegen_units: codegen_units,
2907 cli_forced_local_thinlto_off: disable_local_thinlto,
2908 remap_path_prefix,
2909 remap_path_scope,
2910 real_rust_source_base_dir,
2911 real_rustc_dev_source_base_dir,
2912 edition,
2913 json_artifact_notifications,
2914 json_timings,
2915 json_unused_externs,
2916 json_future_incompat,
2917 pretty,
2918 working_dir,
2919 color,
2920 verbose,
2921 target_modifiers: collected_options.target_modifiers,
2922 mitigation_coverage_map: collected_options.mitigations,
2923 jobs,
2924 recommended_stack_size: DEFAULT_STACK_SIZE,
2925 }
2926}
2927
2928fn parse_pretty(early_dcx: &EarlyDiagCtxt, unstable_opts: &UnstableOptions) -> Option<PpMode> {
2929 use PpMode::*;
2930
2931 let first = match unstable_opts.unpretty.as_deref()? {
2932 "normal" => Source(PpSourceMode::Normal),
2933 "expanded" => Source(PpSourceMode::Expanded),
2934 "expanded,identified" => Source(PpSourceMode::ExpandedIdentified),
2935 "expanded,hygiene" => Source(PpSourceMode::ExpandedHygiene),
2936 "ast-tree" => AstTree,
2937 "ast-tree,expanded" => AstTreeExpanded,
2938 "hir" => Hir(PpHirMode::Normal),
2939 "hir,identified" => Hir(PpHirMode::Identified),
2940 "hir,typed" => Hir(PpHirMode::Typed),
2941 "hir-tree" => HirTree,
2942 "thir-tree" => ThirTree,
2943 "thir-flat" => ThirFlat,
2944 "mir" => Mir,
2945 "stable-mir" => StableMir,
2946 "mir-cfg" => MirCFG,
2947 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!(
2948 "argument to `unpretty` must be one of `normal`, \
2949 `expanded`, `expanded,identified`, `expanded,hygiene`, \
2950 `ast-tree`, `ast-tree,expanded`, `hir`, `hir,identified`, \
2951 `hir,typed`, `hir-tree`, `thir-tree`, `thir-flat`, `mir`, `stable-mir`, or \
2952 `mir-cfg`; got {name}"
2953 )),
2954 };
2955 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6c709eb428d472a3c3d93681c1ba37d44a1c27cf/compiler/rustc_session/src/config.rs:2955",
"rustc_session::config", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6c709eb428d472a3c3d93681c1ba37d44a1c27cf/compiler/rustc_session/src/config.rs"),
::tracing_core::__macro_support::Option::Some(2955u32),
::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:?}");
2956 Some(first)
2957}
2958
2959pub fn make_crate_type_option() -> RustcOptGroup {
2960 make_opt(
2961 OptionStability::Stable,
2962 OptionKind::Multi,
2963 "",
2964 "crate-type",
2965 "Comma separated list of types of crates
2966 for the compiler to emit",
2967 "<bin|lib|rlib|dylib|cdylib|staticlib|proc-macro>",
2968 )
2969}
2970
2971pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateType>, String> {
2972 let mut crate_types: Vec<CrateType> = Vec::new();
2973 for unparsed_crate_type in &list_list {
2974 for part in unparsed_crate_type.split(',') {
2975 let new_part = match part {
2976 "lib" => CrateType::default(),
2977 "rlib" => CrateType::Rlib,
2978 "staticlib" => CrateType::StaticLib,
2979 "dylib" => CrateType::Dylib,
2980 "cdylib" => CrateType::Cdylib,
2981 "bin" => CrateType::Executable,
2982 "proc-macro" => CrateType::ProcMacro,
2983 "sdylib" => CrateType::Sdylib,
2984 _ => {
2985 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!(
2986 "unknown crate type: `{part}`, expected one of: \
2987 `lib`, `rlib`, `staticlib`, `dylib`, `cdylib`, `bin`, `proc-macro`",
2988 ));
2989 }
2990 };
2991 if !crate_types.contains(&new_part) {
2992 crate_types.push(new_part)
2993 }
2994 }
2995 }
2996
2997 Ok(crate_types)
2998}
2999
3000pub mod nightly_options {
3001 use rustc_feature::UnstableFeatures;
3002
3003 use super::{OptionStability, RustcOptGroup};
3004 use crate::EarlyDiagCtxt;
3005
3006 pub fn unstable_options_enabled(matches: &getopts::Matches) -> bool {
3008 let unstable_features =
3009 UnstableFeatures::from_environment(matches.opt_str("crate-name").as_deref());
3010 unstable_features.allow_unstable_compiler_flag("unstable-options")
3011 && matches.opt_strs("Z").iter().any(|x| *x == "unstable-options")
3012 }
3013
3014 pub fn match_is_nightly_build(matches: &getopts::Matches) -> bool {
3015 let krate = matches.opt_str("crate-name");
3016 UnstableFeatures::from_environment(krate.as_deref()).is_nightly_build()
3017 }
3018
3019 pub fn check_nightly_options(
3020 early_dcx: &EarlyDiagCtxt,
3021 matches: &getopts::Matches,
3022 flags: &[RustcOptGroup],
3023 ) {
3024 let has_z_unstable_option = matches.opt_strs("Z").iter().any(|x| *x == "unstable-options");
3025 let unstable_features =
3026 UnstableFeatures::from_environment(matches.opt_str("crate-name").as_deref());
3027 let mut nightly_options_on_stable = 0;
3028
3029 for opt in flags.iter() {
3030 if opt.stability == OptionStability::Stable {
3031 continue;
3032 }
3033 if !matches.opt_present(opt.name) {
3034 continue;
3035 }
3036 if opt.name != "Z" && !has_z_unstable_option {
3037 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!(
3038 "the `-Z unstable-options` flag must also be passed to enable \
3039 the flag `{}`",
3040 opt.name
3041 ));
3042 }
3043
3044 if opt.name == "Z" {
3048 let values = matches.opt_strs(opt.name);
3052 let disallowed_flags = values
3053 .iter()
3054 .map(|flag| flag.split_once("=").map(|(k, _)| k).unwrap_or(flag))
3055 .filter(|flag| !unstable_features.allow_unstable_compiler_flag(flag))
3056 .collect::<Vec<_>>();
3057 if disallowed_flags.is_empty() {
3058 continue;
3059 }
3060
3061 if #[allow(non_exhaustive_omitted_patterns)] match unstable_features {
UnstableFeatures::AllowSelectedUnstableCompilerFlagsOnly { .. } => true,
_ => false,
}matches!(
3067 unstable_features,
3068 UnstableFeatures::AllowSelectedUnstableCompilerFlagsOnly { .. }
3069 ) {
3070 for flag in disallowed_flags {
3071 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`"));
3072 }
3073 }
3074 } else if unstable_features.allow_unstable_compiler_flag(opt.name) {
3075 continue;
3076 }
3077
3078 nightly_options_on_stable += 1;
3079 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);
3080 let _ = early_dcx.early_err(msg);
3082 }
3083
3084 if nightly_options_on_stable > 0 {
3085 let (s, were) = if nightly_options_on_stable > 1 { ("s", "were") } else { ("", "was") };
3086 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!(
3087 "{nightly_options_on_stable} nightly option{s} {were} parsed",
3088 ));
3089 err.help("consider switching to a nightly toolchain: `rustup default nightly`");
3090 err.note(
3091 "selecting a toolchain with `+toolchain` arguments require a rustup proxy; \
3092 see <https://rust-lang.github.io/rustup/concepts/index.html>",
3093 );
3094 err.note(
3095 "for more information about Rust's stability policy, see \
3096 <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html#unstable-features>",
3097 );
3098 err.emit();
3099 }
3100 }
3101}
3102
3103#[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]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
3104pub enum PpSourceMode {
3105 Normal,
3107 Expanded,
3109 ExpandedIdentified,
3111 ExpandedHygiene,
3113}
3114
3115#[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]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
3116pub enum PpHirMode {
3117 Normal,
3119 Identified,
3121 Typed,
3123}
3124
3125#[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]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
3126pub enum PpMode {
3128 Source(PpSourceMode),
3131 AstTree,
3133 AstTreeExpanded,
3135 Hir(PpHirMode),
3137 HirTree,
3139 ThirTree,
3141 ThirFlat,
3143 Mir,
3145 MirCFG,
3147 StableMir,
3149}
3150
3151impl PpMode {
3152 pub fn needs_ast_map(&self) -> bool {
3153 use PpMode::*;
3154 use PpSourceMode::*;
3155 match *self {
3156 Source(Normal) | AstTree => false,
3157
3158 Source(Expanded | ExpandedIdentified | ExpandedHygiene)
3159 | AstTreeExpanded
3160 | Hir(_)
3161 | HirTree
3162 | ThirTree
3163 | ThirFlat
3164 | Mir
3165 | MirCFG
3166 | StableMir => true,
3167 }
3168 }
3169
3170 pub fn needs_analysis(&self) -> bool {
3171 use PpMode::*;
3172 #[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)
3173 }
3174}
3175
3176#[derive(#[automatically_derived]impl ::core::clone::Clone for LlvmTpde {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
match self {
Self::Try => LlvmTpde::Try,
Self::Only => LlvmTpde::Only,
}
}
}Clone, #[automatically_derived]impl ::core::hash::Hash for LlvmTpde {
#[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 LlvmTpde
{
}
#[automatically_derived]impl ::core::cmp::PartialEq for LlvmTpde {
#[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 LlvmTpde { }Eq, #[automatically_derived]impl ::core::fmt::Debug for LlvmTpde {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self { LlvmTpde::Try => "Try", LlvmTpde::Only => "Only", })
}
}Debug)]
3177pub enum LlvmTpde {
3178 Try,
3180 Only,
3182}
3183
3184#[derive(#[automatically_derived]impl ::core::clone::Clone for WasiExecModel {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
3185pub enum WasiExecModel {
3186 Command,
3187 Reactor,
3188}
3189
3190pub(crate) mod dep_tracking {
3209 use std::collections::BTreeMap;
3210 use std::hash::Hash;
3211 use std::num::NonZero;
3212 use std::path::PathBuf;
3213
3214 use rustc_abi::{Align, PackCoroutineLayout};
3215 use rustc_ast::attr::version::RustcVersion;
3216 use rustc_data_structures::fx::FxIndexMap;
3217 use rustc_data_structures::stable_hash::{DummyStableHashCtxt, StableHash, StableHasher};
3218 use rustc_errors::LanguageIdentifier;
3219 use rustc_feature::UnstableFeatures;
3220 use rustc_hashes::Hash64;
3221 use rustc_span::edition::Edition;
3222 use rustc_span::{RealFileName, RemapPathScopeComponents};
3223 use rustc_structures::CollapseMacroDebuginfo;
3224 use rustc_target::spec::{
3225 CodeModel, FramePointer, MergeFunctions, OnBrokenPipe, PanicStrategy, RelocModel,
3226 RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, SymbolVisibility, TargetTuple,
3227 TlsModel,
3228 };
3229
3230 use super::{
3231 AnnotateMoves, AutoDiff, BranchProtection, CFGuard, CFProtection, CodegenRetagOptions,
3232 CoverageOptions, CrateType, DebugInfo, DebugInfoCompression, ErrorOutputType, FmtDebug,
3233 FunctionReturn, InliningThreshold, InstrumentCoverage, InstrumentMcount,
3234 InstrumentMcountOpts, InstrumentXRay, LinkerPluginLto, LlvmTpde, LocationDetail, LtoCli,
3235 MirStripDebugInfo, NextSolverConfig, Offload, OptLevel, OutFileName, OutputType,
3236 OutputTypes, PatchableFunctionEntry, PointerAuthOption, Polonius, ResolveDocLinks,
3237 SourceFileHashAlgorithm, SplitDwarfKind, SwitchWithOptPath, SymbolManglingVersion,
3238 WasiExecModel,
3239 };
3240 use crate::lint;
3241 use crate::utils::NativeLib;
3242
3243 pub(crate) trait DepTrackingHash {
3244 fn hash(
3245 &self,
3246 hasher: &mut StableHasher,
3247 error_format: ErrorOutputType,
3248 for_crate_hash: bool,
3249 );
3250 }
3251
3252 macro_rules! impl_dep_tracking_hash_via_hash {
3253 ($($t:ty),+ $(,)?) => {$(
3254 impl DepTrackingHash for $t {
3255 fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType, _for_crate_hash: bool) {
3256 Hash::hash(self, hasher);
3257 }
3258 }
3259 )+};
3260 }
3261
3262 impl<T: DepTrackingHash> DepTrackingHash for Option<T> {
3263 fn hash(
3264 &self,
3265 hasher: &mut StableHasher,
3266 error_format: ErrorOutputType,
3267 for_crate_hash: bool,
3268 ) {
3269 match self {
3270 Some(x) => {
3271 Hash::hash(&1, hasher);
3272 DepTrackingHash::hash(x, hasher, error_format, for_crate_hash);
3273 }
3274 None => Hash::hash(&0, hasher),
3275 }
3276 }
3277 }
3278
3279 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 LlvmTpde {
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 PackCoroutineLayout {
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!(
3280 (),
3282 Align,
3283 AnnotateMoves,
3284 AutoDiff,
3285 BranchProtection,
3286 CFGuard,
3287 CFProtection,
3288 CodeModel,
3289 CodegenRetagOptions,
3290 CollapseMacroDebuginfo,
3291 CoverageOptions,
3292 CrateType,
3293 DebugInfo,
3294 DebugInfoCompression,
3295 Edition,
3296 FmtDebug,
3297 FramePointer,
3298 FunctionReturn,
3299 Hash64,
3300 InliningThreshold,
3301 InstrumentCoverage,
3302 InstrumentMcount,
3303 InstrumentMcountOpts,
3304 InstrumentXRay,
3305 LanguageIdentifier,
3306 LinkerPluginLto,
3307 LlvmTpde,
3308 LocationDetail,
3309 LtoCli,
3310 MergeFunctions,
3311 MirStripDebugInfo,
3312 NativeLib,
3313 NextSolverConfig,
3314 NonZero<usize>,
3315 Offload,
3316 OnBrokenPipe,
3317 OptLevel,
3318 OutFileName,
3319 OutputType,
3320 PackCoroutineLayout,
3321 PanicStrategy,
3322 PatchableFunctionEntry,
3323 PointerAuthOption,
3324 Polonius,
3325 RelocModel,
3326 RelroLevel,
3327 RemapPathScopeComponents,
3328 ResolveDocLinks,
3329 RustcVersion,
3330 SanitizerSet,
3331 SourceFileHashAlgorithm,
3332 SplitDebuginfo,
3333 SplitDwarfKind,
3334 StackProtector,
3335 String,
3336 SwitchWithOptPath,
3337 SymbolManglingVersion,
3338 SymbolVisibility,
3339 TargetTuple,
3340 TlsModel,
3341 UnstableFeatures,
3342 WasiExecModel,
3343 bool,
3344 lint::Level,
3345 u32,
3346 u64,
3347 usize,
3348 );
3350
3351 impl<T1, T2> DepTrackingHash for (T1, T2)
3352 where
3353 T1: DepTrackingHash,
3354 T2: DepTrackingHash,
3355 {
3356 fn hash(
3357 &self,
3358 hasher: &mut StableHasher,
3359 error_format: ErrorOutputType,
3360 for_crate_hash: bool,
3361 ) {
3362 Hash::hash(&0, hasher);
3363 DepTrackingHash::hash(&self.0, hasher, error_format, for_crate_hash);
3364 Hash::hash(&1, hasher);
3365 DepTrackingHash::hash(&self.1, hasher, error_format, for_crate_hash);
3366 }
3367 }
3368
3369 impl<T1, T2, T3> DepTrackingHash for (T1, T2, T3)
3370 where
3371 T1: DepTrackingHash,
3372 T2: DepTrackingHash,
3373 T3: DepTrackingHash,
3374 {
3375 fn hash(
3376 &self,
3377 hasher: &mut StableHasher,
3378 error_format: ErrorOutputType,
3379 for_crate_hash: bool,
3380 ) {
3381 Hash::hash(&0, hasher);
3382 DepTrackingHash::hash(&self.0, hasher, error_format, for_crate_hash);
3383 Hash::hash(&1, hasher);
3384 DepTrackingHash::hash(&self.1, hasher, error_format, for_crate_hash);
3385 Hash::hash(&2, hasher);
3386 DepTrackingHash::hash(&self.2, hasher, error_format, for_crate_hash);
3387 }
3388 }
3389
3390 impl<T: DepTrackingHash> DepTrackingHash for Vec<T> {
3391 fn hash(
3392 &self,
3393 hasher: &mut StableHasher,
3394 error_format: ErrorOutputType,
3395 for_crate_hash: bool,
3396 ) {
3397 Hash::hash(&self.len(), hasher);
3398 for (index, elem) in self.iter().enumerate() {
3399 Hash::hash(&index, hasher);
3400 DepTrackingHash::hash(elem, hasher, error_format, for_crate_hash);
3401 }
3402 }
3403 }
3404
3405 impl<T: DepTrackingHash, V: DepTrackingHash> DepTrackingHash for FxIndexMap<T, V> {
3406 fn hash(
3407 &self,
3408 hasher: &mut StableHasher,
3409 error_format: ErrorOutputType,
3410 for_crate_hash: bool,
3411 ) {
3412 Hash::hash(&self.len(), hasher);
3413 for (key, value) in self.iter() {
3414 DepTrackingHash::hash(key, hasher, error_format, for_crate_hash);
3415 DepTrackingHash::hash(value, hasher, error_format, for_crate_hash);
3416 }
3417 }
3418 }
3419
3420 impl DepTrackingHash for OutputTypes {
3421 fn hash(
3422 &self,
3423 hasher: &mut StableHasher,
3424 error_format: ErrorOutputType,
3425 for_crate_hash: bool,
3426 ) {
3427 Hash::hash(&self.0.len(), hasher);
3428 for (key, val) in &self.0 {
3429 DepTrackingHash::hash(key, hasher, error_format, for_crate_hash);
3430 if !for_crate_hash {
3431 DepTrackingHash::hash(val, hasher, error_format, for_crate_hash);
3432 }
3433 }
3434 }
3435 }
3436
3437 impl DepTrackingHash for PathBuf {
3438 fn hash(
3439 &self,
3440 hasher: &mut StableHasher,
3441 _error_format: ErrorOutputType,
3442 _for_crate_hash: bool,
3443 ) {
3444 self.stable_hash(&mut DummyStableHashCtxt, hasher);
3445 }
3446 }
3447
3448 impl DepTrackingHash for RealFileName {
3449 fn hash(
3450 &self,
3451 hasher: &mut StableHasher,
3452 _error_format: ErrorOutputType,
3453 _for_crate_hash: bool,
3454 ) {
3455 self.stable_hash(&mut DummyStableHashCtxt, hasher);
3456 }
3457 }
3458
3459 pub(crate) fn stable_hash(
3461 sub_hashes: BTreeMap<&'static str, &dyn DepTrackingHash>,
3462 hasher: &mut StableHasher,
3463 error_format: ErrorOutputType,
3464 for_crate_hash: bool,
3465 ) {
3466 for (key, sub_hash) in sub_hashes {
3467 Hash::hash(&key.len(), hasher);
3470 Hash::hash(key, hasher);
3471 sub_hash.hash(hasher, error_format, for_crate_hash);
3472 }
3473 }
3474}
3475
3476#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for ProcMacroExecutionStrategy {
}
#[automatically_derived]impl ::core::clone::Clone for
ProcMacroExecutionStrategy {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
3478pub enum ProcMacroExecutionStrategy {
3479 SameThread,
3481
3482 CrossThread,
3484}
3485
3486#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for DumpMonoStatsFormat {
}
#[automatically_derived]impl ::core::clone::Clone for DumpMonoStatsFormat {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
3488pub enum DumpMonoStatsFormat {
3489 Markdown,
3491 Json,
3493}
3494
3495impl DumpMonoStatsFormat {
3496 pub fn extension(self) -> &'static str {
3497 match self {
3498 Self::Markdown => "md",
3499 Self::Json => "json",
3500 }
3501 }
3502}
3503
3504#[derive(#[automatically_derived]impl ::core::clone::Clone for PatchableFunctionEntry {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
3507pub struct PatchableFunctionEntry {
3508 prefix: u8,
3510 entry: u8,
3512 section: Option<String>,
3514}
3515
3516impl PatchableFunctionEntry {
3517 pub fn from_parts(
3518 total_nops: u8,
3519 prefix_nops: u8,
3520 section: Option<String>,
3521 ) -> Option<PatchableFunctionEntry> {
3522 if total_nops < prefix_nops {
3523 None
3524 } else if section.as_ref().map(|x| x.contains('\0') || x.is_empty()).unwrap_or(false) {
3526 None
3527 } else {
3528 Some(Self { prefix: prefix_nops, entry: total_nops - prefix_nops, section })
3529 }
3530 }
3531 pub fn prefix(&self) -> u8 {
3532 self.prefix
3533 }
3534 pub fn entry(&self) -> u8 {
3535 self.entry
3536 }
3537 pub fn section(&self) -> Option<&str> {
3538 self.section.as_ref().map(|x| x.as_str())
3539 }
3540}
3541
3542#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for Polonius {
}
#[automatically_derived]impl ::core::clone::Clone for Polonius {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
3545pub enum Polonius {
3546 Off,
3548
3549 Legacy,
3551
3552 Next,
3554}
3555
3556impl Default for Polonius {
3557 fn default() -> Self {
3558 Self::DEFAULT
3559 }
3560}
3561
3562impl Polonius {
3563 pub(crate) const DEFAULT: Self =
3564 if ::core::option::Option::Some("1")option_env!("CFG_DEFAULT_POLONIUS_NEXT").is_some() { Self::Next } else { Self::Off };
3565
3566 pub fn is_legacy_enabled(&self) -> bool {
3568 #[allow(non_exhaustive_omitted_patterns)] match self {
Polonius::Legacy => true,
_ => false,
}matches!(self, Polonius::Legacy)
3569 }
3570
3571 pub fn is_next_enabled(&self) -> bool {
3573 #[allow(non_exhaustive_omitted_patterns)] match self {
Polonius::Next => true,
_ => false,
}matches!(self, Polonius::Next)
3574 }
3575}
3576
3577#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for InliningThreshold {
}
#[automatically_derived]impl ::core::clone::Clone for InliningThreshold {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
3578pub enum InliningThreshold {
3579 Always,
3580 Sometimes(usize),
3581 Never,
3582}
3583
3584impl Default for InliningThreshold {
3585 fn default() -> Self {
3586 Self::Sometimes(100)
3587 }
3588}
3589
3590#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for FunctionReturn {
}
#[automatically_derived]impl ::core::clone::Clone for FunctionReturn {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
3592pub enum FunctionReturn {
3593 #[default]
3595 Keep,
3596
3597 ThunkExtern,
3599}
3600
3601#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for MirIncludeSpans {
}
#[automatically_derived]impl ::core::clone::Clone for MirIncludeSpans {
#[inline]
#[rustc_trivial_field_reads]
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]
#[rustc_trivial_field_reads]
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)]
3604pub enum MirIncludeSpans {
3605 Off,
3606 On,
3607 #[default]
3610 Nll,
3611}
3612
3613impl MirIncludeSpans {
3614 pub fn is_enabled(self) -> bool {
3619 self == MirIncludeSpans::On
3620 }
3621}