Auto merge of #106810 - oli-obk:resolver_reverse_plumbing, r=petrochenkov
Various cleanups around pre-TyCtxt queries and functions
part of #105462
based on https://github.com/rust-lang/rust/pull/106776 (everything starting at [0e2b39f](0e2b39fd1f
) is new in this PR)
r? `@petrochenkov`
I think this should be most of the uncontroversial part of #105462.
This commit is contained in:
commit
65d2f2a5f9
22 changed files with 203 additions and 300 deletions
|
@ -1,6 +1,7 @@
|
|||
use crate::cgu_reuse_tracker::CguReuseTracker;
|
||||
use crate::code_stats::CodeStats;
|
||||
pub use crate::code_stats::{DataTypeKind, FieldInfo, SizeKind, VariantInfo};
|
||||
use crate::config::Input;
|
||||
use crate::config::{self, CrateType, InstrumentCoverage, OptLevel, OutputType, SwitchWithOptPath};
|
||||
use crate::errors::{
|
||||
BranchProtectionRequiresAArch64, CannotEnableCrtStaticLinux, CannotMixAndMatchSanitizers,
|
||||
|
@ -137,6 +138,13 @@ pub struct Limits {
|
|||
pub const_eval_limit: Limit,
|
||||
}
|
||||
|
||||
pub struct CompilerIO {
|
||||
pub input: Input,
|
||||
pub output_dir: Option<PathBuf>,
|
||||
pub output_file: Option<PathBuf>,
|
||||
pub temps_dir: Option<PathBuf>,
|
||||
}
|
||||
|
||||
/// Represents the data associated with a compilation
|
||||
/// session for a single crate.
|
||||
pub struct Session {
|
||||
|
@ -147,9 +155,8 @@ pub struct Session {
|
|||
pub target_tlib_path: Lrc<SearchPath>,
|
||||
pub parse_sess: ParseSess,
|
||||
pub sysroot: PathBuf,
|
||||
/// The name of the root source file of the crate, in the local file system.
|
||||
/// `None` means that there is no source file.
|
||||
pub local_crate_source_file: Option<PathBuf>,
|
||||
/// Input, input file path and output file path to this compilation process.
|
||||
pub io: CompilerIO,
|
||||
|
||||
crate_types: OnceCell<Vec<CrateType>>,
|
||||
/// The `stable_crate_id` is constructed out of the crate name and all the
|
||||
|
@ -228,6 +235,11 @@ impl Session {
|
|||
self.miri_unleashed_features.lock().push((span, feature_gate));
|
||||
}
|
||||
|
||||
pub fn local_crate_source_file(&self) -> Option<PathBuf> {
|
||||
let path = self.io.input.opt_path()?;
|
||||
Some(self.opts.file_path_mapping().map_prefix(path).0.into_owned())
|
||||
}
|
||||
|
||||
fn check_miri_unleashed_features(&self) {
|
||||
let unleashed_features = self.miri_unleashed_features.lock();
|
||||
if !unleashed_features.is_empty() {
|
||||
|
@ -1298,7 +1310,7 @@ fn default_emitter(
|
|||
#[allow(rustc::bad_opt_access)]
|
||||
pub fn build_session(
|
||||
sopts: config::Options,
|
||||
local_crate_source_file: Option<PathBuf>,
|
||||
io: CompilerIO,
|
||||
bundle: Option<Lrc<rustc_errors::FluentBundle>>,
|
||||
registry: rustc_errors::registry::Registry,
|
||||
driver_lint_caps: FxHashMap<lint::LintId, lint::Level>,
|
||||
|
@ -1391,11 +1403,6 @@ pub fn build_session(
|
|||
Lrc::new(SearchPath::from_sysroot_and_triple(&sysroot, target_triple))
|
||||
};
|
||||
|
||||
let file_path_mapping = sopts.file_path_mapping();
|
||||
|
||||
let local_crate_source_file =
|
||||
local_crate_source_file.map(|path| file_path_mapping.map_prefix(path).0);
|
||||
|
||||
let optimization_fuel = Lock::new(OptimizationFuel {
|
||||
remaining: sopts.unstable_opts.fuel.as_ref().map_or(0, |&(_, i)| i),
|
||||
out_of_fuel: false,
|
||||
|
@ -1427,7 +1434,7 @@ pub fn build_session(
|
|||
target_tlib_path,
|
||||
parse_sess,
|
||||
sysroot,
|
||||
local_crate_source_file,
|
||||
io,
|
||||
crate_types: OnceCell::new(),
|
||||
stable_crate_id: OnceCell::new(),
|
||||
features: OnceCell::new(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue