Skip to content

Commit 10639d7

Browse files
committed
Add early return, remove else, unindent.
1 parent 2436d73 commit 10639d7

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

src/librustc/traits/error_reporting.rs

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -708,46 +708,46 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
708708
let trait_ref = data.to_poly_trait_ref();
709709
let self_ty = trait_ref.self_ty();
710710
if predicate.references_error() {
711-
} else {
712-
// Typically, this ambiguity should only happen if
713-
// there are unresolved type inference variables
714-
// (otherwise it would suggest a coherence
715-
// failure). But given #21974 that is not necessarily
716-
// the case -- we can have multiple where clauses that
717-
// are only distinguished by a region, which results
718-
// in an ambiguity even when all types are fully
719-
// known, since we don't dispatch based on region
720-
// relationships.
721-
722-
// This is kind of a hack: it frequently happens that some earlier
723-
// error prevents types from being fully inferred, and then we get
724-
// a bunch of uninteresting errors saying something like "<generic
725-
// #0> doesn't implement Sized". It may even be true that we
726-
// could just skip over all checks where the self-ty is an
727-
// inference variable, but I was afraid that there might be an
728-
// inference variable created, registered as an obligation, and
729-
// then never forced by writeback, and hence by skipping here we'd
730-
// be ignoring the fact that we don't KNOW the type works
731-
// out. Though even that would probably be harmless, given that
732-
// we're only talking about builtin traits, which are known to be
733-
// inhabited. But in any case I just threw in this check for
734-
// has_errors() to be sure that compilation isn't happening
735-
// anyway. In that case, why inundate the user.
736-
if !self.tcx.sess.has_errors() {
737-
if
738-
self.tcx.lang_items.sized_trait()
739-
.map_or(false, |sized_id| sized_id == trait_ref.def_id())
740-
{
741-
self.need_type_info(obligation, self_ty);
742-
} else {
743-
let mut err = struct_span_err!(self.tcx.sess,
744-
obligation.cause.span, E0283,
745-
"type annotations required: \
746-
cannot resolve `{}`",
747-
predicate);
748-
self.note_obligation_cause(&mut err, obligation);
749-
err.emit();
750-
}
711+
return;
712+
}
713+
// Typically, this ambiguity should only happen if
714+
// there are unresolved type inference variables
715+
// (otherwise it would suggest a coherence
716+
// failure). But given #21974 that is not necessarily
717+
// the case -- we can have multiple where clauses that
718+
// are only distinguished by a region, which results
719+
// in an ambiguity even when all types are fully
720+
// known, since we don't dispatch based on region
721+
// relationships.
722+
723+
// This is kind of a hack: it frequently happens that some earlier
724+
// error prevents types from being fully inferred, and then we get
725+
// a bunch of uninteresting errors saying something like "<generic
726+
// #0> doesn't implement Sized". It may even be true that we
727+
// could just skip over all checks where the self-ty is an
728+
// inference variable, but I was afraid that there might be an
729+
// inference variable created, registered as an obligation, and
730+
// then never forced by writeback, and hence by skipping here we'd
731+
// be ignoring the fact that we don't KNOW the type works
732+
// out. Though even that would probably be harmless, given that
733+
// we're only talking about builtin traits, which are known to be
734+
// inhabited. But in any case I just threw in this check for
735+
// has_errors() to be sure that compilation isn't happening
736+
// anyway. In that case, why inundate the user.
737+
if !self.tcx.sess.has_errors() {
738+
if
739+
self.tcx.lang_items.sized_trait()
740+
.map_or(false, |sized_id| sized_id == trait_ref.def_id())
741+
{
742+
self.need_type_info(obligation, self_ty);
743+
} else {
744+
let mut err = struct_span_err!(self.tcx.sess,
745+
obligation.cause.span, E0283,
746+
"type annotations required: \
747+
cannot resolve `{}`",
748+
predicate);
749+
self.note_obligation_cause(&mut err, obligation);
750+
err.emit();
751751
}
752752
}
753753
}

0 commit comments

Comments
 (0)