@@ -6,7 +6,7 @@ pub use crate::options::*;
6
6
use crate :: errors:: FileWriteFail ;
7
7
use crate :: search_paths:: SearchPath ;
8
8
use crate :: utils:: { CanonicalizedPath , NativeLib , NativeLibKind } ;
9
- use crate :: { lint, HashStableContext } ;
9
+ use crate :: { filesearch , lint, HashStableContext } ;
10
10
use crate :: { EarlyDiagCtxt , Session } ;
11
11
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet , FxIndexMap , FxIndexSet } ;
12
12
use rustc_data_structures:: stable_hasher:: { StableOrd , ToStableHashKey } ;
@@ -2856,16 +2856,8 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
2856
2856
2857
2857
let logical_env = parse_logical_env ( early_dcx, matches) ;
2858
2858
2859
- // Try to find a directory containing the Rust `src`, for more details see
2860
- // the doc comment on the `real_rust_source_base_dir` field.
2861
- let tmp_buf;
2862
- let sysroot = match & sysroot_opt {
2863
- Some ( s) => s,
2864
- None => {
2865
- tmp_buf = crate :: filesearch:: get_or_default_sysroot ( ) . expect ( "Failed finding sysroot" ) ;
2866
- & tmp_buf
2867
- }
2868
- } ;
2859
+ let sysroot = filesearch:: materialize_sysroot ( sysroot_opt) ;
2860
+
2869
2861
let real_rust_source_base_dir = {
2870
2862
// This is the location used by the `rust-src` `rustup` component.
2871
2863
let mut candidate = sysroot. join ( "lib/rustlib/src/rust" ) ;
@@ -2909,7 +2901,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
2909
2901
describe_lints,
2910
2902
output_types,
2911
2903
search_paths,
2912
- maybe_sysroot : sysroot_opt ,
2904
+ maybe_sysroot : Some ( sysroot ) ,
2913
2905
target_triple,
2914
2906
test,
2915
2907
incremental,
0 commit comments