Skip to content

Commit b76f818

Browse files
committedMar 23, 2016
Auto merge of #32390 - japaric:untry, r=pnkfelix
convert 99.9% of `try!`s to `?`s The first commit is an automated conversion using the [untry] tool and the following command: ``` $ find -name '*.rs' -type f | xargs untry ``` at the root of the Rust repo. [untry]: https://github.com/japaric/untry cc @rust-lang/lang @alexcrichton @brson
2 parents 26cfc26 + c063c51 commit b76f818

File tree

147 files changed

+4050
-4046
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+4050
-4046
lines changed
 

‎src/compiletest/compiletest.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#![feature(rustc_private)]
1616
#![feature(str_char)]
1717
#![feature(test)]
18+
#![feature(question_mark)]
1819

1920
#![deny(warnings)]
2021

@@ -280,16 +281,16 @@ fn collect_tests_from_dir(config: &Config,
280281
-> io::Result<()> {
281282
// Ignore directories that contain a file
282283
// `compiletest-ignore-dir`.
283-
for file in try!(fs::read_dir(dir)) {
284-
let file = try!(file);
284+
for file in fs::read_dir(dir)? {
285+
let file = file?;
285286
if file.file_name() == *"compiletest-ignore-dir" {
286287
return Ok(());
287288
}
288289
}
289290

290-
let dirs = try!(fs::read_dir(dir));
291+
let dirs = fs::read_dir(dir)?;
291292
for file in dirs {
292-
let file = try!(file);
293+
let file = file?;
293294
let file_path = file.path();
294295
debug!("inspecting file {:?}", file_path.display());
295296
if is_test(config, &file_path) {
@@ -310,11 +311,11 @@ fn collect_tests_from_dir(config: &Config,
310311
tests.push(make_test(config, &paths))
311312
} else if file_path.is_dir() {
312313
let relative_file_path = relative_dir_path.join(file.file_name());
313-
try!(collect_tests_from_dir(config,
314-
base,
315-
&file_path,
316-
&relative_file_path,
317-
tests));
314+
collect_tests_from_dir(config,
315+
base,
316+
&file_path,
317+
&relative_file_path,
318+
tests)?;
318319
}
319320
}
320321
Ok(())

‎src/libcore/fmt/builders.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl<'a, 'b: 'a> fmt::Write for PadAdapter<'a, 'b> {
2929
fn write_str(&mut self, mut s: &str) -> fmt::Result {
3030
while !s.is_empty() {
3131
if self.on_newline {
32-
try!(self.fmt.write_str(" "));
32+
self.fmt.write_str(" ")?;
3333
}
3434

3535
let split = match s.find('\n') {
@@ -42,7 +42,7 @@ impl<'a, 'b: 'a> fmt::Write for PadAdapter<'a, 'b> {
4242
s.len()
4343
}
4444
};
45-
try!(self.fmt.write_str(&s[..split]));
45+
self.fmt.write_str(&s[..split])?;
4646
s = &s[split..];
4747
}
4848

@@ -169,10 +169,10 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
169169
if self.fields > 0 {
170170
self.result = self.result.and_then(|_| {
171171
if self.is_pretty() {
172-
try!(self.fmt.write_str("\n"));
172+
self.fmt.write_str("\n")?;
173173
}
174174
if self.fields == 1 && self.empty_name {
175-
try!(self.fmt.write_str(","));
175+
self.fmt.write_str(",")?;
176176
}
177177
self.fmt.write_str(")")
178178
});

0 commit comments

Comments
 (0)
Please sign in to comment.