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

Fix missing space in error message #2619

Merged
merged 3 commits into from
Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
65 changes: 28 additions & 37 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,60 +425,51 @@ fn component_unavailable_msg(cs: &[Component], manifest: &Manifest, toolchain: &
if cs.len() == 1 {
let _ = write!(
buf,
"component {} is unavailable for download for channel {}{}",
"component {} is unavailable for download for channel '{}'\n",
&cs[0].description(manifest),
toolchain,
if toolchain.starts_with("nightly") {
"\nSometimes not all components are available in any given nightly. "
} else {
""
}
);

if toolchain.starts_with("nightly") {
let _ = write!(
buf,
"Sometimes not all components are available in any given nightly. "
);
}
let _ = write!(
buf,
"If you don't need the component, you can remove it with:\n\n{}",
remove_component_msg(&cs[0], manifest, toolchain)
);
} else {
// More than one component

let same_target = cs
.iter()
.all(|c| c.target == cs[0].target || c.target.is_none());
if same_target {
let cs_str = cs
.iter()

let cs_str = if same_target {
cs.iter()
.map(|c| format!("'{}'", c.short_name(manifest)))
.collect::<Vec<_>>()
.join(", ");
let remove_msg = cs
.iter()
.map(|c| remove_component_msg(c, manifest, toolchain))
.collect::<Vec<_>>()
.join("\n");
let _ = write!(
buf,
"some components unavailable for download for channel {}: {}
If you don't need the components, you can remove them with:\n\n{}\n\n{}",
toolchain, cs_str, remove_msg, TOOLSTATE_MSG,
);
.join(", ")
} else {
let cs_str = cs
.iter()
cs.iter()
.map(|c| c.description(manifest))
.collect::<Vec<_>>()
.join(", ");
let remove_msg = cs
.iter()
.map(|c| remove_component_msg(c, manifest, toolchain))
.collect::<Vec<_>>()
.join("\n");
let _ = write!(
buf,
"some components unavailable for download for channel {}: {}
If you don't need the components, you can remove them with:\n{}\n{}",
toolchain, cs_str, remove_msg, TOOLSTATE_MSG,
);
}
.join(", ")
};

let remove_msg = cs
.iter()
.map(|c| remove_component_msg(c, manifest, toolchain))
.collect::<Vec<_>>()
.join("\n");
let _ = write!(
buf,
"some components unavailable for download for channel '{}': {}\n\
If you don't need the components, you can remove them with:\n\n{}\n\n{}",
toolchain, cs_str, remove_msg, TOOLSTATE_MSG,
);
}

String::from_utf8(buf).unwrap()
Expand Down
8 changes: 4 additions & 4 deletions tests/cli-v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ fn update_unavailable_std() {
config,
&["rustup", "update", "nightly", "--no-self-update"],
for_host!(
"component 'rust-std' for target '{0}' is unavailable for download for channel nightly"
"component 'rust-std' for target '{0}' is unavailable for download for channel 'nightly'"
),
);
});
Expand All @@ -1098,7 +1098,7 @@ fn update_unavailable_force() {
config,
&["rustup", "update", "nightly", "--no-self-update"],
for_host!(
"component 'rls' for target '{0}' is unavailable for download for channel nightly"
"component 'rls' for target '{0}' is unavailable for download for channel 'nightly'"
),
);
expect_ok(
Expand Down Expand Up @@ -1359,7 +1359,7 @@ fn test_complete_profile_skips_missing_when_forced() {
"nightly",
"--no-self-update",
],
for_host!("error: component 'rls' for target '{}' is unavailable for download for channel nightly")
for_host!("error: component 'rls' for target '{}' is unavailable for download for channel 'nightly'")
);
// Now try and force
expect_stderr_ok(
Expand Down Expand Up @@ -1493,7 +1493,7 @@ fn install_allow_downgrade() {
"rls",
],
&format!(
"component 'rls' for target '{}' is unavailable for download for channel nightly",
"component 'rls' for target '{}' is unavailable for download for channel 'nightly'",
trip,
),
);
Expand Down