Skip to content

Commit

Permalink
sort strings on output
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Apr 23, 2018
1 parent 7fa3c8f commit 2c5fbe2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
23 changes: 16 additions & 7 deletions src/librustc_traits/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,22 @@ impl<'a, 'tcx> ClauseDumper<'a, 'tcx> {
.sess
.struct_span_err(attr.span, "program clause dump");

for clause in clauses.iter() {
// Skip the top-level binder for a less verbose output
let program_clause = match clause {
Clause::Implies(program_clause) => program_clause,
Clause::ForAll(program_clause) => program_clause.skip_binder(),
};
err.note(&format!("{}", program_clause));
let mut strings: Vec<_> = clauses
.iter()
.map(|clause| {
// Skip the top-level binder for a less verbose output
let program_clause = match clause {
Clause::Implies(program_clause) => program_clause,
Clause::ForAll(program_clause) => program_clause.skip_binder(),
};
format!("{}", program_clause)
})
.collect();

strings.sort();

for string in strings {
err.note(&string);
}

err.emit();
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/chalkify/lower_env1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ error: program clause dump
LL | #[rustc_dump_program_clauses] //~ ERROR program clause dump
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: Implemented(Self: Bar) :- FromEnv(Self: Bar).
= note: FromEnv(Self: Bar) :- FromEnv(Self: Bar).
= note: FromEnv(Self: Foo) :- FromEnv(Self: Bar).
= note: Implemented(Self: Bar) :- FromEnv(Self: Bar).

error: program clause dump
--> $DIR/lower_env1.rs:19:1
|
LL | #[rustc_dump_env_program_clauses] //~ ERROR program clause dump
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: Implemented(Self: std::marker::Sized) :- FromEnv(Self: std::marker::Sized).
= note: Implemented(Self: Bar) :- FromEnv(Self: Bar).
= note: FromEnv(Self: Bar) :- FromEnv(Self: Bar).
= note: FromEnv(Self: Foo) :- FromEnv(Self: Bar).
= note: Implemented(Self: Bar) :- FromEnv(Self: Bar).
= note: Implemented(Self: Foo) :- FromEnv(Self: Foo).
= note: Implemented(Self: std::marker::Sized) :- FromEnv(Self: std::marker::Sized).

error: aborting due to 2 previous errors

2 changes: 1 addition & 1 deletion src/test/ui/chalkify/lower_trait.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ error: program clause dump
LL | #[rustc_dump_program_clauses] //~ ERROR program clause dump
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: Implemented(Self: Foo<S, T, U>) :- FromEnv(Self: Foo<S, T, U>).
= note: FromEnv(S: std::marker::Sized) :- FromEnv(Self: Foo<S, T, U>).
= note: FromEnv(T: std::marker::Sized) :- FromEnv(Self: Foo<S, T, U>).
= note: FromEnv(U: std::marker::Sized) :- FromEnv(Self: Foo<S, T, U>).
= note: Implemented(Self: Foo<S, T, U>) :- FromEnv(Self: Foo<S, T, U>).

error: aborting due to previous error

4 changes: 2 additions & 2 deletions src/test/ui/chalkify/lower_trait_higher_rank.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ error: program clause dump
LL | #[rustc_dump_program_clauses] //~ ERROR program clause dump
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: Implemented(Self: Foo<F>) :- FromEnv(Self: Foo<F>).
= note: FromEnv(<F as std::ops::FnOnce<(&'a (u8, u16),)>>::Output == &'a u8) :- FromEnv(Self: Foo<F>).
= note: FromEnv(F: std::marker::Sized) :- FromEnv(Self: Foo<F>).
= note: FromEnv(F: std::ops::Fn<(&'a (u8, u16),)>) :- FromEnv(Self: Foo<F>).
= note: FromEnv(<F as std::ops::FnOnce<(&'a (u8, u16),)>>::Output == &'a u8) :- FromEnv(Self: Foo<F>).
= note: Implemented(Self: Foo<F>) :- FromEnv(Self: Foo<F>).

error: aborting due to previous error

6 changes: 3 additions & 3 deletions src/test/ui/chalkify/lower_trait_where_clause.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ error: program clause dump
LL | #[rustc_dump_program_clauses] //~ ERROR program clause dump
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: Implemented(Self: Foo<'a, 'b, S, T, U>) :- FromEnv(Self: Foo<'a, 'b, S, T, U>).
= note: FromEnv(S: std::marker::Sized) :- FromEnv(Self: Foo<'a, 'b, S, T, U>).
= note: FromEnv(T: std::marker::Sized) :- FromEnv(Self: Foo<'a, 'b, S, T, U>).
= note: FromEnv(S: std::fmt::Debug) :- FromEnv(Self: Foo<'a, 'b, S, T, U>).
= note: FromEnv(S: std::marker::Sized) :- FromEnv(Self: Foo<'a, 'b, S, T, U>).
= note: FromEnv(T: std::borrow::Borrow<U>) :- FromEnv(Self: Foo<'a, 'b, S, T, U>).
= note: FromEnv(T: std::marker::Sized) :- FromEnv(Self: Foo<'a, 'b, S, T, U>).
= note: Implemented(Self: Foo<'a, 'b, S, T, U>) :- FromEnv(Self: Foo<'a, 'b, S, T, U>).
= note: RegionOutlives('a : 'b) :- FromEnv(Self: Foo<'a, 'b, S, T, U>).
= note: TypeOutlives(U : 'b) :- FromEnv(Self: Foo<'a, 'b, S, T, U>).

Expand Down

0 comments on commit 2c5fbe2

Please sign in to comment.