about summary refs log tree commit diff
diff options
context:
space:
mode:
authorHavvy <ryan.havvy@gmail.com>2018-06-06 22:11:37 -0700
committerHavvy <ryan.havvy@gmail.com>2018-06-06 22:11:37 -0700
commiteccd2ede3c1b11ddcdde7929e049c4773df690ae (patch)
tree5533e92562788b168c2c5ce24fe050caf4c5987f
parent86ff9fa9c95b618605fad27bd752486c6259187b (diff)
downloadrust-eccd2ede3c1b11ddcdde7929e049c4773df690ae.tar.gz
rust-eccd2ede3c1b11ddcdde7929e049c4773df690ae.zip
Use Ord::cmp for auto traits since stable sort not needed
-rw-r--r--src/librustc_typeck/astconv.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs
index 68553ece3a7..da98dc5d14b 100644
--- a/src/librustc_typeck/astconv.rs
+++ b/src/librustc_typeck/astconv.rs
@@ -30,7 +30,7 @@ use util::common::ErrorReported;
 use util::nodemap::{FxHashSet, FxHashMap};
 use errors::FatalError;
 
-use std::cmp::Ordering;
+// use std::cmp::Ordering;
 use std::iter;
 use syntax::ast;
 use syntax::feature_gate::{GateIssue, emit_feature_err};
@@ -646,7 +646,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
                                             &mut vec![]);
         }
 
-        let (auto_traits, trait_bounds) = split_auto_traits(tcx, &trait_bounds[1..]);
+        let (mut auto_traits, trait_bounds) = split_auto_traits(tcx, &trait_bounds[1..]);
 
         if !trait_bounds.is_empty() {
             let b = &trait_bounds[0];
@@ -708,15 +708,13 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
         }
 
         // Dedup auto traits so that `dyn Trait + Send + Send` is the same as `dyn Trait + Send`.
-        let mut auto_traits =
-            auto_traits.into_iter().map(ty::ExistentialPredicate::AutoTrait).collect::<Vec<_>>();
-        auto_traits.sort_by(|a, b| a.cmp(tcx, b));
-        auto_traits.dedup_by(|a, b| (&*a).cmp(tcx, b) == Ordering::Equal);
+        auto_traits.sort();
+        auto_traits.dedup();
 
         // skip_binder is okay, because the predicates are re-bound.
         let mut v =
             iter::once(ty::ExistentialPredicate::Trait(*existential_principal.skip_binder()))
-            .chain(auto_traits.into_iter())
+            .chain(auto_traits.into_iter().map(ty::ExistentialPredicate::AutoTrait))
             .chain(existential_projections
                    .map(|x| ty::ExistentialPredicate::Projection(*x.skip_binder())))
             .collect::<AccumulateVec<[_; 8]>>();