]> git.lizzy.rs Git - rust.git/commitdiff
Rewrite `match` to use combinators.
authorCorey Farwell <coreyf@rwell.org>
Sun, 19 Feb 2017 15:41:36 +0000 (10:41 -0500)
committerCorey Farwell <coreyf@rwell.org>
Mon, 20 Feb 2017 16:40:01 +0000 (11:40 -0500)
src/librustc/traits/error_reporting.rs

index 411e986f62d900e21622cd072fc5778f9db97e6a..a9f3c54bd73e08d3a3f3a90be497eec9416bfcf8 100644 (file)
@@ -535,14 +535,10 @@ pub fn report_selection_error(&self,
                             return;
                         } else {
                             let trait_ref = trait_predicate.to_poly_trait_ref();
-                            let (post_message, pre_message) = match self.get_parent_trait_ref(
-                                &obligation.cause.code)
-                            {
-                                Some(t) => {
-                                    (format!(" in `{}`", t), format!("within `{}`, ", t))
-                                }
-                                None => (String::new(), String::new()),
-                            };
+                            let (post_message, pre_message) =
+                                self.get_parent_trait_ref(&obligation.cause.code)
+                                    .map(|t| (format!(" in `{}`", t), format!("within `{}`, ", t)))
+                                    .unwrap_or((String::new(), String::new()));
                             let mut err = struct_span_err!(
                                 self.tcx.sess,
                                 span,