Skip to content
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

switch from termcolor to anstream and anstyle #737

Merged
merged 20 commits into from
Apr 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
minor: save config.stderr() when we use it a lot
this also cleans up lines that get unnecessarily changed in the diff
  • Loading branch information
suaviloquence committed Apr 18, 2024
commit 43c335870af429f7d01e8b986c5ff3c60b051dc1
31 changes: 17 additions & 14 deletions src/rustdoc_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,19 @@ impl RustdocCommand {
if !output.status.success() {
if self.silence {
config.log_error(|config| {
let mut stderr = config.stderr();
let delimiter = "-----";
writeln!(
config.stderr(),
stderr,
"error: running cargo-doc on crate {crate_name} failed with output:"
)?;
writeln!(
config.stderr(),
stderr,
"{delimiter}\n{}\n{delimiter}\n",
String::from_utf8_lossy(&output.stderr)
)?;
writeln!(
config.stderr(),
stderr,
"error: failed to build rustdoc for crate {crate_name} v{version}"
)?;
Ok(())
Expand All @@ -169,16 +170,17 @@ impl RustdocCommand {
config.log_error(|config| {
let features =
crate_source.feature_list_from_config(config, crate_data.feature_config);
let mut stderr = config.stderr();
writeln!(
config.stderr(),
stderr,
"note: this is usually due to a compilation error in the crate,"
)?;
writeln!(
config.stderr(),
stderr,
" and is unlikely to be a bug in cargo-semver-checks"
)?;
writeln!(
config.stderr(),
stderr,
"note: the following command can be used to reproduce the compilation error:"
)?;
let selector = match crate_source {
Expand All @@ -199,7 +201,7 @@ impl RustdocCommand {
format!("--features {} ", features.into_iter().join(","))
};
writeln!(
config.stderr(),
stderr,
" \
cargo new --lib example &&
cd example &&
Expand Down Expand Up @@ -244,21 +246,22 @@ cargo new --lib example &&
} else {
config.log_error(|config| {
let delimiter = "-----";
let mut stderr = config.stderr();
writeln!(
config.stderr(),
stderr,
"error: running cargo-config on crate {crate_name} failed with output:"
)?;
writeln!(
config.stderr(),
stderr,
"{delimiter}\n{}\n{delimiter}\n",
String::from_utf8_lossy(&output.stderr)
)?;

writeln!(config.stderr(), "error: unexpected cargo config output for crate {crate_name} v{version}\n")?;
writeln!(config.stderr(), "note: this may be a bug in cargo, or a bug in cargo-semver-checks;")?;
writeln!(config.stderr(), " if unsure, feel free to open a GitHub issue on cargo-semver-checks")?;
writeln!(config.stderr(), "note: running the following command on the crate should reproduce the error:")?;
writeln!(config.stderr(),
writeln!(stderr, "error: unexpected cargo config output for crate {crate_name} v{version}\n")?;
writeln!(stderr, "note: this may be a bug in cargo, or a bug in cargo-semver-checks;")?;
writeln!(stderr, " if unsure, feel free to open a GitHub issue on cargo-semver-checks")?;
writeln!(stderr, "note: running the following command on the crate should reproduce the error:")?;
writeln!(stderr,
" cargo config -Zunstable-options get --format=json-value build.target\n",
)?;
Ok(())
Expand Down
Loading