Skip to content

Commit 166bb9f

Browse files
authored
Merge pull request #1420 from rust-lang-nursery/db-do-or-do-not
There is no try...
2 parents a835916 + ccd49b6 commit 166bb9f

27 files changed

+729
-905
lines changed

src/rustup-cli/common.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use wait_timeout::ChildExt;
1919
pub fn confirm(question: &str, default: bool) -> Result<bool> {
2020
print!("{} ", question);
2121
let _ = std::io::stdout().flush();
22-
let input = try!(read_line());
22+
let input = read_line()?;
2323

2424
let r = match &*input {
2525
"y" | "Y" => true,
@@ -46,7 +46,7 @@ pub fn confirm_advanced() -> Result<Confirm> {
4646
println!("3) Cancel installation");
4747

4848
let _ = std::io::stdout().flush();
49-
let input = try!(read_line());
49+
let input = read_line()?;
5050

5151
let r = match &*input {
5252
"1" | "" => Confirm::Yes,
@@ -62,7 +62,7 @@ pub fn confirm_advanced() -> Result<Confirm> {
6262
pub fn question_str(question: &str, default: &str) -> Result<String> {
6363
println!("{}", question);
6464
let _ = std::io::stdout().flush();
65-
let input = try!(read_line());
65+
let input = read_line()?;
6666

6767
println!("");
6868

@@ -77,7 +77,7 @@ pub fn question_bool(question: &str, default: bool) -> Result<bool> {
7777
println!("{}", question);
7878

7979
let _ = std::io::stdout().flush();
80-
let input = try!(read_line());
80+
let input = read_line()?;
8181

8282
println!("");
8383

@@ -108,7 +108,7 @@ pub fn set_globals(verbose: bool) -> Result<Cfg> {
108108

109109
let download_tracker = RefCell::new(DownloadTracker::new());
110110

111-
Ok(try!(Cfg::from_env(Arc::new(move |n: Notification| {
111+
Ok(Cfg::from_env(Arc::new(move |n: Notification| {
112112
if download_tracker.borrow_mut().handle_notification(&n) {
113113
return;
114114
}
@@ -129,7 +129,7 @@ pub fn set_globals(verbose: bool) -> Result<Cfg> {
129129
err!("{}", n);
130130
}
131131
}
132-
}))))
132+
}))?)
133133
}
134134

135135
pub fn show_channel_update(
@@ -199,26 +199,26 @@ fn show_channel_updates(
199199
}
200200

201201
pub fn update_all_channels(cfg: &Cfg, self_update: bool, force_update: bool) -> Result<()> {
202-
let toolchains = try!(cfg.update_all_channels(force_update));
202+
let toolchains = cfg.update_all_channels(force_update)?;
203203

204204
if toolchains.is_empty() {
205205
info!("no updatable toolchains installed");
206206
}
207207

208208
let setup_path = if self_update {
209-
try!(self_update::prepare_update())
209+
self_update::prepare_update()?
210210
} else {
211211
None
212212
};
213213

214214
if !toolchains.is_empty() {
215215
println!("");
216216

217-
try!(show_channel_updates(cfg, toolchains));
217+
show_channel_updates(cfg, toolchains)?;
218218
}
219219

220220
if let Some(ref setup_path) = setup_path {
221-
try!(self_update::run_update(setup_path));
221+
self_update::run_update(setup_path)?;
222222

223223
unreachable!(); // update exits on success
224224
} else if self_update {
@@ -282,7 +282,7 @@ pub fn rustc_version(toolchain: &Toolchain) -> String {
282282

283283
pub fn list_targets(toolchain: &Toolchain) -> Result<()> {
284284
let mut t = term2::stdout();
285-
for component in try!(toolchain.list_components()) {
285+
for component in toolchain.list_components()? {
286286
if component.component.pkg == "rust-std" {
287287
let target = component
288288
.component
@@ -308,7 +308,7 @@ pub fn list_targets(toolchain: &Toolchain) -> Result<()> {
308308

309309
pub fn list_components(toolchain: &Toolchain) -> Result<()> {
310310
let mut t = term2::stdout();
311-
for component in try!(toolchain.list_components()) {
311+
for component in toolchain.list_components()? {
312312
let name = component.component.name();
313313
if component.required {
314314
let _ = t.attr(term2::Attr::Bold);
@@ -327,7 +327,7 @@ pub fn list_components(toolchain: &Toolchain) -> Result<()> {
327327
}
328328

329329
pub fn list_toolchains(cfg: &Cfg) -> Result<()> {
330-
let toolchains = try!(cfg.list_toolchains());
330+
let toolchains = cfg.list_toolchains()?;
331331

332332
if toolchains.is_empty() {
333333
println!("no installed toolchains");
@@ -351,7 +351,7 @@ pub fn list_toolchains(cfg: &Cfg) -> Result<()> {
351351
}
352352

353353
pub fn list_overrides(cfg: &Cfg) -> Result<()> {
354-
let overrides = try!(cfg.settings_file.with(|s| Ok(s.overrides.clone())));
354+
let overrides = cfg.settings_file.with(|s| Ok(s.overrides.clone()))?;
355355

356356
if overrides.is_empty() {
357357
println!("no overrides");

src/rustup-cli/proxy_mode.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::path::PathBuf;
99
use job;
1010

1111
pub fn main() -> Result<()> {
12-
try!(::self_update::cleanup_self_updater());
12+
::self_update::cleanup_self_updater()?;
1313

1414
let _setup = job::setup();
1515

@@ -19,7 +19,7 @@ pub fn main() -> Result<()> {
1919
let arg0 = arg0.as_ref()
2020
.and_then(|a| a.file_name())
2121
.and_then(|a| a.to_str());
22-
let ref arg0 = try!(arg0.ok_or(ErrorKind::NoExeName));
22+
let ref arg0 = arg0.ok_or(ErrorKind::NoExeName)?;
2323

2424
// Check for a toolchain specifier.
2525
let arg1 = args.next();
@@ -38,17 +38,17 @@ pub fn main() -> Result<()> {
3838
env::args_os().skip(2).collect()
3939
};
4040

41-
let cfg = try!(set_globals(false));
42-
try!(cfg.check_metadata_version());
43-
try!(direct_proxy(&cfg, arg0, toolchain, &cmd_args));
41+
let cfg = set_globals(false)?;
42+
cfg.check_metadata_version()?;
43+
direct_proxy(&cfg, arg0, toolchain, &cmd_args)?;
4444

4545
Ok(())
4646
}
4747

4848
fn direct_proxy(cfg: &Cfg, arg0: &str, toolchain: Option<&str>, args: &[OsString]) -> Result<()> {
4949
let cmd = match toolchain {
50-
None => try!(cfg.create_command_for_dir(&try!(utils::current_dir()), arg0)),
51-
Some(tc) => try!(cfg.create_command_for_toolchain(tc, false, arg0)),
50+
None => cfg.create_command_for_dir(&utils::current_dir()?, arg0)?,
51+
Some(tc) => cfg.create_command_for_toolchain(tc, false, arg0)?,
5252
};
53-
Ok(try!(run_command_for_dir(cmd, arg0, args, &cfg)))
53+
Ok(run_command_for_dir(cmd, arg0, args, &cfg)?)
5454
}

0 commit comments

Comments
 (0)