about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorJonas Schievink <jonasschievink@gmail.com>2020-11-23 15:25:47 +0100
committerGitHub <noreply@github.com>2020-11-23 15:25:47 +0100
commitb4db342f512fabde89a9010ea9239795724deee1 (patch)
tree61c890bc6f7af4e3c0ca4f90deade8298d2fa9e1 /compiler
parent32be3ae06a3ec9b97dff0a16e9fbb2e2f260601f (diff)
parente0871cc0bedc9e7c6b0104600727a7109a2a0659 (diff)
downloadrust-b4db342f512fabde89a9010ea9239795724deee1.tar.gz
rust-b4db342f512fabde89a9010ea9239795724deee1.zip
Rollup merge of #79325 - LingMan:try_op, r=jonas-schievink
Reduce boilerplate with the `?` operator

`@rustbot` modify labels to +C-cleanup.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_builtin_macros/src/format_foreign.rs16
-rw-r--r--compiler/rustc_trait_selection/src/traits/select/mod.rs10
2 files changed, 9 insertions, 17 deletions
diff --git a/compiler/rustc_builtin_macros/src/format_foreign.rs b/compiler/rustc_builtin_macros/src/format_foreign.rs
index b69b00d65f2..f00dfd1241f 100644
--- a/compiler/rustc_builtin_macros/src/format_foreign.rs
+++ b/compiler/rustc_builtin_macros/src/format_foreign.rs
@@ -649,17 +649,13 @@ pub mod shell {
     impl<'a> Iterator for Substitutions<'a> {
         type Item = Substitution<'a>;
         fn next(&mut self) -> Option<Self::Item> {
-            match parse_next_substitution(self.s) {
-                Some((mut sub, tail)) => {
-                    self.s = tail;
-                    if let Some(InnerSpan { start, end }) = sub.position() {
-                        sub.set_position(start + self.pos, end + self.pos);
-                        self.pos += end;
-                    }
-                    Some(sub)
-                }
-                None => None,
+            let (mut sub, tail) = parse_next_substitution(self.s)?;
+            self.s = tail;
+            if let Some(InnerSpan { start, end }) = sub.position() {
+                sub.set_position(start + self.pos, end + self.pos);
+                self.pos += end;
             }
+            Some(sub)
         }
 
         fn size_hint(&self) -> (usize, Option<usize>) {
diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs
index 4189a81632a..5b31998b7d3 100644
--- a/compiler/rustc_trait_selection/src/traits/select/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs
@@ -2372,13 +2372,9 @@ impl<'o, 'tcx> Iterator for TraitObligationStackList<'o, 'tcx> {
     type Item = &'o TraitObligationStack<'o, 'tcx>;
 
     fn next(&mut self) -> Option<&'o TraitObligationStack<'o, 'tcx>> {
-        match self.head {
-            Some(o) => {
-                *self = o.previous;
-                Some(o)
-            }
-            None => None,
-        }
+        let o = self.head?;
+        *self = o.previous;
+        Some(o)
     }
 }