Make sysroot mandatory for rustdoc
This commit is contained in:
parent
9ae4e3eb7c
commit
2fae4ee92e
4 changed files with 13 additions and 16 deletions
|
@ -317,7 +317,7 @@ fn test_search_paths_tracking_hash_different_order() {
|
||||||
|
|
||||||
let push = |opts: &mut Options, search_path| {
|
let push = |opts: &mut Options, search_path| {
|
||||||
opts.search_paths.push(SearchPath::from_cli_opt(
|
opts.search_paths.push(SearchPath::from_cli_opt(
|
||||||
None,
|
"not-a-sysroot".as_ref(),
|
||||||
&opts.target_triple,
|
&opts.target_triple,
|
||||||
&early_dcx,
|
&early_dcx,
|
||||||
search_path,
|
search_path,
|
||||||
|
|
|
@ -2824,7 +2824,6 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
|
||||||
let logical_env = parse_logical_env(early_dcx, matches);
|
let logical_env = parse_logical_env(early_dcx, matches);
|
||||||
|
|
||||||
let sysroot = filesearch::materialize_sysroot(sysroot_opt);
|
let sysroot = filesearch::materialize_sysroot(sysroot_opt);
|
||||||
|
|
||||||
let real_rust_source_base_dir = {
|
let real_rust_source_base_dir = {
|
||||||
// This is the location used by the `rust-src` `rustup` component.
|
// This is the location used by the `rust-src` `rustup` component.
|
||||||
let mut candidate = sysroot.join("lib/rustlib/src/rust");
|
let mut candidate = sysroot.join("lib/rustlib/src/rust");
|
||||||
|
@ -2845,7 +2844,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
|
||||||
|
|
||||||
let mut search_paths = vec![];
|
let mut search_paths = vec![];
|
||||||
for s in &matches.opt_strs("L") {
|
for s in &matches.opt_strs("L") {
|
||||||
search_paths.push(SearchPath::from_cli_opt(Some(&sysroot), &target_triple, early_dcx, s));
|
search_paths.push(SearchPath::from_cli_opt(&sysroot, &target_triple, early_dcx, s));
|
||||||
}
|
}
|
||||||
|
|
||||||
let working_dir = std::env::current_dir().unwrap_or_else(|e| {
|
let working_dir = std::env::current_dir().unwrap_or_else(|e| {
|
||||||
|
|
|
@ -48,7 +48,7 @@ impl PathKind {
|
||||||
|
|
||||||
impl SearchPath {
|
impl SearchPath {
|
||||||
pub fn from_cli_opt(
|
pub fn from_cli_opt(
|
||||||
sysroot: Option<&Path>,
|
sysroot: &Path,
|
||||||
triple: &TargetTriple,
|
triple: &TargetTriple,
|
||||||
early_dcx: &EarlyDiagCtxt,
|
early_dcx: &EarlyDiagCtxt,
|
||||||
path: &str,
|
path: &str,
|
||||||
|
@ -64,21 +64,12 @@ impl SearchPath {
|
||||||
} else if let Some(stripped) = path.strip_prefix("all=") {
|
} else if let Some(stripped) = path.strip_prefix("all=") {
|
||||||
(PathKind::All, stripped)
|
(PathKind::All, stripped)
|
||||||
} else if let Some(stripped) = path.strip_prefix("builtin:") {
|
} else if let Some(stripped) = path.strip_prefix("builtin:") {
|
||||||
let Some(sysroot) = sysroot else {
|
|
||||||
early_dcx.early_fatal("`-L builtin:` is not supported without a sysroot present");
|
|
||||||
};
|
|
||||||
let triple = match triple {
|
|
||||||
TargetTriple::TargetTriple(triple) => triple,
|
|
||||||
TargetTriple::TargetJson { .. } => {
|
|
||||||
early_dcx.early_fatal("`-L builtin:` is not supported with custom targets");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if stripped.contains(std::path::is_separator) {
|
if stripped.contains(std::path::is_separator) {
|
||||||
early_dcx.early_fatal("`-L builtin:` does not accept paths");
|
early_dcx.early_fatal("`-L builtin:` does not accept paths");
|
||||||
}
|
}
|
||||||
|
|
||||||
let path = make_target_lib_path(sysroot, triple).join("builtin").join(stripped);
|
let path =
|
||||||
|
make_target_lib_path(sysroot, triple.triple()).join("builtin").join(stripped);
|
||||||
if !path.is_dir() {
|
if !path.is_dir() {
|
||||||
early_dcx.early_fatal(format!("builtin:{stripped} does not exist"));
|
early_dcx.early_fatal(format!("builtin:{stripped} does not exist"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -625,10 +625,17 @@ impl Options {
|
||||||
let target = parse_target_triple(early_dcx, matches);
|
let target = parse_target_triple(early_dcx, matches);
|
||||||
let maybe_sysroot = matches.opt_str("sysroot").map(PathBuf::from);
|
let maybe_sysroot = matches.opt_str("sysroot").map(PathBuf::from);
|
||||||
|
|
||||||
|
let sysroot = match &maybe_sysroot {
|
||||||
|
Some(s) => s.clone(),
|
||||||
|
None => {
|
||||||
|
rustc_session::filesearch::get_or_default_sysroot().expect("Failed finding sysroot")
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let libs = matches
|
let libs = matches
|
||||||
.opt_strs("L")
|
.opt_strs("L")
|
||||||
.iter()
|
.iter()
|
||||||
.map(|s| SearchPath::from_cli_opt(maybe_sysroot.as_deref(), &target, early_dcx, s))
|
.map(|s| SearchPath::from_cli_opt(&sysroot, &target, early_dcx, s))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let show_coverage = matches.opt_present("show-coverage");
|
let show_coverage = matches.opt_present("show-coverage");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue