Skip to content

Commit ca6cd05

Browse files
authored
Merge pull request #2619 from dralley/master
Fix missing space in error message
2 parents 3c3a27f + 291f693 commit ca6cd05

File tree

2 files changed

+32
-41
lines changed

2 files changed

+32
-41
lines changed

src/errors.rs

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -425,60 +425,51 @@ fn component_unavailable_msg(cs: &[Component], manifest: &Manifest, toolchain: &
425425
if cs.len() == 1 {
426426
let _ = write!(
427427
buf,
428-
"component {} is unavailable for download for channel {}{}",
428+
"component {} is unavailable for download for channel '{}'\n",
429429
&cs[0].description(manifest),
430430
toolchain,
431-
if toolchain.starts_with("nightly") {
432-
"\nSometimes not all components are available in any given nightly. "
433-
} else {
434-
""
435-
}
436431
);
437-
432+
if toolchain.starts_with("nightly") {
433+
let _ = write!(
434+
buf,
435+
"Sometimes not all components are available in any given nightly. "
436+
);
437+
}
438438
let _ = write!(
439439
buf,
440440
"If you don't need the component, you can remove it with:\n\n{}",
441441
remove_component_msg(&cs[0], manifest, toolchain)
442442
);
443443
} else {
444+
// More than one component
445+
444446
let same_target = cs
445447
.iter()
446448
.all(|c| c.target == cs[0].target || c.target.is_none());
447-
if same_target {
448-
let cs_str = cs
449-
.iter()
449+
450+
let cs_str = if same_target {
451+
cs.iter()
450452
.map(|c| format!("'{}'", c.short_name(manifest)))
451453
.collect::<Vec<_>>()
452-
.join(", ");
453-
let remove_msg = cs
454-
.iter()
455-
.map(|c| remove_component_msg(c, manifest, toolchain))
456-
.collect::<Vec<_>>()
457-
.join("\n");
458-
let _ = write!(
459-
buf,
460-
"some components unavailable for download for channel {}: {}
461-
If you don't need the components, you can remove them with:\n\n{}\n\n{}",
462-
toolchain, cs_str, remove_msg, TOOLSTATE_MSG,
463-
);
454+
.join(", ")
464455
} else {
465-
let cs_str = cs
466-
.iter()
456+
cs.iter()
467457
.map(|c| c.description(manifest))
468458
.collect::<Vec<_>>()
469-
.join(", ");
470-
let remove_msg = cs
471-
.iter()
472-
.map(|c| remove_component_msg(c, manifest, toolchain))
473-
.collect::<Vec<_>>()
474-
.join("\n");
475-
let _ = write!(
476-
buf,
477-
"some components unavailable for download for channel {}: {}
478-
If you don't need the components, you can remove them with:\n{}\n{}",
479-
toolchain, cs_str, remove_msg, TOOLSTATE_MSG,
480-
);
481-
}
459+
.join(", ")
460+
};
461+
462+
let remove_msg = cs
463+
.iter()
464+
.map(|c| remove_component_msg(c, manifest, toolchain))
465+
.collect::<Vec<_>>()
466+
.join("\n");
467+
let _ = write!(
468+
buf,
469+
"some components unavailable for download for channel '{}': {}\n\
470+
If you don't need the components, you can remove them with:\n\n{}\n\n{}",
471+
toolchain, cs_str, remove_msg, TOOLSTATE_MSG,
472+
);
482473
}
483474

484475
String::from_utf8(buf).unwrap()

tests/cli-v2.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ fn update_unavailable_std() {
10711071
config,
10721072
&["rustup", "update", "nightly", "--no-self-update"],
10731073
for_host!(
1074-
"component 'rust-std' for target '{0}' is unavailable for download for channel nightly"
1074+
"component 'rust-std' for target '{0}' is unavailable for download for channel 'nightly'"
10751075
),
10761076
);
10771077
});
@@ -1098,7 +1098,7 @@ fn update_unavailable_force() {
10981098
config,
10991099
&["rustup", "update", "nightly", "--no-self-update"],
11001100
for_host!(
1101-
"component 'rls' for target '{0}' is unavailable for download for channel nightly"
1101+
"component 'rls' for target '{0}' is unavailable for download for channel 'nightly'"
11021102
),
11031103
);
11041104
expect_ok(
@@ -1359,7 +1359,7 @@ fn test_complete_profile_skips_missing_when_forced() {
13591359
"nightly",
13601360
"--no-self-update",
13611361
],
1362-
for_host!("error: component 'rls' for target '{}' is unavailable for download for channel nightly")
1362+
for_host!("error: component 'rls' for target '{}' is unavailable for download for channel 'nightly'")
13631363
);
13641364
// Now try and force
13651365
expect_stderr_ok(
@@ -1493,7 +1493,7 @@ fn install_allow_downgrade() {
14931493
"rls",
14941494
],
14951495
&format!(
1496-
"component 'rls' for target '{}' is unavailable for download for channel nightly",
1496+
"component 'rls' for target '{}' is unavailable for download for channel 'nightly'",
14971497
trip,
14981498
),
14991499
);

0 commit comments

Comments
 (0)