diff options
| author | Nicholas Nethercote <nnethercote@mozilla.com> | 2018-11-22 15:49:48 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <nnethercote@mozilla.com> | 2018-12-12 10:36:15 +1100 |
| commit | 2640da7d13a1051dddcf93c06f9ae90508fce6fb (patch) | |
| tree | d0cec63297afc90780020789f4fb654cf21d47ab /src/librustc/session | |
| parent | 0238bcc60d943878244ef7221d338f13a35e2a45 (diff) | |
| download | rust-2640da7d13a1051dddcf93c06f9ae90508fce6fb.tar.gz rust-2640da7d13a1051dddcf93c06f9ae90508fce6fb.zip | |
Remove `Session::sysroot()`.
Instead of maybe storing its own sysroot and maybe deferring to the one in `Session::opts`, just clone the latter when necessary so one is always directly available. This removes the need for the getter.
Diffstat (limited to 'src/librustc/session')
| -rw-r--r-- | src/librustc/session/mod.rs | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index d1dd745add9..56a57b5375f 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -48,7 +48,7 @@ use std::cell::{self, Cell, RefCell}; use std::env; use std::fmt; use std::io::Write; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; use std::time::Duration; use std::sync::mpsc; use std::sync::atomic::{AtomicUsize, Ordering}; @@ -69,7 +69,7 @@ pub struct Session { pub entry_fn: Once<Option<(NodeId, Span, config::EntryFnType)>>, pub plugin_registrar_fn: Once<Option<ast::NodeId>>, pub proc_macro_decls_static: Once<Option<ast::NodeId>>, - pub default_sysroot: Option<PathBuf>, + 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>, @@ -694,17 +694,9 @@ impl Session { ) } - pub fn sysroot<'a>(&'a self) -> &'a Path { - match self.opts.maybe_sysroot { - Some(ref sysroot) => sysroot, - None => self.default_sysroot - .as_ref() - .expect("missing sysroot and default_sysroot in Session"), - } - } pub fn target_filesearch(&self, kind: PathKind) -> filesearch::FileSearch<'_> { filesearch::FileSearch::new( - self.sysroot(), + &self.sysroot, self.opts.target_triple.triple(), &self.opts.search_paths, kind, @@ -712,7 +704,7 @@ impl Session { } pub fn host_filesearch(&self, kind: PathKind) -> filesearch::FileSearch<'_> { filesearch::FileSearch::new( - self.sysroot(), + &self.sysroot, config::host_triple(), &self.opts.search_paths, kind, @@ -1109,9 +1101,9 @@ pub fn build_session_( let target_cfg = config::build_target_config(&sopts, &span_diagnostic); let p_s = parse::ParseSess::with_span_handler(span_diagnostic, source_map); - let default_sysroot = match sopts.maybe_sysroot { - Some(_) => None, - None => Some(filesearch::get_or_default_sysroot()), + let sysroot = match &sopts.maybe_sysroot { + Some(sysroot) => sysroot.clone(), + None => filesearch::get_or_default_sysroot(), }; let file_path_mapping = sopts.file_path_mapping(); @@ -1147,7 +1139,7 @@ pub fn build_session_( entry_fn: Once::new(), plugin_registrar_fn: Once::new(), proc_macro_decls_static: Once::new(), - default_sysroot, + sysroot, local_crate_source_file, working_dir, lint_store: RwLock::new(lint::LintStore::new()), |
