mirror of
https://github.com/rust-lang/rustlings
synced 2024-11-16 12:12:54 +00:00
Merge pull request #1904 from mo8it/lsp
Fix the sysroot path when it contains whitespaces
This commit is contained in:
commit
f3fdb07507
@ -2,7 +2,7 @@ use glob::glob;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::env;
|
||||
use std::error::Error;
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
/// Contains the structure of resulting rust-project.json file
|
||||
@ -79,21 +79,24 @@ impl RustAnalyzerProject {
|
||||
.output()?
|
||||
.stdout;
|
||||
|
||||
let toolchain = String::from_utf8_lossy(&toolchain);
|
||||
let mut whitespace_iter = toolchain.split_whitespace();
|
||||
let toolchain = String::from_utf8(toolchain)?;
|
||||
let toolchain = toolchain.trim_end();
|
||||
|
||||
let toolchain = whitespace_iter.next().unwrap_or(&toolchain);
|
||||
println!("Determined toolchain: {toolchain}\n");
|
||||
|
||||
println!("Determined toolchain: {}\n", &toolchain);
|
||||
|
||||
self.sysroot_src = (std::path::Path::new(toolchain)
|
||||
let Ok(path) = Path::new(toolchain)
|
||||
.join("lib")
|
||||
.join("rustlib")
|
||||
.join("src")
|
||||
.join("rust")
|
||||
.join("library")
|
||||
.to_string_lossy())
|
||||
.to_string();
|
||||
.into_os_string()
|
||||
.into_string()
|
||||
else {
|
||||
return Err("The sysroot path is invalid UTF8".into());
|
||||
};
|
||||
self.sysroot_src = path;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user