Skip to content

Commit

Permalink
Improve "rustc show" output order
Browse files Browse the repository at this point in the history
  • Loading branch information
majaha committed Feb 19, 2023
1 parent 7659519 commit 7b564d8
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1115,8 +1115,8 @@ fn show(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<utils::ExitCode> {
};

let show_installed_toolchains = installed_toolchains.len() > 1;
let show_active_targets = active_targets.len() > 1;
let show_active_toolchain = true;
let show_active_targets = active_targets.len() > 1;

// Only need to display headers if we have multiple sections
let show_headers = [
Expand Down Expand Up @@ -1158,26 +1158,6 @@ fn show(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<utils::ExitCode> {
};
}

if show_active_targets {
let mut t = term2::stdout();
if show_headers {
print_header::<Error>(&mut t, "installed targets for active toolchain")?;
}
for at in active_targets {
writeln!(
t,
"{}",
at.component
.target
.as_ref()
.expect("rust-std should have a target")
)?;
}
if show_headers {
writeln!(t)?;
};
}

if show_active_toolchain {
let mut t = term2::stdout();
if show_headers {
Expand Down Expand Up @@ -1214,6 +1194,26 @@ fn show(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<utils::ExitCode> {
}
}

if show_active_targets {
let mut t = term2::stdout();
if show_headers {
print_header::<Error>(&mut t, "installed targets for active toolchain")?;
}
for at in active_targets {
writeln!(
t,
"{}",
at.component
.target
.as_ref()
.expect("rust-std should have a target")
)?;
}
if show_headers {
writeln!(t)?;
};
}

fn print_header<E>(t: &mut term2::StdoutTerminal, s: &str) -> std::result::Result<(), E>
where
E: From<term::Error> + From<std::io::Error>,
Expand Down

0 comments on commit 7b564d8

Please sign in to comment.