about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMasaki Hara <ackie.h.gmai@gmail.com>2017-06-04 14:10:14 +0900
committerMasaki Hara <ackie.h.gmai@gmail.com>2017-06-07 12:15:39 +0900
commitab72611d8f664684dbd5dd2efe6fd7edff53ee5d (patch)
treebe15f7c11d1cc858e8286a57851374cf9d1cbceb /src
parent76242aebb9d47558124c991a6faf0eb706d35703 (diff)
downloadrust-ab72611d8f664684dbd5dd2efe6fd7edff53ee5d.tar.gz
rust-ab72611d8f664684dbd5dd2efe6fd7edff53ee5d.zip
Replace some matches with try.
Diffstat (limited to 'src')
-rw-r--r--src/librustc_resolve/macros.rs5
-rw-r--r--src/libsyntax/parse/parser.rs5
-rw-r--r--src/libsyntax/ptr.rs5
3 files changed, 3 insertions, 12 deletions
diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs
index a950a9a23e4..60c07eda4d5 100644
--- a/src/librustc_resolve/macros.rs
+++ b/src/librustc_resolve/macros.rs
@@ -285,10 +285,7 @@ impl<'a> base::Resolver for Resolver<'a> {
                      -> Result<Option<Rc<SyntaxExtension>>, Determinacy> {
         let def = match invoc.kind {
             InvocationKind::Attr { attr: None, .. } => return Ok(None),
-            _ => match self.resolve_invoc_to_def(invoc, scope, force) {
-                Ok(def) => def,
-                Err(determinacy) => return Err(determinacy),
-            },
+            _ => self.resolve_invoc_to_def(invoc, scope, force)?,
         };
 
         self.macro_defs.insert(invoc.expansion_data.mark, def.def_id());
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index d9cb2b4ab7d..1e156ed07b0 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -1249,10 +1249,7 @@ impl<'a> Parser<'a> {
             let mac = respan(lo.to(self.prev_span), Mac_ { path: pth, tts: tts });
             (keywords::Invalid.ident(), ast::TraitItemKind::Macro(mac))
         } else {
-            let (constness, unsafety, abi) = match self.parse_fn_front_matter() {
-                Ok(cua) => cua,
-                Err(e) => return Err(e),
-            };
+            let (constness, unsafety, abi) = self.parse_fn_front_matter()?;
 
             let ident = self.parse_ident()?;
             let mut generics = self.parse_generics()?;
diff --git a/src/libsyntax/ptr.rs b/src/libsyntax/ptr.rs
index 15111bbba0a..d51ff9860ac 100644
--- a/src/libsyntax/ptr.rs
+++ b/src/libsyntax/ptr.rs
@@ -211,10 +211,7 @@ impl<T: Encodable> Encodable for P<[T]> {
 
 impl<T: Decodable> Decodable for P<[T]> {
     fn decode<D: Decoder>(d: &mut D) -> Result<P<[T]>, D::Error> {
-        Ok(P::from_vec(match Decodable::decode(d) {
-            Ok(t) => t,
-            Err(e) => return Err(e)
-        }))
+        Ok(P::from_vec(Decodable::decode(d)?))
     }
 }