Auto merge of #118472 - nnethercote:rustc_session, r=bjorn3
`rustc_session` cleanups r? `@bjorn3`
This commit is contained in:
commit
1d726a2be0
16 changed files with 89 additions and 120 deletions
|
@ -12,9 +12,9 @@ use object::{
|
||||||
|
|
||||||
use rustc_data_structures::memmap::Mmap;
|
use rustc_data_structures::memmap::Mmap;
|
||||||
use rustc_data_structures::owned_slice::{try_slice_owned, OwnedSlice};
|
use rustc_data_structures::owned_slice::{try_slice_owned, OwnedSlice};
|
||||||
|
use rustc_metadata::creader::MetadataLoader;
|
||||||
use rustc_metadata::fs::METADATA_FILENAME;
|
use rustc_metadata::fs::METADATA_FILENAME;
|
||||||
use rustc_metadata::EncodedMetadata;
|
use rustc_metadata::EncodedMetadata;
|
||||||
use rustc_session::cstore::MetadataLoader;
|
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
use rustc_span::sym;
|
use rustc_span::sym;
|
||||||
use rustc_target::abi::Endian;
|
use rustc_target::abi::Endian;
|
||||||
|
|
|
@ -9,6 +9,7 @@ use rustc_ast::expand::allocator::AllocatorKind;
|
||||||
use rustc_data_structures::fx::FxIndexMap;
|
use rustc_data_structures::fx::FxIndexMap;
|
||||||
use rustc_data_structures::sync::{DynSend, DynSync};
|
use rustc_data_structures::sync::{DynSend, DynSync};
|
||||||
use rustc_errors::ErrorGuaranteed;
|
use rustc_errors::ErrorGuaranteed;
|
||||||
|
use rustc_metadata::creader::MetadataLoaderDyn;
|
||||||
use rustc_metadata::EncodedMetadata;
|
use rustc_metadata::EncodedMetadata;
|
||||||
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
|
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
|
||||||
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf, TyAndLayout};
|
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf, TyAndLayout};
|
||||||
|
@ -16,7 +17,6 @@ use rustc_middle::ty::{Ty, TyCtxt};
|
||||||
use rustc_middle::util::Providers;
|
use rustc_middle::util::Providers;
|
||||||
use rustc_session::{
|
use rustc_session::{
|
||||||
config::{self, OutputFilenames, PrintRequest},
|
config::{self, OutputFilenames, PrintRequest},
|
||||||
cstore::MetadataLoaderDyn,
|
|
||||||
Session,
|
Session,
|
||||||
};
|
};
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
|
|
|
@ -33,10 +33,10 @@ use rustc_feature::find_gated_cfg;
|
||||||
use rustc_interface::util::{self, collect_crate_types, get_codegen_backend};
|
use rustc_interface::util::{self, collect_crate_types, get_codegen_backend};
|
||||||
use rustc_interface::{interface, Queries};
|
use rustc_interface::{interface, Queries};
|
||||||
use rustc_lint::unerased_lint_store;
|
use rustc_lint::unerased_lint_store;
|
||||||
|
use rustc_metadata::creader::MetadataLoader;
|
||||||
use rustc_metadata::locator;
|
use rustc_metadata::locator;
|
||||||
use rustc_session::config::{nightly_options, CG_OPTIONS, Z_OPTIONS};
|
use rustc_session::config::{nightly_options, CG_OPTIONS, Z_OPTIONS};
|
||||||
use rustc_session::config::{ErrorOutputType, Input, OutFileName, OutputType, TrimmedDefPaths};
|
use rustc_session::config::{ErrorOutputType, Input, OutFileName, OutputType, TrimmedDefPaths};
|
||||||
use rustc_session::cstore::MetadataLoader;
|
|
||||||
use rustc_session::getopts::{self, Matches};
|
use rustc_session::getopts::{self, Matches};
|
||||||
use rustc_session::lint::{Lint, LintId};
|
use rustc_session::lint::{Lint, LintId};
|
||||||
use rustc_session::{config, EarlyErrorHandler, Session};
|
use rustc_session::{config, EarlyErrorHandler, Session};
|
||||||
|
|
|
@ -262,7 +262,7 @@ pub(crate) fn prepare_session_directory(
|
||||||
directory."
|
directory."
|
||||||
);
|
);
|
||||||
|
|
||||||
sess.init_incr_comp_session(session_dir, directory_lock, false);
|
sess.init_incr_comp_session(session_dir, directory_lock);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ pub(crate) fn prepare_session_directory(
|
||||||
sess.emit_warning(errors::HardLinkFailed { path: &session_dir });
|
sess.emit_warning(errors::HardLinkFailed { path: &session_dir });
|
||||||
}
|
}
|
||||||
|
|
||||||
sess.init_incr_comp_session(session_dir, directory_lock, true);
|
sess.init_incr_comp_session(session_dir, directory_lock);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
} else {
|
} else {
|
||||||
debug!("copying failed - trying next directory");
|
debug!("copying failed - trying next directory");
|
||||||
|
|
|
@ -7,8 +7,9 @@ use crate::rmeta::{CrateDep, CrateMetadata, CrateNumMap, CrateRoot, MetadataBlob
|
||||||
use rustc_ast::expand::allocator::{alloc_error_handler_name, global_fn_name, AllocatorKind};
|
use rustc_ast::expand::allocator::{alloc_error_handler_name, global_fn_name, AllocatorKind};
|
||||||
use rustc_ast::{self as ast, *};
|
use rustc_ast::{self as ast, *};
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
|
use rustc_data_structures::owned_slice::OwnedSlice;
|
||||||
use rustc_data_structures::svh::Svh;
|
use rustc_data_structures::svh::Svh;
|
||||||
use rustc_data_structures::sync::{FreezeReadGuard, FreezeWriteGuard};
|
use rustc_data_structures::sync::{self, FreezeReadGuard, FreezeWriteGuard};
|
||||||
use rustc_expand::base::SyntaxExtension;
|
use rustc_expand::base::SyntaxExtension;
|
||||||
use rustc_fs_util::try_canonicalize;
|
use rustc_fs_util::try_canonicalize;
|
||||||
use rustc_hir::def_id::{CrateNum, LocalDefId, StableCrateId, StableCrateIdMap, LOCAL_CRATE};
|
use rustc_hir::def_id::{CrateNum, LocalDefId, StableCrateId, StableCrateIdMap, LOCAL_CRATE};
|
||||||
|
@ -16,16 +17,14 @@ use rustc_hir::definitions::Definitions;
|
||||||
use rustc_index::IndexVec;
|
use rustc_index::IndexVec;
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_session::config::{self, CrateType, ExternLocation};
|
use rustc_session::config::{self, CrateType, ExternLocation};
|
||||||
use rustc_session::cstore::{
|
use rustc_session::cstore::{CrateDepKind, CrateSource, ExternCrate, ExternCrateSource};
|
||||||
CrateDepKind, CrateSource, ExternCrate, ExternCrateSource, MetadataLoaderDyn,
|
|
||||||
};
|
|
||||||
use rustc_session::lint;
|
use rustc_session::lint;
|
||||||
use rustc_session::output::validate_crate_name;
|
use rustc_session::output::validate_crate_name;
|
||||||
use rustc_session::search_paths::PathKind;
|
use rustc_session::search_paths::PathKind;
|
||||||
use rustc_span::edition::Edition;
|
use rustc_span::edition::Edition;
|
||||||
use rustc_span::symbol::{sym, Symbol};
|
use rustc_span::symbol::{sym, Symbol};
|
||||||
use rustc_span::{Span, DUMMY_SP};
|
use rustc_span::{Span, DUMMY_SP};
|
||||||
use rustc_target::spec::{PanicStrategy, TargetTriple};
|
use rustc_target::spec::{PanicStrategy, Target, TargetTriple};
|
||||||
|
|
||||||
use proc_macro::bridge::client::ProcMacro;
|
use proc_macro::bridge::client::ProcMacro;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
@ -34,6 +33,17 @@ use std::path::Path;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use std::{cmp, iter};
|
use std::{cmp, iter};
|
||||||
|
|
||||||
|
/// The backend's way to give the crate store access to the metadata in a library.
|
||||||
|
/// Note that it returns the raw metadata bytes stored in the library file, whether
|
||||||
|
/// it is compressed, uncompressed, some weird mix, etc.
|
||||||
|
/// rmeta files are backend independent and not handled here.
|
||||||
|
pub trait MetadataLoader {
|
||||||
|
fn get_rlib_metadata(&self, target: &Target, filename: &Path) -> Result<OwnedSlice, String>;
|
||||||
|
fn get_dylib_metadata(&self, target: &Target, filename: &Path) -> Result<OwnedSlice, String>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type MetadataLoaderDyn = dyn MetadataLoader + Send + Sync + sync::DynSend + sync::DynSync;
|
||||||
|
|
||||||
pub struct CStore {
|
pub struct CStore {
|
||||||
metadata_loader: Box<MetadataLoaderDyn>,
|
metadata_loader: Box<MetadataLoaderDyn>,
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,7 @@
|
||||||
//! no means all of the necessary details. Take a look at the rest of
|
//! no means all of the necessary details. Take a look at the rest of
|
||||||
//! metadata::locator or metadata::creader for all the juicy details!
|
//! metadata::locator or metadata::creader for all the juicy details!
|
||||||
|
|
||||||
use crate::creader::Library;
|
use crate::creader::{Library, MetadataLoader};
|
||||||
use crate::errors;
|
use crate::errors;
|
||||||
use crate::rmeta::{rustc_version, MetadataBlob, METADATA_HEADER};
|
use crate::rmeta::{rustc_version, MetadataBlob, METADATA_HEADER};
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ use rustc_data_structures::svh::Svh;
|
||||||
use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
|
use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
|
||||||
use rustc_fs_util::try_canonicalize;
|
use rustc_fs_util::try_canonicalize;
|
||||||
use rustc_session::config;
|
use rustc_session::config;
|
||||||
use rustc_session::cstore::{CrateSource, MetadataLoader};
|
use rustc_session::cstore::CrateSource;
|
||||||
use rustc_session::filesearch::FileSearch;
|
use rustc_session::filesearch::FileSearch;
|
||||||
use rustc_session::search_paths::PathKind;
|
use rustc_session::search_paths::PathKind;
|
||||||
use rustc_session::utils::CanonicalizedPath;
|
use rustc_session::utils::CanonicalizedPath;
|
||||||
|
|
|
@ -8,23 +8,19 @@ use crate::search_paths::SearchPath;
|
||||||
use crate::utils::{CanonicalizedPath, NativeLib, NativeLibKind};
|
use crate::utils::{CanonicalizedPath, NativeLib, NativeLibKind};
|
||||||
use crate::{lint, HashStableContext};
|
use crate::{lint, HashStableContext};
|
||||||
use crate::{EarlyErrorHandler, Session};
|
use crate::{EarlyErrorHandler, Session};
|
||||||
|
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
|
||||||
use rustc_data_structures::stable_hasher::{StableOrd, ToStableHashKey};
|
use rustc_data_structures::stable_hasher::{StableOrd, ToStableHashKey};
|
||||||
use rustc_target::abi::Align;
|
use rustc_errors::emitter::HumanReadableErrorType;
|
||||||
use rustc_target::spec::LinkSelfContainedComponents;
|
use rustc_errors::{ColorConfig, DiagnosticArgValue, HandlerFlags, IntoDiagnosticArg};
|
||||||
use rustc_target::spec::{PanicStrategy, RelocModel, SanitizerSet, SplitDebuginfo};
|
|
||||||
use rustc_target::spec::{Target, TargetTriple, TargetWarnings, TARGETS};
|
|
||||||
|
|
||||||
use rustc_feature::UnstableFeatures;
|
use rustc_feature::UnstableFeatures;
|
||||||
use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST, LATEST_STABLE_EDITION};
|
use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST, LATEST_STABLE_EDITION};
|
||||||
use rustc_span::source_map::FilePathMapping;
|
use rustc_span::source_map::FilePathMapping;
|
||||||
use rustc_span::symbol::{sym, Symbol};
|
use rustc_span::symbol::{sym, Symbol};
|
||||||
use rustc_span::{FileName, FileNameDisplayPreference, RealFileName, SourceFileHashAlgorithm};
|
use rustc_span::{FileName, FileNameDisplayPreference, RealFileName, SourceFileHashAlgorithm};
|
||||||
|
use rustc_target::abi::Align;
|
||||||
use rustc_errors::emitter::HumanReadableErrorType;
|
use rustc_target::spec::LinkSelfContainedComponents;
|
||||||
use rustc_errors::{ColorConfig, DiagnosticArgValue, HandlerFlags, IntoDiagnosticArg};
|
use rustc_target::spec::{PanicStrategy, RelocModel, SanitizerSet, SplitDebuginfo};
|
||||||
|
use rustc_target::spec::{Target, TargetTriple, TargetWarnings, TARGETS};
|
||||||
use std::collections::btree_map::{
|
use std::collections::btree_map::{
|
||||||
Iter as BTreeMapIter, Keys as BTreeMapKeysIter, Values as BTreeMapValuesIter,
|
Iter as BTreeMapIter, Keys as BTreeMapKeysIter, Values as BTreeMapValuesIter,
|
||||||
};
|
};
|
||||||
|
@ -1250,7 +1246,7 @@ fn default_configuration(sess: &Session) -> Cfg {
|
||||||
// NOTE: This should be kept in sync with `CheckCfg::fill_well_known` below.
|
// NOTE: This should be kept in sync with `CheckCfg::fill_well_known` below.
|
||||||
let end = &sess.target.endian;
|
let end = &sess.target.endian;
|
||||||
let arch = &sess.target.arch;
|
let arch = &sess.target.arch;
|
||||||
let wordsz = sess.target.pointer_width.to_string();
|
let wordsz = sess.target.pointer_width as u64;
|
||||||
let os = &sess.target.os;
|
let os = &sess.target.os;
|
||||||
let env = &sess.target.env;
|
let env = &sess.target.env;
|
||||||
let abi = &sess.target.abi;
|
let abi = &sess.target.abi;
|
||||||
|
@ -1277,7 +1273,7 @@ fn default_configuration(sess: &Session) -> Cfg {
|
||||||
}
|
}
|
||||||
ret.insert((sym::target_arch, Some(Symbol::intern(arch))));
|
ret.insert((sym::target_arch, Some(Symbol::intern(arch))));
|
||||||
ret.insert((sym::target_endian, Some(Symbol::intern(end.as_str()))));
|
ret.insert((sym::target_endian, Some(Symbol::intern(end.as_str()))));
|
||||||
ret.insert((sym::target_pointer_width, Some(Symbol::intern(&wordsz))));
|
ret.insert((sym::target_pointer_width, Some(sym::integer(wordsz))));
|
||||||
ret.insert((sym::target_env, Some(Symbol::intern(env))));
|
ret.insert((sym::target_env, Some(Symbol::intern(env))));
|
||||||
ret.insert((sym::target_abi, Some(Symbol::intern(abi))));
|
ret.insert((sym::target_abi, Some(Symbol::intern(abi))));
|
||||||
if sess.is_nightly_build() {
|
if sess.is_nightly_build() {
|
||||||
|
@ -1297,19 +1293,18 @@ fn default_configuration(sess: &Session) -> Cfg {
|
||||||
] {
|
] {
|
||||||
if i >= min_atomic_width && i <= max_atomic_width {
|
if i >= min_atomic_width && i <= max_atomic_width {
|
||||||
has_atomic = true;
|
has_atomic = true;
|
||||||
let mut insert_atomic = |s, align: Align| {
|
let mut insert_atomic = |sym, align: Align| {
|
||||||
ret.insert((sym::target_has_atomic_load_store, Some(Symbol::intern(s))));
|
ret.insert((sym::target_has_atomic_load_store, Some(sym)));
|
||||||
if atomic_cas {
|
if atomic_cas {
|
||||||
ret.insert((sym::target_has_atomic, Some(Symbol::intern(s))));
|
ret.insert((sym::target_has_atomic, Some(sym)));
|
||||||
}
|
}
|
||||||
if align.bits() == i {
|
if align.bits() == i {
|
||||||
ret.insert((sym::target_has_atomic_equal_alignment, Some(Symbol::intern(s))));
|
ret.insert((sym::target_has_atomic_equal_alignment, Some(sym)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let s = i.to_string();
|
insert_atomic(sym::integer(i), align);
|
||||||
insert_atomic(&s, align);
|
if wordsz == i {
|
||||||
if s == wordsz {
|
insert_atomic(sym::ptr, layout.pointer_align.abi);
|
||||||
insert_atomic("ptr", layout.pointer_align.abi);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2150,25 +2145,27 @@ fn collect_print_requests(
|
||||||
}
|
}
|
||||||
|
|
||||||
const PRINT_KINDS: &[(&str, PrintKind)] = &[
|
const PRINT_KINDS: &[(&str, PrintKind)] = &[
|
||||||
("crate-name", PrintKind::CrateName),
|
// tidy-alphabetical-start
|
||||||
("file-names", PrintKind::FileNames),
|
("all-target-specs-json", PrintKind::AllTargetSpecs),
|
||||||
("sysroot", PrintKind::Sysroot),
|
|
||||||
("target-libdir", PrintKind::TargetLibdir),
|
|
||||||
("cfg", PrintKind::Cfg),
|
|
||||||
("calling-conventions", PrintKind::CallingConventions),
|
("calling-conventions", PrintKind::CallingConventions),
|
||||||
("target-list", PrintKind::TargetList),
|
("cfg", PrintKind::Cfg),
|
||||||
|
("code-models", PrintKind::CodeModels),
|
||||||
|
("crate-name", PrintKind::CrateName),
|
||||||
|
("deployment-target", PrintKind::DeploymentTarget),
|
||||||
|
("file-names", PrintKind::FileNames),
|
||||||
|
("link-args", PrintKind::LinkArgs),
|
||||||
|
("native-static-libs", PrintKind::NativeStaticLibs),
|
||||||
|
("relocation-models", PrintKind::RelocationModels),
|
||||||
|
("split-debuginfo", PrintKind::SplitDebuginfo),
|
||||||
|
("stack-protector-strategies", PrintKind::StackProtectorStrategies),
|
||||||
|
("sysroot", PrintKind::Sysroot),
|
||||||
("target-cpus", PrintKind::TargetCPUs),
|
("target-cpus", PrintKind::TargetCPUs),
|
||||||
("target-features", PrintKind::TargetFeatures),
|
("target-features", PrintKind::TargetFeatures),
|
||||||
("relocation-models", PrintKind::RelocationModels),
|
("target-libdir", PrintKind::TargetLibdir),
|
||||||
("code-models", PrintKind::CodeModels),
|
("target-list", PrintKind::TargetList),
|
||||||
("tls-models", PrintKind::TlsModels),
|
|
||||||
("native-static-libs", PrintKind::NativeStaticLibs),
|
|
||||||
("stack-protector-strategies", PrintKind::StackProtectorStrategies),
|
|
||||||
("target-spec-json", PrintKind::TargetSpec),
|
("target-spec-json", PrintKind::TargetSpec),
|
||||||
("all-target-specs-json", PrintKind::AllTargetSpecs),
|
("tls-models", PrintKind::TlsModels),
|
||||||
("link-args", PrintKind::LinkArgs),
|
// tidy-alphabetical-end
|
||||||
("split-debuginfo", PrintKind::SplitDebuginfo),
|
|
||||||
("deployment-target", PrintKind::DeploymentTarget),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// We disallow reusing the same path in multiple prints, such as `--print
|
// We disallow reusing the same path in multiple prints, such as `--print
|
||||||
|
@ -2297,14 +2294,7 @@ fn select_debuginfo(matches: &getopts::Matches, cg: &CodegenOptions) -> DebugInf
|
||||||
if max_g > max_c { DebugInfo::Full } else { cg.debuginfo }
|
if max_g > max_c { DebugInfo::Full } else { cg.debuginfo }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_debuginfo_compression(
|
fn parse_assert_incr_state(
|
||||||
_handler: &EarlyErrorHandler,
|
|
||||||
unstable_opts: &UnstableOptions,
|
|
||||||
) -> DebugInfoCompression {
|
|
||||||
unstable_opts.debuginfo_compression
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn parse_assert_incr_state(
|
|
||||||
handler: &EarlyErrorHandler,
|
handler: &EarlyErrorHandler,
|
||||||
opt_assertion: &Option<String>,
|
opt_assertion: &Option<String>,
|
||||||
) -> Option<IncrementalStateAssertion> {
|
) -> Option<IncrementalStateAssertion> {
|
||||||
|
@ -2460,6 +2450,17 @@ pub fn parse_externs(
|
||||||
matches: &getopts::Matches,
|
matches: &getopts::Matches,
|
||||||
unstable_opts: &UnstableOptions,
|
unstable_opts: &UnstableOptions,
|
||||||
) -> Externs {
|
) -> Externs {
|
||||||
|
fn is_ascii_ident(string: &str) -> bool {
|
||||||
|
let mut chars = string.chars();
|
||||||
|
if let Some(start) = chars.next()
|
||||||
|
&& (start.is_ascii_alphabetic() || start == '_')
|
||||||
|
{
|
||||||
|
chars.all(|char| char.is_ascii_alphanumeric() || char == '_')
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let is_unstable_enabled = unstable_opts.unstable_options;
|
let is_unstable_enabled = unstable_opts.unstable_options;
|
||||||
let mut externs: BTreeMap<String, ExternEntry> = BTreeMap::new();
|
let mut externs: BTreeMap<String, ExternEntry> = BTreeMap::new();
|
||||||
for arg in matches.opt_strs("extern") {
|
for arg in matches.opt_strs("extern") {
|
||||||
|
@ -2472,12 +2473,12 @@ pub fn parse_externs(
|
||||||
Some((opts, name)) => (Some(opts), name.to_string()),
|
Some((opts, name)) => (Some(opts), name.to_string()),
|
||||||
};
|
};
|
||||||
|
|
||||||
if !crate::utils::is_ascii_ident(&name) {
|
if !is_ascii_ident(&name) {
|
||||||
let mut error = handler.early_struct_error(format!(
|
let mut error = handler.early_struct_error(format!(
|
||||||
"crate name `{name}` passed to `--extern` is not a valid ASCII identifier"
|
"crate name `{name}` passed to `--extern` is not a valid ASCII identifier"
|
||||||
));
|
));
|
||||||
let adjusted_name = name.replace('-', "_");
|
let adjusted_name = name.replace('-', "_");
|
||||||
if crate::utils::is_ascii_ident(&adjusted_name) {
|
if is_ascii_ident(&adjusted_name) {
|
||||||
error.help(format!(
|
error.help(format!(
|
||||||
"consider replacing the dashes with underscores: `{adjusted_name}`"
|
"consider replacing the dashes with underscores: `{adjusted_name}`"
|
||||||
));
|
));
|
||||||
|
@ -2791,8 +2792,7 @@ pub fn build_session_options(
|
||||||
// for more details.
|
// for more details.
|
||||||
let debug_assertions = cg.debug_assertions.unwrap_or(opt_level == OptLevel::No);
|
let debug_assertions = cg.debug_assertions.unwrap_or(opt_level == OptLevel::No);
|
||||||
let debuginfo = select_debuginfo(matches, &cg);
|
let debuginfo = select_debuginfo(matches, &cg);
|
||||||
let debuginfo_compression: DebugInfoCompression =
|
let debuginfo_compression = unstable_opts.debuginfo_compression;
|
||||||
select_debuginfo_compression(handler, &unstable_opts);
|
|
||||||
|
|
||||||
let mut search_paths = vec![];
|
let mut search_paths = vec![];
|
||||||
for s in &matches.opt_strs("L") {
|
for s in &matches.opt_strs("L") {
|
||||||
|
@ -3143,6 +3143,12 @@ impl PpMode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Hash, PartialEq, Eq, Debug)]
|
||||||
|
pub enum WasiExecModel {
|
||||||
|
Command,
|
||||||
|
Reactor,
|
||||||
|
}
|
||||||
|
|
||||||
/// Command-line arguments passed to the compiler have to be incorporated with
|
/// Command-line arguments passed to the compiler have to be incorporated with
|
||||||
/// the dependency tracking system for incremental compilation. This module
|
/// the dependency tracking system for incremental compilation. This module
|
||||||
/// provides some utilities to make this more convenient.
|
/// provides some utilities to make this more convenient.
|
||||||
|
@ -3168,9 +3174,9 @@ pub(crate) mod dep_tracking {
|
||||||
LinkerPluginLto, LocationDetail, LtoCli, OomStrategy, OptLevel, OutFileName, OutputType,
|
LinkerPluginLto, LocationDetail, LtoCli, OomStrategy, OptLevel, OutFileName, OutputType,
|
||||||
OutputTypes, Polonius, RemapPathScopeComponents, ResolveDocLinks, SourceFileHashAlgorithm,
|
OutputTypes, Polonius, RemapPathScopeComponents, ResolveDocLinks, SourceFileHashAlgorithm,
|
||||||
SplitDwarfKind, SwitchWithOptPath, SymbolManglingVersion, TraitSolver, TrimmedDefPaths,
|
SplitDwarfKind, SwitchWithOptPath, SymbolManglingVersion, TraitSolver, TrimmedDefPaths,
|
||||||
|
WasiExecModel,
|
||||||
};
|
};
|
||||||
use crate::lint;
|
use crate::lint;
|
||||||
use crate::options::WasiExecModel;
|
|
||||||
use crate::utils::NativeLib;
|
use crate::utils::NativeLib;
|
||||||
use rustc_data_structures::stable_hasher::Hash64;
|
use rustc_data_structures::stable_hasher::Hash64;
|
||||||
use rustc_errors::LanguageIdentifier;
|
use rustc_errors::LanguageIdentifier;
|
||||||
|
|
|
@ -6,7 +6,6 @@ use crate::search_paths::PathKind;
|
||||||
use crate::utils::NativeLibKind;
|
use crate::utils::NativeLibKind;
|
||||||
use crate::Session;
|
use crate::Session;
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_data_structures::owned_slice::OwnedSlice;
|
|
||||||
use rustc_data_structures::sync::{self, AppendOnlyIndexVec, FreezeLock};
|
use rustc_data_structures::sync::{self, AppendOnlyIndexVec, FreezeLock};
|
||||||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, StableCrateId, LOCAL_CRATE};
|
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, StableCrateId, LOCAL_CRATE};
|
||||||
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash, Definitions};
|
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash, Definitions};
|
||||||
|
@ -14,10 +13,9 @@ use rustc_span::hygiene::{ExpnHash, ExpnId};
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_target::spec::abi::Abi;
|
||||||
use rustc_target::spec::Target;
|
|
||||||
|
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::PathBuf;
|
||||||
|
|
||||||
// lonely orphan structs and enums looking for a better home
|
// lonely orphan structs and enums looking for a better home
|
||||||
|
|
||||||
|
@ -197,21 +195,6 @@ pub enum ExternCrateSource {
|
||||||
Path,
|
Path,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The backend's way to give the crate store access to the metadata in a library.
|
|
||||||
/// Note that it returns the raw metadata bytes stored in the library file, whether
|
|
||||||
/// it is compressed, uncompressed, some weird mix, etc.
|
|
||||||
/// rmeta files are backend independent and not handled here.
|
|
||||||
///
|
|
||||||
/// At the time of this writing, there is only one backend and one way to store
|
|
||||||
/// metadata in library -- this trait just serves to decouple rustc_metadata from
|
|
||||||
/// the archive reader, which depends on LLVM.
|
|
||||||
pub trait MetadataLoader: std::fmt::Debug {
|
|
||||||
fn get_rlib_metadata(&self, target: &Target, filename: &Path) -> Result<OwnedSlice, String>;
|
|
||||||
fn get_dylib_metadata(&self, target: &Target, filename: &Path) -> Result<OwnedSlice, String>;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type MetadataLoaderDyn = dyn MetadataLoader + Send + Sync + sync::DynSend + sync::DynSync;
|
|
||||||
|
|
||||||
/// A store of Rust crates, through which their metadata can be accessed.
|
/// A store of Rust crates, through which their metadata can be accessed.
|
||||||
///
|
///
|
||||||
/// Note that this trait should probably not be expanding today. All new
|
/// Note that this trait should probably not be expanding today. All new
|
||||||
|
|
|
@ -9,12 +9,6 @@ use std::path::{Path, PathBuf};
|
||||||
use crate::search_paths::{PathKind, SearchPath};
|
use crate::search_paths::{PathKind, SearchPath};
|
||||||
use rustc_fs_util::fix_windows_verbatim_for_gcc;
|
use rustc_fs_util::fix_windows_verbatim_for_gcc;
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
pub enum FileMatch {
|
|
||||||
FileMatches,
|
|
||||||
FileDoesntMatch,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct FileSearch<'a> {
|
pub struct FileSearch<'a> {
|
||||||
sysroot: &'a Path,
|
sysroot: &'a Path,
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#![feature(if_let_guard)]
|
|
||||||
#![feature(let_chains)]
|
#![feature(let_chains)]
|
||||||
#![feature(min_specialization)]
|
|
||||||
#![feature(never_type)]
|
#![feature(never_type)]
|
||||||
#![feature(lazy_cell)]
|
#![feature(lazy_cell)]
|
||||||
#![feature(option_get_or_insert_default)]
|
#![feature(option_get_or_insert_default)]
|
||||||
|
|
|
@ -1985,9 +1985,3 @@ written to standard error output)"),
|
||||||
// - compiler/rustc_interface/src/tests.rs
|
// - compiler/rustc_interface/src/tests.rs
|
||||||
// - src/doc/unstable-book/src/compiler-flags
|
// - src/doc/unstable-book/src/compiler-flags
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Hash, PartialEq, Eq, Debug)]
|
|
||||||
pub enum WasiExecModel {
|
|
||||||
Command,
|
|
||||||
Reactor,
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//! Related to out filenames of compilation (e.g. save analysis, binaries).
|
//! Related to out filenames of compilation (e.g. binaries).
|
||||||
use crate::config::{CrateType, Input, OutFileName, OutputFilenames, OutputType};
|
use crate::config::{CrateType, Input, OutFileName, OutputFilenames, OutputType};
|
||||||
use crate::errors::{
|
use crate::errors::{
|
||||||
CrateNameDoesNotMatch, CrateNameEmpty, CrateNameInvalid, FileIsNotWriteable,
|
CrateNameDoesNotMatch, CrateNameEmpty, CrateNameInvalid, FileIsNotWriteable,
|
||||||
|
|
|
@ -214,7 +214,7 @@ pub struct ParseSess {
|
||||||
pub assume_incomplete_release: bool,
|
pub assume_incomplete_release: bool,
|
||||||
/// Spans passed to `proc_macro::quote_span`. Each span has a numerical
|
/// Spans passed to `proc_macro::quote_span`. Each span has a numerical
|
||||||
/// identifier represented by its position in the vector.
|
/// identifier represented by its position in the vector.
|
||||||
pub proc_macro_quoted_spans: AppendOnlyVec<Span>,
|
proc_macro_quoted_spans: AppendOnlyVec<Span>,
|
||||||
/// Used to generate new `AttrId`s. Every `AttrId` is unique.
|
/// Used to generate new `AttrId`s. Every `AttrId` is unique.
|
||||||
pub attr_id_generator: AttrIdGenerator,
|
pub attr_id_generator: AttrIdGenerator,
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,6 @@ use crate::parse::{add_feature_diagnostics, ParseSess};
|
||||||
use crate::search_paths::{PathKind, SearchPath};
|
use crate::search_paths::{PathKind, SearchPath};
|
||||||
use crate::{filesearch, lint};
|
use crate::{filesearch, lint};
|
||||||
|
|
||||||
pub use rustc_ast::attr::MarkedAttrs;
|
|
||||||
pub use rustc_ast::Attribute;
|
|
||||||
use rustc_data_structures::flock;
|
use rustc_data_structures::flock;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
|
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
|
||||||
use rustc_data_structures::jobserver::{self, Client};
|
use rustc_data_structures::jobserver::{self, Client};
|
||||||
|
@ -48,7 +46,7 @@ use std::path::{Path, PathBuf};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::{atomic::AtomicBool, Arc};
|
use std::sync::{atomic::AtomicBool, Arc};
|
||||||
|
|
||||||
pub struct OptimizationFuel {
|
struct OptimizationFuel {
|
||||||
/// If `-zfuel=crate=n` is specified, initially set to `n`, otherwise `0`.
|
/// If `-zfuel=crate=n` is specified, initially set to `n`, otherwise `0`.
|
||||||
remaining: u64,
|
remaining: u64,
|
||||||
/// We're rejecting all further optimizations.
|
/// We're rejecting all further optimizations.
|
||||||
|
@ -816,12 +814,7 @@ impl Session {
|
||||||
if self_contained { vec![p.clone(), p.join("self-contained")] } else { vec![p] }
|
if self_contained { vec![p.clone(), p.join("self-contained")] } else { vec![p] }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_incr_comp_session(
|
pub fn init_incr_comp_session(&self, session_dir: PathBuf, lock_file: flock::Lock) {
|
||||||
&self,
|
|
||||||
session_dir: PathBuf,
|
|
||||||
lock_file: flock::Lock,
|
|
||||||
load_dep_graph: bool,
|
|
||||||
) {
|
|
||||||
let mut incr_comp_session = self.incr_comp_session.borrow_mut();
|
let mut incr_comp_session = self.incr_comp_session.borrow_mut();
|
||||||
|
|
||||||
if let IncrCompSession::NotInitialized = *incr_comp_session {
|
if let IncrCompSession::NotInitialized = *incr_comp_session {
|
||||||
|
@ -830,7 +823,7 @@ impl Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
*incr_comp_session =
|
*incr_comp_session =
|
||||||
IncrCompSession::Active { session_directory: session_dir, lock_file, load_dep_graph };
|
IncrCompSession::Active { session_directory: session_dir, _lock_file: lock_file };
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn finalize_incr_comp_session(&self, new_directory_path: PathBuf) {
|
pub fn finalize_incr_comp_session(&self, new_directory_path: PathBuf) {
|
||||||
|
@ -1704,13 +1697,15 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
|
||||||
|
|
||||||
/// Holds data on the current incremental compilation session, if there is one.
|
/// Holds data on the current incremental compilation session, if there is one.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum IncrCompSession {
|
enum IncrCompSession {
|
||||||
/// This is the state the session will be in until the incr. comp. dir is
|
/// This is the state the session will be in until the incr. comp. dir is
|
||||||
/// needed.
|
/// needed.
|
||||||
NotInitialized,
|
NotInitialized,
|
||||||
/// This is the state during which the session directory is private and can
|
/// This is the state during which the session directory is private and can
|
||||||
/// be modified.
|
/// be modified. `_lock_file` is never directly used, but its presence
|
||||||
Active { session_directory: PathBuf, lock_file: flock::Lock, load_dep_graph: bool },
|
/// alone has an effect, because the file will unlock when the session is
|
||||||
|
/// dropped.
|
||||||
|
Active { session_directory: PathBuf, _lock_file: flock::Lock },
|
||||||
/// This is the state after the session directory has been finalized. In this
|
/// This is the state after the session directory has been finalized. In this
|
||||||
/// state, the contents of the directory must not be modified any more.
|
/// state, the contents of the directory must not be modified any more.
|
||||||
Finalized { session_directory: PathBuf },
|
Finalized { session_directory: PathBuf },
|
||||||
|
@ -1772,7 +1767,7 @@ impl EarlyErrorHandler {
|
||||||
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
#[allow(rustc::untranslatable_diagnostic)]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||||
pub(crate) fn early_struct_error(
|
pub fn early_struct_error(
|
||||||
&self,
|
&self,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'_, !> {
|
) -> DiagnosticBuilder<'_, !> {
|
||||||
|
|
|
@ -158,14 +158,3 @@ pub fn extra_compiler_flags() -> Option<(Vec<String>, bool)> {
|
||||||
|
|
||||||
if !result.is_empty() { Some((result, excluded_cargo_defaults)) } else { None }
|
if !result.is_empty() { Some((result, excluded_cargo_defaults)) } else { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn is_ascii_ident(string: &str) -> bool {
|
|
||||||
let mut chars = string.chars();
|
|
||||||
if let Some(start) = chars.next()
|
|
||||||
&& (start.is_ascii_alphabetic() || start == '_')
|
|
||||||
{
|
|
||||||
chars.all(|char| char.is_ascii_alphanumeric() || char == '_')
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
error: unknown print request `uwu`. Valid print requests are: `crate-name`, `file-names`, `sysroot`, `target-libdir`, `cfg`, `calling-conventions`, `target-list`, `target-cpus`, `target-features`, `relocation-models`, `code-models`, `tls-models`, `native-static-libs`, `stack-protector-strategies`, `target-spec-json`, `all-target-specs-json`, `link-args`, `split-debuginfo`, `deployment-target`
|
error: unknown print request `uwu`. Valid print requests are: `all-target-specs-json`, `calling-conventions`, `cfg`, `code-models`, `crate-name`, `deployment-target`, `file-names`, `link-args`, `native-static-libs`, `relocation-models`, `split-debuginfo`, `stack-protector-strategies`, `sysroot`, `target-cpus`, `target-features`, `target-libdir`, `target-list`, `target-spec-json`, `tls-models`
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue