@@ -48,7 +48,7 @@ use std::cell::{self, Cell, RefCell};
4848use std:: env;
4949use std:: fmt;
5050use std:: io:: Write ;
51- use std:: path:: { Path , PathBuf } ;
51+ use std:: path:: PathBuf ;
5252use std:: time:: Duration ;
5353use std:: sync:: mpsc;
5454use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
@@ -69,7 +69,7 @@ pub struct Session {
6969 pub entry_fn : Once < Option < ( NodeId , Span , config:: EntryFnType ) > > ,
7070 pub plugin_registrar_fn : Once < Option < ast:: NodeId > > ,
7171 pub proc_macro_decls_static : Once < Option < ast:: NodeId > > ,
72- pub default_sysroot : Option < PathBuf > ,
72+ pub sysroot : PathBuf ,
7373 /// The name of the root source file of the crate, in the local file system.
7474 /// `None` means that there is no source file.
7575 pub local_crate_source_file : Option < PathBuf > ,
@@ -694,25 +694,17 @@ impl Session {
694694 )
695695 }
696696
697- pub fn sysroot < ' a > ( & ' a self ) -> & ' a Path {
698- match self . opts . maybe_sysroot {
699- Some ( ref sysroot) => sysroot,
700- None => self . default_sysroot
701- . as_ref ( )
702- . expect ( "missing sysroot and default_sysroot in Session" ) ,
703- }
704- }
705697 pub fn target_filesearch ( & self , kind : PathKind ) -> filesearch:: FileSearch < ' _ > {
706698 filesearch:: FileSearch :: new (
707- self . sysroot ( ) ,
699+ & self . sysroot ,
708700 self . opts . target_triple . triple ( ) ,
709701 & self . opts . search_paths ,
710702 kind,
711703 )
712704 }
713705 pub fn host_filesearch ( & self , kind : PathKind ) -> filesearch:: FileSearch < ' _ > {
714706 filesearch:: FileSearch :: new (
715- self . sysroot ( ) ,
707+ & self . sysroot ,
716708 config:: host_triple ( ) ,
717709 & self . opts . search_paths ,
718710 kind,
@@ -1109,9 +1101,9 @@ pub fn build_session_(
11091101 let target_cfg = config:: build_target_config ( & sopts, & span_diagnostic) ;
11101102
11111103 let p_s = parse:: ParseSess :: with_span_handler ( span_diagnostic, source_map) ;
1112- let default_sysroot = match sopts. maybe_sysroot {
1113- Some ( _ ) => None ,
1114- None => Some ( filesearch:: get_or_default_sysroot ( ) ) ,
1104+ let sysroot = match & sopts. maybe_sysroot {
1105+ Some ( sysroot ) => sysroot . clone ( ) ,
1106+ None => filesearch:: get_or_default_sysroot ( ) ,
11151107 } ;
11161108
11171109 let file_path_mapping = sopts. file_path_mapping ( ) ;
@@ -1147,7 +1139,7 @@ pub fn build_session_(
11471139 entry_fn : Once :: new ( ) ,
11481140 plugin_registrar_fn : Once :: new ( ) ,
11491141 proc_macro_decls_static : Once :: new ( ) ,
1150- default_sysroot ,
1142+ sysroot ,
11511143 local_crate_source_file,
11521144 working_dir,
11531145 lint_store : RwLock :: new ( lint:: LintStore :: new ( ) ) ,
0 commit comments