Skip to content

Commit

Permalink
[easy][move] Sort errors by first Loc when displaying
Browse files Browse the repository at this point in the history
- Sort errors by the initial Loc, makes reading errors a lot easier in big lists
  • Loading branch information
Todd Nowacki committed Nov 8, 2019
1 parent de7b695 commit f0a754e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion language/move-lang/src/errors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,13 @@ fn render_errors<W: WriteColor>(
writer: &mut W,
files: &Files,
file_mapping: &FileMapping,
errors: Errors,
mut errors: Errors,
) {
errors.sort_by(|e1, e2| {
let loc1: &Loc = &e1[0].0;
let loc2: &Loc = &e2[0].0;
loc1.cmp(loc2)
});
let mut seen: HashSet<HashableError> = HashSet::new();
for error in errors.into_iter() {
let hashable_error = hashable_error(&error);
Expand Down
2 changes: 1 addition & 1 deletion language/move-lang/src/shared/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl TryFrom<&[u8]> for Address {
// Loc
//**************************************************************************************************

#[derive(Debug, Copy, Clone, Default, Eq, PartialEq)]
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Ord, PartialOrd)]
pub struct Loc {
file: &'static str,
span: Span,
Expand Down

0 comments on commit f0a754e

Please sign in to comment.