Skip to content

Commit

Permalink
sort the list of inference errors by span
Browse files Browse the repository at this point in the history
this should produce more error stability
  • Loading branch information
arielb1 committed Sep 24, 2017
1 parent 9d6b9d6 commit b6bce56
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,20 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
GenericBoundFailure(..) => true,
};

if errors.iter().all(|e| is_bound_failure(e)) {

let mut errors = if errors.iter().all(|e| is_bound_failure(e)) {
errors.clone()
} else {
errors.iter().filter(|&e| !is_bound_failure(e)).cloned().collect()
}
};

// sort the errors by span, for better error message stability.
errors.sort_by_key(|u| match *u {
ConcreteFailure(ref sro, _, _) => sro.span(),
GenericBoundFailure(ref sro, _, _) => sro.span(),
SubSupConflict(ref rvo, _, _, _, _) => rvo.span(),
});
errors
}

/// Adds a note if the types come from similarly named crates
Expand Down

0 comments on commit b6bce56

Please sign in to comment.