Skip to content

Commit ebde0f9

Browse files
committed
rebasing
1 parent 04b654d commit ebde0f9

File tree

9 files changed

+53
-23
lines changed

9 files changed

+53
-23
lines changed

download/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ pub mod reqwest_be {
330330
callback: &dyn Fn(Event<'_>) -> Result<()>,
331331
) -> Result<bool> {
332332
use std::fs;
333-
use std::io;
334333

335334
// The file scheme is mostly for use by tests to mock the dist server
336335
if url.scheme() == "file" {

src/cli/rustup_mode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ pub fn cli() -> App<'static, 'static> {
535535
.map(|&shell| ("shell", Some(shell), "rustup"))
536536
.collect::<Vec<_>>();
537537

538-
app.subcommand(
538+
app
539539
.subcommand(
540540
SubCommand::with_name("set")
541541
.about("Alter rustup settings")

src/cli/self_update.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,6 @@ fn do_pre_install_options_sanity_checks(opts: &InstallOpts) -> Result<()> {
448448
fn do_anti_sudo_check(no_prompt: bool) -> Result<()> {
449449
#[cfg(unix)]
450450
pub fn home_mismatch() -> bool {
451-
use std::env;
452451
use std::ffi::CStr;
453452
use std::mem;
454453
use std::ops::Deref;

src/dist/dist.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,6 @@ fn update_from_dist_<'a>(
612612
force_update,
613613
&download,
614614
&download.notify_handler,
615-
&toolchain.manifest_name(),
616615
)? {
617616
UpdateStatus::Unchanged => Ok(None),
618617
UpdateStatus::Changed => Ok(Some(hash)),

src/dist/manifest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use crate::errors::*;
1414
use crate::utils::toml_utils::*;
1515

16-
use crate::dist::{Profile, TargetTriple};
16+
use crate::dist::dist::{Profile, TargetTriple};
1717
use std::collections::HashMap;
1818

1919
pub const SUPPORTED_MANIFEST_VERSIONS: [&str; 1] = ["2"];

src/dist/manifestation.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl Changes {
4949
.chain(self.explicit_add_components.iter())
5050
}
5151

52-
fn check_invariants(&self, rust_target_package: &TargetedPackage, config: &Option<Config>) {
52+
fn check_invariants(&self, config: &Option<Config>) {
5353
for component_to_add in self.iter_add_components() {
5454
assert!(
5555
!self.remove_components.contains(component_to_add),
@@ -111,7 +111,6 @@ impl Manifestation {
111111
force_update: bool,
112112
download_cfg: &DownloadCfg<'_>,
113113
notify_handler: &dyn Fn(Notification<'_>),
114-
toolchain_str: &str,
115114
) -> Result<UpdateStatus> {
116115
// Some vars we're going to need a few times
117116
let temp_cfg = download_cfg.temp_cfg;
@@ -121,7 +120,7 @@ impl Manifestation {
121120

122121
// Create the lists of components needed for installation
123122
let config = self.read_config()?;
124-
let update = Update::build_update(self, new_manifest, &changes, config, notify_handler)?;
123+
let update = Update::build_update(self, new_manifest, &changes, &config, notify_handler)?;
125124

126125
if update.nothing_changes() {
127126
// TODO chnages and ,manifest are empty?
@@ -130,7 +129,7 @@ impl Manifestation {
130129
}
131130

132131
// Validate that the requested components are available
133-
match update.unavailable_components(new_manifest, toolchain_str) {
132+
match update.unavailable_components(new_manifest) {
134133
Ok(_) => {}
135134
_ if force_update => {}
136135
Err(e) => return Err(e),
@@ -471,15 +470,15 @@ impl Update {
471470
fn build_update(
472471
manifestation: &Manifestation,
473472
new_manifest: &Manifest,
474-
changes: Changes,
475-
notify_handler: &dyn Fn(Notification<'_>),
473+
changes: &Changes,
476474
config: &Option<Config>,
475+
notify_handler: &dyn Fn(Notification<'_>),
477476
) -> Result<Update> {
478477
// The package to install.
479478
let rust_package = new_manifest.get_package("rust")?;
480479
let rust_target_package = rust_package.get_target(Some(&manifestation.target_triple))?;
481480

482-
changes.check_invariants(rust_target_package, &config);
481+
changes.check_invariants(&config);
483482

484483
// The list of components already installed, empty if a new install
485484
let starting_list = config
@@ -501,7 +500,7 @@ impl Update {
501500
&starting_list,
502501
rust_target_package,
503502
new_manifest,
504-
changes,
503+
&changes,
505504
config,
506505
);
507506

@@ -527,7 +526,7 @@ impl Update {
527526
for component in &result.final_component_list {
528527
if !starting_list.contains(component) {
529528
result.components_to_install.push(component.clone());
530-
} else if changes.add_extensions.contains(&component) {
529+
} else if changes.explicit_add_components.contains(&component) {
531530
notify_handler(Notification::ComponentAlreadyInstalled(
532531
&component.description(new_manifest),
533532
));
@@ -548,7 +547,6 @@ impl Update {
548547
rust_target_package: &TargetedPackage,
549548
new_manifest: &Manifest,
550549
changes: &Changes,
551-
notify_handler: &dyn Fn(Notification<'_>),
552550
config: &Option<Config>,
553551
) {
554552
// Add requested components
@@ -622,7 +620,6 @@ impl Update {
622620
return Err(ErrorKind::RequestedComponentsUnavailable(
623621
unavailable_components,
624622
new_manifest.clone(),
625-
toolchain_str.to_owned(),
626623
)
627624
.into());
628625
}

src/errors.rs

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::component_for_bin;
22
use crate::dist::manifest::{Component, Manifest};
33
use crate::dist::temp;
4+
use crate::dist::dist::Profile;
45
use error_chain::error_chain;
56
use error_chain::error_chain_processing;
67
use error_chain::{impl_error_chain_kind, impl_error_chain_processed, impl_extract_backtrace};
@@ -270,9 +271,9 @@ error_chain! {
270271
description("missing package for the target of a rename")
271272
display("server sent a broken manifest: missing package for the target of a rename {}", name)
272273
}
273-
RequestedComponentsUnavailable(c: Vec<Component>, manifest: Manifest, toolchain: String) {
274+
RequestedComponentsUnavailable(c: Vec<Component>, manifest: Manifest) {
274275
description("some requested components are unavailable to download")
275-
display("{} for channel '{}'", component_unavailable_msg(&c, &manifest), toolchain)
276+
display("{}", component_unavailable_msg(&c, &manifest))
276277
}
277278
UnknownMetadataVersion(v: String) {
278279
description("unknown metadata version")
@@ -313,7 +314,7 @@ error_chain! {
313314
display(
314315
"unknown profile name: '{}'; valid profile names are {}",
315316
p,
316-
dist::Profile::names()
317+
Profile::names()
317318
.iter()
318319
.map(|s| format!("'{}'", s))
319320
.collect::<Vec<_>>()
@@ -346,3 +347,41 @@ fn install_msg(bin: &str, toolchain: &str, is_default: bool) -> String {
346347
None => String::new(),
347348
}
348349
}
350+
351+
fn component_unavailable_msg(cs: &[Component], manifest: &Manifest) -> String {
352+
assert!(!cs.is_empty());
353+
354+
let mut buf = vec![];
355+
356+
if cs.len() == 1 {
357+
let _ = write!(
358+
buf,
359+
"component {} is unavailable for download",
360+
&cs[0].description(manifest)
361+
);
362+
} else {
363+
use itertools::Itertools;
364+
let same_target = cs
365+
.iter()
366+
.all(|c| c.target == cs[0].target || c.target.is_none());
367+
if same_target {
368+
let mut cs_strs = cs.iter().map(|c| format!("'{}'", c.short_name(manifest)));
369+
let cs_str = cs_strs.join(", ");
370+
let _ = write!(
371+
buf,
372+
"some components unavailable for download: {}\n{}",
373+
cs_str, TOOLSTATE_MSG,
374+
);
375+
} else {
376+
let mut cs_strs = cs.iter().map(|c| c.description(manifest));
377+
let cs_str = cs_strs.join(", ");
378+
let _ = write!(
379+
buf,
380+
"some components unavailable for download: {}\n{}",
381+
cs_str, TOOLSTATE_MSG,
382+
);
383+
}
384+
}
385+
386+
String::from_utf8(buf).expect("")
387+
}

src/toolchain.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,7 @@ impl<'a> Toolchain<'a> {
554554
false,
555555
&self.download_cfg(),
556556
&self.download_cfg().notify_handler,
557-
&toolchain.manifest_name(),
558-
)?;
557+
)?;
559558

560559
Ok(())
561560
} else {
@@ -607,7 +606,6 @@ impl<'a> Toolchain<'a> {
607606
false,
608607
&self.download_cfg(),
609608
&self.download_cfg().notify_handler,
610-
&toolchain.manifest_name(),
611609
)?;
612610

613611
Ok(())

src/utils/raw.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,6 @@ pub fn find_cmd<'a>(cmds: &[&'a str]) -> Option<&'a str> {
357357
pub fn open_browser(path: &Path) -> io::Result<bool> {
358358
#[cfg(not(windows))]
359359
fn inner(path: &Path) -> io::Result<bool> {
360-
use std::env;
361360
use std::process::Stdio;
362361

363362
let env_browser = env::var_os("BROWSER").map(|b| env::split_paths(&b).collect::<Vec<_>>());

0 commit comments

Comments
 (0)