Skip to content

Commit b6bce56

Browse files
committed
sort the list of inference errors by span
this should produce more error stability
1 parent 9d6b9d6 commit b6bce56

File tree

1 file changed

+11
-2
lines changed
  • src/librustc/infer/error_reporting

1 file changed

+11
-2
lines changed

src/librustc/infer/error_reporting/mod.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,20 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
333333
GenericBoundFailure(..) => true,
334334
};
335335

336-
if errors.iter().all(|e| is_bound_failure(e)) {
336+
337+
let mut errors = if errors.iter().all(|e| is_bound_failure(e)) {
337338
errors.clone()
338339
} else {
339340
errors.iter().filter(|&e| !is_bound_failure(e)).cloned().collect()
340-
}
341+
};
342+
343+
// sort the errors by span, for better error message stability.
344+
errors.sort_by_key(|u| match *u {
345+
ConcreteFailure(ref sro, _, _) => sro.span(),
346+
GenericBoundFailure(ref sro, _, _) => sro.span(),
347+
SubSupConflict(ref rvo, _, _, _, _) => rvo.span(),
348+
});
349+
errors
341350
}
342351

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

0 commit comments

Comments
 (0)