about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits/auto_trait.rs
diff options
context:
space:
mode:
authorCastilloDel <delcastillodelarosadaniel@gmail.com>2022-10-28 23:32:41 +0200
committerCastilloDel <delcastillodelarosadaniel@gmail.com>2022-11-08 19:41:48 +0100
commit755ca4b9aa064b77fa8a0f6cdaf050b768d844bc (patch)
treecb2ba809ef662ec220857fa38c98c03db3b3dc3e /compiler/rustc_trait_selection/src/traits/auto_trait.rs
parentddfe1e87f7c85c03773c29180a931447fcd03b65 (diff)
downloadrust-755ca4b9aa064b77fa8a0f6cdaf050b768d844bc.tar.gz
rust-755ca4b9aa064b77fa8a0f6cdaf050b768d844bc.zip
Reduce the scope of allow(rustc::potential_query_instability) in rustc_trait_selection
Make InferCtxtExt use a FxIndexMap

This should be faster, because the map is only being used to iterate,
which is supposed to be faster with the IndexMap

Make the user_computed_preds use an IndexMap

It is being used mostly for iteration, so the change shouldn't result in
a perf hit

Make the RegionDeps fields use an IndexMap

This change could be a perf hit. Both `larger` and `smaller` are used
for iteration, but they are also used for insertions.

Make types_without_default_bounds use an IndexMap

It uses extend, but it also iterates and removes items. Not sure if
this will be a perf hit.

Make InferTtxt.reported_trait_errors use an IndexMap

This change brought a lot of other changes. The map seems to have been
mostly used for iteration, so the performance shouldn't suffer.

Add FIXME to change ProvisionalEvaluationCache.map to use an IndexMap

Right now this results in a perf hit. IndexMap doesn't have
the `drain_filter` API, so in `on_completion` we now need to iterate two
times over the map.
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits/auto_trait.rs')
-rw-r--r--compiler/rustc_trait_selection/src/traits/auto_trait.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs
index ed34ab95ad6..188f8bb7e2a 100644
--- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs
+++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs
@@ -12,7 +12,7 @@ use rustc_middle::ty::fold::{TypeFolder, TypeSuperFoldable};
 use rustc_middle::ty::visit::TypeVisitable;
 use rustc_middle::ty::{PolyTraitRef, Region, RegionVid};
 
-use rustc_data_structures::fx::{FxHashMap, FxHashSet};
+use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
 
 use std::collections::hash_map::Entry;
 use std::collections::VecDeque;
@@ -27,8 +27,8 @@ pub enum RegionTarget<'tcx> {
 
 #[derive(Default, Debug, Clone)]
 pub struct RegionDeps<'tcx> {
-    larger: FxHashSet<RegionTarget<'tcx>>,
-    smaller: FxHashSet<RegionTarget<'tcx>>,
+    larger: FxIndexSet<RegionTarget<'tcx>>,
+    smaller: FxIndexSet<RegionTarget<'tcx>>,
 }
 
 pub enum AutoTraitResult<A> {
@@ -266,7 +266,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
         }));
 
         let computed_preds = param_env.caller_bounds().iter();
-        let mut user_computed_preds: FxHashSet<_> = user_env.caller_bounds().iter().collect();
+        let mut user_computed_preds: FxIndexSet<_> = user_env.caller_bounds().iter().collect();
 
         let mut new_env = param_env;
         let dummy_cause = ObligationCause::dummy();
@@ -389,7 +389,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
     /// not just one specific lifetime (e.g., `'static`).
     fn add_user_pred(
         &self,
-        user_computed_preds: &mut FxHashSet<ty::Predicate<'tcx>>,
+        user_computed_preds: &mut FxIndexSet<ty::Predicate<'tcx>>,
         new_pred: ty::Predicate<'tcx>,
     ) {
         let mut should_add_new = true;
@@ -585,7 +585,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
         &self,
         ty: Ty<'_>,
         nested: impl Iterator<Item = Obligation<'tcx, ty::Predicate<'tcx>>>,
-        computed_preds: &mut FxHashSet<ty::Predicate<'tcx>>,
+        computed_preds: &mut FxIndexSet<ty::Predicate<'tcx>>,
         fresh_preds: &mut FxHashSet<ty::Predicate<'tcx>>,
         predicates: &mut VecDeque<ty::PolyTraitPredicate<'tcx>>,
         select: &mut SelectionContext<'_, 'tcx>,