Skip to content

Commit 83fe48d

Browse files
committed
Remove else, unindent.
1 parent de2f7e1 commit 83fe48d

File tree

1 file changed

+45
-46
lines changed

1 file changed

+45
-46
lines changed

src/librustc/traits/error_reporting.rs

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -533,55 +533,54 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
533533

534534
if self.tcx.sess.has_errors() && trait_predicate.references_error() {
535535
return;
536+
}
537+
let trait_ref = trait_predicate.to_poly_trait_ref();
538+
let (post_message, pre_message) =
539+
self.get_parent_trait_ref(&obligation.cause.code)
540+
.map(|t| (format!(" in `{}`", t), format!("within `{}`, ", t)))
541+
.unwrap_or((String::new(), String::new()));
542+
let mut err = struct_span_err!(
543+
self.tcx.sess,
544+
span,
545+
E0277,
546+
"the trait bound `{}` is not satisfied{}",
547+
trait_ref.to_predicate(),
548+
post_message);
549+
err.span_label(span,
550+
&format!("{}the trait `{}` is not \
551+
implemented for `{}`",
552+
pre_message,
553+
trait_ref,
554+
trait_ref.self_ty()));
555+
556+
// Try to report a help message
557+
558+
if !trait_ref.has_infer_types() &&
559+
self.predicate_can_apply(trait_ref) {
560+
// If a where-clause may be useful, remind the
561+
// user that they can add it.
562+
//
563+
// don't display an on-unimplemented note, as
564+
// these notes will often be of the form
565+
// "the type `T` can't be frobnicated"
566+
// which is somewhat confusing.
567+
err.help(&format!("consider adding a `where {}` bound",
568+
trait_ref.to_predicate()));
569+
} else if let Some(s) = self.on_unimplemented_note(trait_ref,
570+
obligation) {
571+
// If it has a custom "#[rustc_on_unimplemented]"
572+
// error message, let's display it!
573+
err.note(&s);
536574
} else {
537-
let trait_ref = trait_predicate.to_poly_trait_ref();
538-
let (post_message, pre_message) =
539-
self.get_parent_trait_ref(&obligation.cause.code)
540-
.map(|t| (format!(" in `{}`", t), format!("within `{}`, ", t)))
541-
.unwrap_or((String::new(), String::new()));
542-
let mut err = struct_span_err!(
543-
self.tcx.sess,
544-
span,
545-
E0277,
546-
"the trait bound `{}` is not satisfied{}",
547-
trait_ref.to_predicate(),
548-
post_message);
549-
err.span_label(span,
550-
&format!("{}the trait `{}` is not \
551-
implemented for `{}`",
552-
pre_message,
553-
trait_ref,
554-
trait_ref.self_ty()));
555-
556-
// Try to report a help message
557-
558-
if !trait_ref.has_infer_types() &&
559-
self.predicate_can_apply(trait_ref) {
560-
// If a where-clause may be useful, remind the
561-
// user that they can add it.
562-
//
563-
// don't display an on-unimplemented note, as
564-
// these notes will often be of the form
565-
// "the type `T` can't be frobnicated"
566-
// which is somewhat confusing.
567-
err.help(&format!("consider adding a `where {}` bound",
568-
trait_ref.to_predicate()));
569-
} else if let Some(s) = self.on_unimplemented_note(trait_ref,
570-
obligation) {
571-
// If it has a custom "#[rustc_on_unimplemented]"
572-
// error message, let's display it!
573-
err.note(&s);
574-
} else {
575-
// If we can't show anything useful, try to find
576-
// similar impls.
577-
let impl_candidates =
578-
self.find_similar_impl_candidates(trait_ref);
579-
if impl_candidates.len() > 0 {
580-
self.report_similar_impl_candidates(trait_ref, &mut err);
581-
}
575+
// If we can't show anything useful, try to find
576+
// similar impls.
577+
let impl_candidates =
578+
self.find_similar_impl_candidates(trait_ref);
579+
if impl_candidates.len() > 0 {
580+
self.report_similar_impl_candidates(trait_ref, &mut err);
582581
}
583-
err
584582
}
583+
err
585584
}
586585

587586
ty::Predicate::Equate(ref predicate) => {

0 commit comments

Comments
 (0)