mirror of
https://github.com/notohh/rustlings.git
synced 2024-11-25 14:57:32 -05:00
Fix the sysroot path when it contains whitespaces
This commit is contained in:
parent
18d0f3411f
commit
1fe32a7ff2
1 changed files with 12 additions and 9 deletions
|
@ -2,7 +2,7 @@ use glob::glob;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::path::PathBuf;
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
/// Contains the structure of resulting rust-project.json file
|
/// Contains the structure of resulting rust-project.json file
|
||||||
|
@ -79,21 +79,24 @@ impl RustAnalyzerProject {
|
||||||
.output()?
|
.output()?
|
||||||
.stdout;
|
.stdout;
|
||||||
|
|
||||||
let toolchain = String::from_utf8_lossy(&toolchain);
|
let toolchain = String::from_utf8(toolchain)?;
|
||||||
let mut whitespace_iter = toolchain.split_whitespace();
|
let toolchain = toolchain.trim_end();
|
||||||
|
|
||||||
let toolchain = whitespace_iter.next().unwrap_or(&toolchain);
|
println!("Determined toolchain: {toolchain}\n");
|
||||||
|
|
||||||
println!("Determined toolchain: {}\n", &toolchain);
|
let Ok(path) = Path::new(toolchain)
|
||||||
|
|
||||||
self.sysroot_src = (std::path::Path::new(toolchain)
|
|
||||||
.join("lib")
|
.join("lib")
|
||||||
.join("rustlib")
|
.join("rustlib")
|
||||||
.join("src")
|
.join("src")
|
||||||
.join("rust")
|
.join("rust")
|
||||||
.join("library")
|
.join("library")
|
||||||
.to_string_lossy())
|
.into_os_string()
|
||||||
.to_string();
|
.into_string()
|
||||||
|
else {
|
||||||
|
return Err("The sysroot path is invalid UTF8".into());
|
||||||
|
};
|
||||||
|
self.sysroot_src = path;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue