Skip to content

File tree

11 files changed

+25
-27
lines changed

11 files changed

+25
-27
lines changed
 

‎src/bootstrap/doc.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -914,13 +914,13 @@ fn symlink_dir_force(config: &Config, src: &Path, dst: &Path) -> io::Result<()>
914914
}
915915
if let Ok(m) = fs::symlink_metadata(dst) {
916916
if m.file_type().is_dir() {
917-
try!(fs::remove_dir_all(dst));
917+
fs::remove_dir_all(dst)?;
918918
} else {
919919
// handle directory junctions on windows by falling back to
920920
// `remove_dir`.
921-
try!(fs::remove_file(dst).or_else(|_| {
921+
fs::remove_file(dst).or_else(|_| {
922922
fs::remove_dir(dst)
923-
}));
923+
})?;
924924
}
925925
}
926926

‎src/bootstrap/util.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,11 @@ pub fn symlink_dir(config: &Config, src: &Path, dest: &Path) -> io::Result<()> {
203203
// We're using low-level APIs to create the junction, and these are more
204204
// picky about paths. For example, forward slashes cannot be used as a
205205
// path separator, so we should try to canonicalize the path first.
206-
let target = try!(fs::canonicalize(target));
206+
let target = fs::canonicalize(target)?;
207207

208-
try!(fs::create_dir(junction));
208+
fs::create_dir(junction)?;
209209

210-
let path = try!(to_u16s(junction));
210+
let path = to_u16s(junction)?;
211211

212212
unsafe {
213213
let h = CreateFileW(path.as_ptr(),

‎src/libcore/macros.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,14 @@ macro_rules! debug_assert_ne {
278278
///
279279
/// // The previous method of quick returning Errors
280280
/// fn write_to_file_using_try() -> Result<(), MyError> {
281-
/// let mut file = try!(File::create("my_best_friends.txt"));
282-
/// try!(file.write_all(b"This is a list of my best friends."));
281+
/// let mut file = r#try!(File::create("my_best_friends.txt"));
282+
/// r#try!(file.write_all(b"This is a list of my best friends."));
283283
/// Ok(())
284284
/// }
285285
///
286286
/// // This is equivalent to:
287287
/// fn write_to_file_using_match() -> Result<(), MyError> {
288-
/// let mut file = try!(File::create("my_best_friends.txt"));
288+
/// let mut file = r#try!(File::create("my_best_friends.txt"));
289289
/// match file.write_all(b"This is a list of my best friends.") {
290290
/// Ok(v) => v,
291291
/// Err(e) => return Err(From::from(e)),
@@ -296,14 +296,14 @@ macro_rules! debug_assert_ne {
296296
#[macro_export]
297297
#[stable(feature = "rust1", since = "1.0.0")]
298298
#[doc(alias = "?")]
299-
macro_rules! try {
299+
macro_rules! r#try {
300300
($expr:expr) => (match $expr {
301301
$crate::result::Result::Ok(val) => val,
302302
$crate::result::Result::Err(err) => {
303303
return $crate::result::Result::Err($crate::convert::From::from(err))
304304
}
305305
});
306-
($expr:expr,) => (try!($expr));
306+
($expr:expr,) => (r#try!($expr));
307307
}
308308

309309
/// Write formatted data into a buffer.

‎src/librustc_incremental/persist/fs.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ pub fn garbage_collect_session_directories(sess: &Session) -> io::Result<()> {
659659
let mut session_directories = FxHashSet::default();
660660
let mut lock_files = FxHashSet::default();
661661

662-
for dir_entry in try!(crate_directory.read_dir()) {
662+
for dir_entry in crate_directory.read_dir()? {
663663
let dir_entry = match dir_entry {
664664
Ok(dir_entry) => dir_entry,
665665
_ => {
@@ -887,7 +887,7 @@ fn all_except_most_recent(deletion_candidates: Vec<(SystemTime, PathBuf, Option<
887887
/// into the '\\?\' format, which supports much longer paths.
888888
fn safe_remove_dir_all(p: &Path) -> io::Result<()> {
889889
if p.exists() {
890-
let canonicalized = try!(p.canonicalize());
890+
let canonicalized = p.canonicalize()?;
891891
std_fs::remove_dir_all(canonicalized)
892892
} else {
893893
Ok(())
@@ -896,7 +896,7 @@ fn safe_remove_dir_all(p: &Path) -> io::Result<()> {
896896

897897
fn safe_remove_file(p: &Path) -> io::Result<()> {
898898
if p.exists() {
899-
let canonicalized = try!(p.canonicalize());
899+
let canonicalized = p.canonicalize()?;
900900
std_fs::remove_file(canonicalized)
901901
} else {
902902
Ok(())

‎src/librustc_mir/dataflow/move_paths/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> {
128128
proj: &PlaceProjection<'tcx>)
129129
-> Result<MovePathIndex, MoveError<'tcx>>
130130
{
131-
let base = try!(self.move_path_for(&proj.base));
131+
let base = self.move_path_for(&proj.base)?;
132132
let mir = self.builder.mir;
133133
let tcx = self.builder.tcx;
134134
let place_ty = proj.base.ty(mir, tcx).to_ty(tcx);

‎src/librustc_target/spec/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ impl Target {
995995

996996
key!(is_builtin, bool);
997997
key!(linker, optional);
998-
try!(key!(lld_flavor, LldFlavor));
998+
key!(lld_flavor, LldFlavor)?;
999999
key!(pre_link_args, link_args);
10001000
key!(pre_link_args_crt, link_args);
10011001
key!(pre_link_objects_exe, list);
@@ -1038,7 +1038,7 @@ impl Target {
10381038
key!(no_default_libraries, bool);
10391039
key!(position_independent_executables, bool);
10401040
key!(needs_plt, bool);
1041-
try!(key!(relro_level, RelroLevel));
1041+
key!(relro_level, RelroLevel)?;
10421042
key!(archive_format);
10431043
key!(allow_asm, bool);
10441044
key!(custom_unwind_resume, bool);
@@ -1048,7 +1048,7 @@ impl Target {
10481048
key!(max_atomic_width, Option<u64>);
10491049
key!(min_atomic_width, Option<u64>);
10501050
key!(atomic_cas, bool);
1051-
try!(key!(panic_strategy, PanicStrategy));
1051+
key!(panic_strategy, PanicStrategy)?;
10521052
key!(crt_static_allows_dylibs, bool);
10531053
key!(crt_static_default, bool);
10541054
key!(crt_static_respected, bool);

‎src/libstd/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2065,7 +2065,7 @@ impl DirBuilder {
20652065
Err(e) => return Err(e),
20662066
}
20672067
match path.parent() {
2068-
Some(p) => try!(self.create_dir_all(p)),
2068+
Some(p) => self.create_dir_all(p)?,
20692069
None => return Err(io::Error::new(io::ErrorKind::Other, "failed to create whole tree")),
20702070
}
20712071
match self.inner.mkdir(path) {

‎src/libstd/sys/windows/stdio.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub fn get(handle: c::DWORD) -> io::Result<Output> {
4848
}
4949

5050
fn write(handle: c::DWORD, data: &[u8]) -> io::Result<usize> {
51-
let handle = match try!(get(handle)) {
51+
let handle = match get(handle)? {
5252
Output::Console(c) => c,
5353
Output::Pipe(p) => {
5454
let handle = Handle::new(p);
@@ -99,7 +99,7 @@ impl Stdin {
9999
}
100100

101101
pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
102-
let handle = match try!(get(c::STD_INPUT_HANDLE)) {
102+
let handle = match get(c::STD_INPUT_HANDLE)? {
103103
Output::Console(c) => c,
104104
Output::Pipe(p) => {
105105
let handle = Handle::new(p);

‎src/libsyntax/parse/parser.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -3145,7 +3145,7 @@ impl<'a> Parser<'a> {
31453145
RangeLimits::Closed
31463146
};
31473147

3148-
let r = try!(self.mk_range(Some(lhs), rhs, limits));
3148+
let r = self.mk_range(Some(lhs), rhs, limits)?;
31493149
lhs = self.mk_expr(lhs_span.to(rhs_span), r, ThinVec::new());
31503150
break
31513151
}
@@ -3353,9 +3353,7 @@ impl<'a> Parser<'a> {
33533353
RangeLimits::Closed
33543354
};
33553355

3356-
let r = try!(self.mk_range(None,
3357-
opt_end,
3358-
limits));
3356+
let r = self.mk_range(None, opt_end, limits)?;
33593357
Ok(self.mk_expr(lo.to(hi), r, attrs))
33603358
}
33613359

‎src/libsyntax/print/pprust.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,7 @@ impl<'a> State<'a> {
15251525

15261526
pub fn print_defaultness(&mut self, defaultness: ast::Defaultness) -> io::Result<()> {
15271527
if let ast::Defaultness::Default = defaultness {
1528-
try!(self.word_nbsp("default"));
1528+
self.word_nbsp("default")?;
15291529
}
15301530
Ok(())
15311531
}

‎src/libsyntax_ext/format_foreign.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ pub mod printf {
264264
match *self {
265265
Num::Num(n) => write!(s, "{}", n),
266266
Num::Arg(n) => {
267-
let n = try!(n.checked_sub(1).ok_or(::std::fmt::Error));
267+
let n = n.checked_sub(1).ok_or(::std::fmt::Error)?;
268268
write!(s, "{}$", n)
269269
},
270270
Num::Next => write!(s, "*"),

0 commit comments

Comments
 (0)
Please sign in to comment.