Move compiler input and ouput paths into session
This commit is contained in:
parent
42f75f1e46
commit
9f5cd03153
15 changed files with 113 additions and 154 deletions
|
@ -50,8 +50,8 @@ use std::rc::Rc;
|
|||
use std::sync::LazyLock;
|
||||
use std::{env, fs, iter};
|
||||
|
||||
pub fn parse<'a>(sess: &'a Session, input: &Input) -> PResult<'a, ast::Crate> {
|
||||
let krate = sess.time("parse_crate", || match input {
|
||||
pub fn parse<'a>(sess: &'a Session) -> PResult<'a, ast::Crate> {
|
||||
let krate = sess.time("parse_crate", || match &sess.io.input {
|
||||
Input::File(file) => parse_crate_from_file(file, &sess.parse_sess),
|
||||
Input::Str { input, name } => {
|
||||
parse_crate_from_source_str(name.clone(), input.clone(), &sess.parse_sess)
|
||||
|
@ -665,7 +665,6 @@ fn write_out_deps(
|
|||
|
||||
pub fn prepare_outputs(
|
||||
sess: &Session,
|
||||
compiler: &Compiler,
|
||||
krate: &ast::Crate,
|
||||
boxed_resolver: &RefCell<BoxedResolver>,
|
||||
crate_name: Symbol,
|
||||
|
@ -673,13 +672,13 @@ pub fn prepare_outputs(
|
|||
let _timer = sess.timer("prepare_outputs");
|
||||
|
||||
// FIXME: rustdoc passes &[] instead of &krate.attrs here
|
||||
let outputs = util::build_output_filenames(&compiler.io, &krate.attrs, sess);
|
||||
let outputs = util::build_output_filenames(&krate.attrs, sess);
|
||||
|
||||
let output_paths =
|
||||
generated_output_paths(sess, &outputs, compiler.io.output_file.is_some(), crate_name);
|
||||
generated_output_paths(sess, &outputs, sess.io.output_file.is_some(), crate_name);
|
||||
|
||||
// Ensure the source file isn't accidentally overwritten during compilation.
|
||||
if let Some(ref input_path) = compiler.io.input.opt_path() {
|
||||
if let Some(ref input_path) = sess.io.input.opt_path() {
|
||||
if sess.opts.will_create_output_file() {
|
||||
if output_contains_path(&output_paths, input_path) {
|
||||
let reported = sess.emit_err(InputFileWouldBeOverWritten { path: input_path });
|
||||
|
@ -693,7 +692,7 @@ pub fn prepare_outputs(
|
|||
}
|
||||
}
|
||||
|
||||
if let Some(ref dir) = compiler.io.temps_dir {
|
||||
if let Some(ref dir) = sess.io.temps_dir {
|
||||
if fs::create_dir_all(dir).is_err() {
|
||||
let reported = sess.emit_err(TempsDirError);
|
||||
return Err(reported);
|
||||
|
@ -706,7 +705,7 @@ pub fn prepare_outputs(
|
|||
&& sess.opts.output_types.len() == 1;
|
||||
|
||||
if !only_dep_info {
|
||||
if let Some(ref dir) = compiler.io.output_dir {
|
||||
if let Some(ref dir) = sess.io.output_dir {
|
||||
if fs::create_dir_all(dir).is_err() {
|
||||
let reported = sess.emit_err(OutDirError);
|
||||
return Err(reported);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue