-
Notifications
You must be signed in to change notification settings - Fork 378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ensure sysroot is correct #1231
base: main
Are you sure you want to change the base?
Conversation
471fb49
to
2bbc0fd
Compare
l.replace(" (default)", "") | ||
.replace(" (override)", "") | ||
.trim() | ||
.to_owned() | ||
let mut mode = ToolchainMode::None; | ||
let mut l = if l.contains(" (override)") { | ||
mode = ToolchainMode::Override; | ||
l.replace(" (override)", "") | ||
} else { | ||
l.to_owned() | ||
}; | ||
if l.contains(" (default)") { | ||
if mode.is_overriden() { | ||
mode = ToolchainMode::DefaultOverride; | ||
} else { | ||
mode = ToolchainMode::Default; | ||
} | ||
l = l.replace(" (default)", ""); | ||
} | ||
|
||
(l, mode) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not super happy about this.
pub fn installed_toolchains( | ||
msg_info: &mut MessageInfo, | ||
) -> Result<Vec<(String, ToolchainMode, std::path::PathBuf)>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should probably return a vec of struct
, like available_targets
pub fn sysroot(msg_info: &mut MessageInfo) -> Result<PathBuf> { | ||
let stdout = rustc_command() | ||
.args(["--print", "sysroot"]) | ||
.run_and_get_stdout(msg_info)? | ||
.trim() | ||
.to_owned(); | ||
Ok(PathBuf::from(stdout)) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not needed anymore, rustup toolchain list -v
gives us this, for all toolchains
let (toolchain_name, sysroot) = if let Some((toolchain_name, _, sysroot)) = | ||
installed_toolchains | ||
.iter() | ||
.find(|(_, mode, _)| mode.is_overriden()) | ||
{ | ||
(toolchain_name, sysroot) | ||
} else if let Some((toolchain_name, _, sysroot)) = installed_toolchains | ||
.iter() | ||
.find(|(_, mode, _)| mode.is_defaulted()) | ||
{ | ||
(toolchain_name, sysroot) | ||
} else { | ||
eyre::bail!("no default toolchain found"); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like there is a better way to write this, not sure how though
This resolves #1198