@@ -48,7 +48,7 @@ use std::cell::{self, Cell, RefCell};
48
48
use std:: env;
49
49
use std:: fmt;
50
50
use std:: io:: Write ;
51
- use std:: path:: { Path , PathBuf } ;
51
+ use std:: path:: PathBuf ;
52
52
use std:: time:: Duration ;
53
53
use std:: sync:: mpsc;
54
54
use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
@@ -69,7 +69,7 @@ pub struct Session {
69
69
pub entry_fn : Once < Option < ( NodeId , Span , config:: EntryFnType ) > > ,
70
70
pub plugin_registrar_fn : Once < Option < ast:: NodeId > > ,
71
71
pub proc_macro_decls_static : Once < Option < ast:: NodeId > > ,
72
- pub default_sysroot : Option < PathBuf > ,
72
+ pub sysroot : PathBuf ,
73
73
/// The name of the root source file of the crate, in the local file system.
74
74
/// `None` means that there is no source file.
75
75
pub local_crate_source_file : Option < PathBuf > ,
@@ -694,25 +694,17 @@ impl Session {
694
694
)
695
695
}
696
696
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
- }
705
697
pub fn target_filesearch ( & self , kind : PathKind ) -> filesearch:: FileSearch < ' _ > {
706
698
filesearch:: FileSearch :: new (
707
- self . sysroot ( ) ,
699
+ & self . sysroot ,
708
700
self . opts . target_triple . triple ( ) ,
709
701
& self . opts . search_paths ,
710
702
kind,
711
703
)
712
704
}
713
705
pub fn host_filesearch ( & self , kind : PathKind ) -> filesearch:: FileSearch < ' _ > {
714
706
filesearch:: FileSearch :: new (
715
- self . sysroot ( ) ,
707
+ & self . sysroot ,
716
708
config:: host_triple ( ) ,
717
709
& self . opts . search_paths ,
718
710
kind,
@@ -1109,9 +1101,9 @@ pub fn build_session_(
1109
1101
let target_cfg = config:: build_target_config ( & sopts, & span_diagnostic) ;
1110
1102
1111
1103
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 ( ) ,
1115
1107
} ;
1116
1108
1117
1109
let file_path_mapping = sopts. file_path_mapping ( ) ;
@@ -1147,7 +1139,7 @@ pub fn build_session_(
1147
1139
entry_fn : Once :: new ( ) ,
1148
1140
plugin_registrar_fn : Once :: new ( ) ,
1149
1141
proc_macro_decls_static : Once :: new ( ) ,
1150
- default_sysroot ,
1142
+ sysroot ,
1151
1143
local_crate_source_file,
1152
1144
working_dir,
1153
1145
lint_store : RwLock :: new ( lint:: LintStore :: new ( ) ) ,
0 commit comments