Skip to content

Commit eccd2ed

Browse files
committed
Use Ord::cmp for auto traits since stable sort not needed
1 parent 86ff9fa commit eccd2ed

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/librustc_typeck/astconv.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use util::common::ErrorReported;
3030
use util::nodemap::{FxHashSet, FxHashMap};
3131
use errors::FatalError;
3232

33-
use std::cmp::Ordering;
33+
// use std::cmp::Ordering;
3434
use std::iter;
3535
use syntax::ast;
3636
use syntax::feature_gate::{GateIssue, emit_feature_err};
@@ -646,7 +646,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
646646
&mut vec![]);
647647
}
648648

649-
let (auto_traits, trait_bounds) = split_auto_traits(tcx, &trait_bounds[1..]);
649+
let (mut auto_traits, trait_bounds) = split_auto_traits(tcx, &trait_bounds[1..]);
650650

651651
if !trait_bounds.is_empty() {
652652
let b = &trait_bounds[0];
@@ -708,15 +708,13 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
708708
}
709709

710710
// Dedup auto traits so that `dyn Trait + Send + Send` is the same as `dyn Trait + Send`.
711-
let mut auto_traits =
712-
auto_traits.into_iter().map(ty::ExistentialPredicate::AutoTrait).collect::<Vec<_>>();
713-
auto_traits.sort_by(|a, b| a.cmp(tcx, b));
714-
auto_traits.dedup_by(|a, b| (&*a).cmp(tcx, b) == Ordering::Equal);
711+
auto_traits.sort();
712+
auto_traits.dedup();
715713

716714
// skip_binder is okay, because the predicates are re-bound.
717715
let mut v =
718716
iter::once(ty::ExistentialPredicate::Trait(*existential_principal.skip_binder()))
719-
.chain(auto_traits.into_iter())
717+
.chain(auto_traits.into_iter().map(ty::ExistentialPredicate::AutoTrait))
720718
.chain(existential_projections
721719
.map(|x| ty::ExistentialPredicate::Projection(*x.skip_binder())))
722720
.collect::<AccumulateVec<[_; 8]>>();

0 commit comments

Comments
 (0)