]> git.lizzy.rs Git - rust.git/commitdiff
Remove `else`, unindent.
authorCorey Farwell <coreyf@rwell.org>
Sun, 19 Feb 2017 15:46:43 +0000 (10:46 -0500)
committerCorey Farwell <coreyf@rwell.org>
Mon, 20 Feb 2017 16:40:02 +0000 (11:40 -0500)
src/librustc/traits/error_reporting.rs

index a9f3c54bd73e08d3a3f3a90be497eec9416bfcf8..193c07166b04e6924a4f4709424539802e157e7f 100644 (file)
@@ -533,55 +533,54 @@ pub fn report_selection_error(&self,
 
                         if self.tcx.sess.has_errors() && trait_predicate.references_error() {
                             return;
+                        }
+                        let trait_ref = trait_predicate.to_poly_trait_ref();
+                        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,
+                            E0277,
+                            "the trait bound `{}` is not satisfied{}",
+                            trait_ref.to_predicate(),
+                            post_message);
+                        err.span_label(span,
+                                        &format!("{}the trait `{}` is not \
+                                                    implemented for `{}`",
+                                                pre_message,
+                                                trait_ref,
+                                                trait_ref.self_ty()));
+
+                        // Try to report a help message
+
+                        if !trait_ref.has_infer_types() &&
+                            self.predicate_can_apply(trait_ref) {
+                            // If a where-clause may be useful, remind the
+                            // user that they can add it.
+                            //
+                            // don't display an on-unimplemented note, as
+                            // these notes will often be of the form
+                            //     "the type `T` can't be frobnicated"
+                            // which is somewhat confusing.
+                            err.help(&format!("consider adding a `where {}` bound",
+                                                trait_ref.to_predicate()));
+                        } else if let Some(s) = self.on_unimplemented_note(trait_ref,
+                                                                            obligation) {
+                            // If it has a custom "#[rustc_on_unimplemented]"
+                            // error message, let's display it!
+                            err.note(&s);
                         } else {
-                            let trait_ref = trait_predicate.to_poly_trait_ref();
-                            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,
-                                E0277,
-                                "the trait bound `{}` is not satisfied{}",
-                                trait_ref.to_predicate(),
-                                post_message);
-                            err.span_label(span,
-                                            &format!("{}the trait `{}` is not \
-                                                        implemented for `{}`",
-                                                    pre_message,
-                                                    trait_ref,
-                                                    trait_ref.self_ty()));
-
-                            // Try to report a help message
-
-                            if !trait_ref.has_infer_types() &&
-                                self.predicate_can_apply(trait_ref) {
-                                // If a where-clause may be useful, remind the
-                                // user that they can add it.
-                                //
-                                // don't display an on-unimplemented note, as
-                                // these notes will often be of the form
-                                //     "the type `T` can't be frobnicated"
-                                // which is somewhat confusing.
-                                err.help(&format!("consider adding a `where {}` bound",
-                                                    trait_ref.to_predicate()));
-                            } else if let Some(s) = self.on_unimplemented_note(trait_ref,
-                                                                                obligation) {
-                                // If it has a custom "#[rustc_on_unimplemented]"
-                                // error message, let's display it!
-                                err.note(&s);
-                            } else {
-                                // If we can't show anything useful, try to find
-                                // similar impls.
-                                let impl_candidates =
-                                    self.find_similar_impl_candidates(trait_ref);
-                                if impl_candidates.len() > 0 {
-                                    self.report_similar_impl_candidates(trait_ref, &mut err);
-                                }
+                            // If we can't show anything useful, try to find
+                            // similar impls.
+                            let impl_candidates =
+                                self.find_similar_impl_candidates(trait_ref);
+                            if impl_candidates.len() > 0 {
+                                self.report_similar_impl_candidates(trait_ref, &mut err);
                             }
-                            err
                         }
+                        err
                     }
 
                     ty::Predicate::Equate(ref predicate) => {