diff --git a/compiler/rustc_borrowck/src/borrow_set.rs b/compiler/rustc_borrowck/src/borrow_set.rs index 5bb92a35826..fa0552e012d 100644 --- a/compiler/rustc_borrowck/src/borrow_set.rs +++ b/compiler/rustc_borrowck/src/borrow_set.rs @@ -4,7 +4,7 @@ use crate::nll::ToRegionVid; use crate::path_utils::allow_two_phase_borrow; use crate::place_ext::PlaceExt; use crate::BorrowIndex; -use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; +use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; use rustc_index::bit_set::BitSet; use rustc_middle::mir::traversal; use rustc_middle::mir::visit::{MutatingUseContext, NonUseContext, PlaceContext, Visitor}; @@ -26,10 +26,10 @@ pub struct BorrowSet<'tcx> { /// NOTE: a given location may activate more than one borrow in the future /// when more general two-phase borrow support is introduced, but for now we /// only need to store one borrow index. - pub activation_map: FxHashMap>, + pub activation_map: FxIndexMap>, /// Map from local to all the borrows on that local. - pub local_map: FxHashMap>, + pub local_map: FxIndexMap>, pub(crate) locals_state_at_exit: LocalsStateAtExit, } @@ -175,8 +175,8 @@ struct GatherBorrows<'a, 'tcx> { tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, location_map: FxIndexMap>, - activation_map: FxHashMap>, - local_map: FxHashMap>, + activation_map: FxIndexMap>, + local_map: FxIndexMap>, /// When we encounter a 2-phase borrow statement, it will always /// be assigning into a temporary TEMP: @@ -186,7 +186,7 @@ struct GatherBorrows<'a, 'tcx> { /// We add TEMP into this map with `b`, where `b` is the index of /// the borrow. When we find a later use of this activation, we /// remove from the map (and add to the "tombstone" set below). - pending_activations: FxHashMap, + pending_activations: FxIndexMap, locals_state_at_exit: LocalsStateAtExit, } diff --git a/compiler/rustc_borrowck/src/dataflow.rs b/compiler/rustc_borrowck/src/dataflow.rs index 2821677c537..d2574aa58c2 100644 --- a/compiler/rustc_borrowck/src/dataflow.rs +++ b/compiler/rustc_borrowck/src/dataflow.rs @@ -1,6 +1,6 @@ #![deny(rustc::untranslatable_diagnostic)] #![deny(rustc::diagnostic_outside_of_impl)] -use rustc_data_structures::fx::FxHashMap; +use rustc_data_structures::fx::FxIndexMap; use rustc_index::bit_set::BitSet; use rustc_middle::mir::{self, BasicBlock, Body, Location, Place}; use rustc_middle::ty::RegionVid; @@ -124,7 +124,7 @@ pub struct Borrows<'a, 'tcx> { body: &'a Body<'tcx>, borrow_set: &'a BorrowSet<'tcx>, - borrows_out_of_scope_at_location: FxHashMap>, + borrows_out_of_scope_at_location: FxIndexMap>, } struct StackEntry { @@ -138,7 +138,7 @@ struct OutOfScopePrecomputer<'a, 'tcx> { visit_stack: Vec, body: &'a Body<'tcx>, regioncx: &'a RegionInferenceContext<'tcx>, - borrows_out_of_scope_at_location: FxHashMap>, + borrows_out_of_scope_at_location: FxIndexMap>, } impl<'a, 'tcx> OutOfScopePrecomputer<'a, 'tcx> { @@ -148,7 +148,7 @@ impl<'a, 'tcx> OutOfScopePrecomputer<'a, 'tcx> { visit_stack: vec![], body, regioncx, - borrows_out_of_scope_at_location: FxHashMap::default(), + borrows_out_of_scope_at_location: FxIndexMap::default(), } } } diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index a622a215a2e..f43b611f54e 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -1,7 +1,7 @@ use either::Either; use rustc_const_eval::util::CallKind; use rustc_data_structures::captures::Captures; -use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::fx::FxIndexSet; use rustc_errors::{ struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, MultiSpan, }; @@ -173,7 +173,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let mut is_loop_move = false; let mut in_pattern = false; - let mut seen_spans = FxHashSet::default(); + let mut seen_spans = FxIndexSet::default(); for move_site in &move_site_vec { let move_out = self.move_data.moves[(*move_site).moi]; @@ -2223,8 +2223,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } } - let mut visited = FxHashSet::default(); - let mut move_locations = FxHashSet::default(); + let mut visited = FxIndexSet::default(); + let mut move_locations = FxIndexSet::default(); let mut reinits = vec![]; let mut result = vec![]; @@ -2351,7 +2351,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let reinits_reachable = reinits .into_iter() .filter(|reinit| { - let mut visited = FxHashSet::default(); + let mut visited = FxIndexSet::default(); let mut stack = vec![*reinit]; while let Some(location) = stack.pop() { if !visited.insert(location) { diff --git a/compiler/rustc_borrowck/src/diagnostics/find_use.rs b/compiler/rustc_borrowck/src/diagnostics/find_use.rs index 15f42e26cbf..fd1fda2ee4b 100644 --- a/compiler/rustc_borrowck/src/diagnostics/find_use.rs +++ b/compiler/rustc_borrowck/src/diagnostics/find_use.rs @@ -9,7 +9,7 @@ use crate::{ nll::ToRegionVid, region_infer::{Cause, RegionInferenceContext}, }; -use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::fx::FxIndexSet; use rustc_middle::mir::visit::{MirVisitable, PlaceContext, Visitor}; use rustc_middle::mir::{Body, Local, Location}; use rustc_middle::ty::{RegionVid, TyCtxt}; @@ -37,7 +37,7 @@ struct UseFinder<'cx, 'tcx> { impl<'cx, 'tcx> UseFinder<'cx, 'tcx> { fn find(&mut self) -> Option { let mut queue = VecDeque::new(); - let mut visited = FxHashSet::default(); + let mut visited = FxIndexSet::default(); queue.push_back(self.start_point); while let Some(p) = queue.pop_front() { diff --git a/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs b/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs index 1eaf0a2f15c..d5ece57437e 100644 --- a/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs +++ b/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs @@ -1,7 +1,7 @@ //! Contains utilities for generating suggestions for borrowck errors related to unsatisfied //! outlives constraints. -use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::fx::FxIndexSet; use rustc_errors::Diagnostic; use rustc_middle::ty::RegionVid; use smallvec::SmallVec; @@ -87,7 +87,7 @@ impl OutlivesSuggestionBuilder { // Keep track of variables that we have already suggested unifying so that we don't print // out silly duplicate messages. - let mut unified_already = FxHashSet::default(); + let mut unified_already = FxIndexSet::default(); for (fr, outlived) in &self.constraints_to_add { let Some(fr_name) = self.region_vid_to_name(mbcx, *fr) else { diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index 115e512a974..0fc3240c560 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -1,6 +1,5 @@ //! This query borrow-checks the MIR to (further) ensure it is not broken. -#![allow(rustc::potential_query_instability)] #![feature(associated_type_bounds)] #![feature(box_patterns)] #![feature(let_chains)] @@ -18,7 +17,7 @@ extern crate rustc_middle; #[macro_use] extern crate tracing; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; use rustc_data_structures::graph::dominators::Dominators; use rustc_data_structures::vec_map::VecMap; use rustc_errors::{Diagnostic, DiagnosticBuilder, DiagnosticMessage, SubdiagnosticMessage}; @@ -404,7 +403,7 @@ fn do_mir_borrowck<'tcx>( // Note that this set is expected to be small - only upvars from closures // would have a chance of erroneously adding non-user-defined mutable vars // to the set. - let temporary_used_locals: FxHashSet = mbcx + let temporary_used_locals: FxIndexSet = mbcx .used_mut .iter() .filter(|&local| !mbcx.body.local_decls[*local].is_user_variable()) @@ -491,7 +490,7 @@ pub struct BodyWithBorrowckFacts<'tcx> { pub struct BorrowckInferCtxt<'cx, 'tcx> { pub(crate) infcx: &'cx InferCtxt<'tcx>, - pub(crate) reg_var_to_origin: RefCell>, + pub(crate) reg_var_to_origin: RefCell>, } impl<'cx, 'tcx> BorrowckInferCtxt<'cx, 'tcx> { @@ -588,7 +587,7 @@ struct MirBorrowckCtxt<'cx, 'tcx> { /// borrow errors that is handled by the `reservation_error_reported` field as the inclusion /// of the `Span` type (while required to mute some errors) stops the muting of the reservation /// errors. - access_place_error_reported: FxHashSet<(Place<'tcx>, Span)>, + access_place_error_reported: FxIndexSet<(Place<'tcx>, Span)>, /// This field keeps track of when borrow conflict errors are reported /// for reservations, so that we don't report seemingly duplicate /// errors for corresponding activations. @@ -596,17 +595,17 @@ struct MirBorrowckCtxt<'cx, 'tcx> { // FIXME: ideally this would be a set of `BorrowIndex`, not `Place`s, // but it is currently inconvenient to track down the `BorrowIndex` // at the time we detect and report a reservation error. - reservation_error_reported: FxHashSet>, + reservation_error_reported: FxIndexSet>, /// This fields keeps track of the `Span`s that we have /// used to report extra information for `FnSelfUse`, to avoid /// unnecessarily verbose errors. - fn_self_span_reported: FxHashSet, + fn_self_span_reported: FxIndexSet, /// This field keeps track of errors reported in the checking of uninitialized variables, /// so that we don't report seemingly duplicate errors. - uninitialized_error_reported: FxHashSet>, + uninitialized_error_reported: FxIndexSet>, /// This field keeps track of all the local variables that are declared mut and are mutated. /// Used for the warning issued by an unused mutable local variable. - used_mut: FxHashSet, + used_mut: FxIndexSet, /// If the function we're checking is a closure, then we'll need to report back the list of /// mutable upvars that have been used. This field keeps track of them. used_mut_upvars: SmallVec<[Field; 8]>, @@ -628,7 +627,7 @@ struct MirBorrowckCtxt<'cx, 'tcx> { /// Record the region names generated for each region in the given /// MIR def so that we can reuse them later in help/error messages. - region_names: RefCell>, + region_names: RefCell>, /// The counter for generating new region names. next_region_name: RefCell, @@ -2329,7 +2328,7 @@ mod error { /// same primary span come out in a consistent order. buffered_move_errors: BTreeMap, (PlaceRef<'tcx>, DiagnosticBuilder<'tcx, ErrorGuaranteed>)>, - buffered_mut_errors: FxHashMap, usize)>, + buffered_mut_errors: FxIndexMap, usize)>, /// Diagnostics to be reported buffer. buffered: Vec, /// Set to Some if we emit an error during borrowck diff --git a/compiler/rustc_borrowck/src/member_constraints.rs b/compiler/rustc_borrowck/src/member_constraints.rs index 4af324f740a..b6c5d4245d7 100644 --- a/compiler/rustc_borrowck/src/member_constraints.rs +++ b/compiler/rustc_borrowck/src/member_constraints.rs @@ -1,7 +1,7 @@ #![deny(rustc::untranslatable_diagnostic)] #![deny(rustc::diagnostic_outside_of_impl)] use rustc_data_structures::captures::Captures; -use rustc_data_structures::fx::FxHashMap; +use rustc_data_structures::fx::FxIndexMap; use rustc_index::vec::IndexVec; use rustc_middle::infer::MemberConstraint; use rustc_middle::ty::{self, Ty}; @@ -18,7 +18,7 @@ where { /// Stores the first "member" constraint for a given `R0`. This is an /// index into the `constraints` vector below. - first_constraints: FxHashMap, + first_constraints: FxIndexMap, /// Stores the data about each `R0 member of [R1..Rn]` constraint. /// These are organized into a linked list, so each constraint @@ -132,7 +132,7 @@ where let MemberConstraintSet { first_constraints, mut constraints, choice_regions } = self; - let mut first_constraints2 = FxHashMap::default(); + let mut first_constraints2 = FxIndexMap::default(); first_constraints2.reserve(first_constraints.len()); for (r1, start1) in first_constraints { diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index e6195de404c..905d8c42b28 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -3,7 +3,7 @@ use std::rc::Rc; use rustc_data_structures::binary_search_util; use rustc_data_structures::frozen::Frozen; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; use rustc_data_structures::graph::scc::Sccs; use rustc_errors::Diagnostic; use rustc_hir::def_id::CRATE_DEF_ID; @@ -88,7 +88,7 @@ pub struct RegionInferenceContext<'tcx> { member_constraints_applied: Vec, /// Map universe indexes to information on why we created it. - universe_causes: FxHashMap>, + universe_causes: FxIndexMap>, /// Contains the minimum universe of any variable within the same /// SCC. We will ensure that no SCC contains values that are not @@ -263,7 +263,7 @@ fn sccs_info<'cx, 'tcx>( debug!(debug_str); let num_components = sccs.scc_data().ranges().len(); - let mut components = vec![FxHashSet::default(); num_components]; + let mut components = vec![FxIndexSet::default(); num_components]; for (reg_var_idx, scc_idx) in sccs.scc_indices().iter().enumerate() { let reg_var = ty::RegionVid::from_usize(reg_var_idx); @@ -295,9 +295,9 @@ fn sccs_info<'cx, 'tcx>( (ConstraintSccIndex::from_usize(scc_idx), repr) }) - .collect::>(); + .collect::>(); - let mut scc_node_to_edges = FxHashMap::default(); + let mut scc_node_to_edges = FxIndexMap::default(); for (scc_idx, repr) in components_representatives.iter() { let edges_range = sccs.scc_data().ranges()[*scc_idx].clone(); let edges = &sccs.scc_data().all_successors()[edges_range]; @@ -325,7 +325,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { universal_region_relations: Frozen>, outlives_constraints: OutlivesConstraintSet<'tcx>, member_constraints_in: MemberConstraintSet<'tcx, RegionVid>, - universe_causes: FxHashMap>, + universe_causes: FxIndexMap>, type_tests: Vec>, liveness_constraints: LivenessValues, elements: &Rc, @@ -522,6 +522,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// outlives `'a` and hence contains R0 and R1. fn init_free_and_bound_regions(&mut self) { // Update the names (if any) + // This iterator has unstable order but we collect it all into an IndexVec for (external_name, variable) in self.universal_regions.named_universal_regions() { debug!( "init_universal_regions: region {:?} has external name {:?}", @@ -918,7 +919,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { // Sometimes we register equivalent type-tests that would // result in basically the exact same error being reported to // the user. Avoid that. - let mut deduplicate_errors = FxHashSet::default(); + let mut deduplicate_errors = FxIndexSet::default(); for type_test in &self.type_tests { debug!("check_type_test: {:?}", type_test); @@ -1504,6 +1505,8 @@ impl<'tcx> RegionInferenceContext<'tcx> { // the outlives suggestions or the debug output from `#[rustc_regions]` would be // duplicated. The polonius subset errors are deduplicated here, while keeping the // CFG-location ordering. + // We can iterate the HashMap here because the result is sorted afterwards. + #[allow(rustc::potential_query_instability)] let mut subset_errors: Vec<_> = polonius_output .subset_errors .iter() diff --git a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs index c550e37c63e..ec4b2e9d3e4 100644 --- a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs +++ b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs @@ -1,4 +1,4 @@ -use rustc_data_structures::fx::{FxHashMap, FxIndexSet}; +use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; use rustc_data_structures::vec_map::VecMap; use rustc_errors::ErrorGuaranteed; use rustc_hir::def_id::LocalDefId; @@ -65,7 +65,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { ) -> VecMap> { let mut result: VecMap> = VecMap::new(); - let member_constraints: FxHashMap<_, _> = self + let member_constraints: FxIndexMap<_, _> = self .member_constraints .all_indices() .map(|ci| (self.member_constraints[ci].key, ci)) @@ -364,7 +364,7 @@ fn check_opaque_type_parameter_valid( OpaqueTyOrigin::TyAlias => {} } let opaque_generics = tcx.generics_of(opaque_type_key.def_id); - let mut seen_params: FxHashMap<_, Vec<_>> = FxHashMap::default(); + let mut seen_params: FxIndexMap<_, Vec<_>> = FxIndexMap::default(); for (i, arg) in opaque_type_key.substs.iter().enumerate() { let arg_is_param = match arg.unpack() { GenericArgKind::Type(ty) => matches!(ty.kind(), ty::Param(_)), diff --git a/compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs b/compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs index 167f6646096..23a59c12865 100644 --- a/compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs +++ b/compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs @@ -3,7 +3,7 @@ use crate::constraints::ConstraintSccIndex; use crate::RegionInferenceContext; use itertools::Itertools; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; use rustc_data_structures::graph::vec_graph::VecGraph; use rustc_data_structures::graph::WithSuccessors; use rustc_middle::ty::RegionVid; @@ -14,7 +14,7 @@ pub(crate) struct ReverseSccGraph { graph: VecGraph, /// For each SCC, the range of `universal_regions` that use that SCC as /// their value. - scc_regions: FxHashMap>, + scc_regions: FxIndexMap>, /// All of the universal regions, in grouped so that `scc_regions` can /// index into here. universal_regions: Vec, @@ -26,7 +26,7 @@ impl ReverseSccGraph { &'a self, scc0: ConstraintSccIndex, ) -> impl Iterator + 'a { - let mut duplicates = FxHashSet::default(); + let mut duplicates = FxIndexSet::default(); self.graph .depth_first_search(scc0) .flat_map(move |scc1| { @@ -55,7 +55,7 @@ impl RegionInferenceContext<'_> { paired_scc_regions.sort(); let universal_regions = paired_scc_regions.iter().map(|&(_, region)| region).collect(); - let mut scc_regions = FxHashMap::default(); + let mut scc_regions = FxIndexMap::default(); let mut start = 0; for (scc, group) in &paired_scc_regions.into_iter().group_by(|(scc, _)| *scc) { let group_size = group.count(); diff --git a/compiler/rustc_borrowck/src/type_check/input_output.rs b/compiler/rustc_borrowck/src/type_check/input_output.rs index 717020ea5b8..17e702eb8c5 100644 --- a/compiler/rustc_borrowck/src/type_check/input_output.rs +++ b/compiler/rustc_borrowck/src/type_check/input_output.rs @@ -19,7 +19,7 @@ use super::{Locations, TypeChecker}; impl<'a, 'tcx> TypeChecker<'a, 'tcx> { /// Check explicit closure signature annotation, - /// e.g., `|x: FxHashMap<_, &'static u32>| ...`. + /// e.g., `|x: FxIndexMap<_, &'static u32>| ...`. #[instrument(skip(self, body), level = "debug")] pub(super) fn check_signature_annotation(&mut self, body: &Body<'tcx>) { let mir_def_id = body.source.def_id().expect_local(); diff --git a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs index 473c0596300..a687d3f5352 100644 --- a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs +++ b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs @@ -1,4 +1,4 @@ -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; use rustc_index::bit_set::HybridBitSet; use rustc_index::interval::IntervalSet; use rustc_infer::infer::canonical::QueryRegionConstraints; @@ -56,7 +56,7 @@ pub(super) fn trace<'mir, 'tcx>( elements, local_use_map, move_data, - drop_data: FxHashMap::default(), + drop_data: FxIndexMap::default(), }; let mut results = LivenessResults::new(cx); @@ -85,7 +85,7 @@ struct LivenessContext<'me, 'typeck, 'flow, 'tcx> { move_data: &'me MoveData<'tcx>, /// Cache for the results of `dropck_outlives` query. - drop_data: FxHashMap, DropData<'tcx>>, + drop_data: FxIndexMap, DropData<'tcx>>, /// Results of dataflow tracking which variables (and paths) have been /// initialized. @@ -185,7 +185,7 @@ impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> { fn add_extra_drop_facts( &mut self, drop_used: Vec<(Local, Location)>, - relevant_live_locals: FxHashSet, + relevant_live_locals: FxIndexSet, ) { let locations = IntervalSet::new(self.cx.elements.num_points()); diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index a49da3da6c0..06c7b8b8f87 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -9,7 +9,7 @@ use either::Either; use hir::OpaqueTyOrigin; use rustc_data_structures::frozen::Frozen; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; use rustc_data_structures::vec_map::VecMap; use rustc_hir as hir; use rustc_hir::def::DefKind; @@ -145,7 +145,7 @@ pub(crate) fn type_check<'mir, 'tcx>( outlives_constraints: OutlivesConstraintSet::default(), member_constraints: MemberConstraintSet::default(), type_tests: Vec::default(), - universe_causes: FxHashMap::default(), + universe_causes: FxIndexMap::default(), }; let CreateResult { @@ -875,7 +875,7 @@ struct TypeChecker<'a, 'tcx> { user_type_annotations: &'a CanonicalUserTypeAnnotations<'tcx>, region_bound_pairs: &'a RegionBoundPairs<'tcx>, implicit_region_bound: ty::Region<'tcx>, - reported_errors: FxHashSet<(Ty<'tcx>, Span)>, + reported_errors: FxIndexSet<(Ty<'tcx>, Span)>, borrowck_context: &'a mut BorrowCheckContext<'a, 'tcx>, } @@ -925,7 +925,7 @@ pub(crate) struct MirTypeckRegionConstraints<'tcx> { pub(crate) member_constraints: MemberConstraintSet<'tcx, RegionVid>, - pub(crate) universe_causes: FxHashMap>, + pub(crate) universe_causes: FxIndexMap>, pub(crate) type_tests: Vec>, } diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index 76d0b875424..68c86051364 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -312,6 +312,9 @@ impl<'tcx> UniversalRegions<'tcx> { } /// Gets an iterator over all the early-bound regions that have names. + /// Iteration order may be unstable, so this should only be used when + /// iteration order doesn't affect anything + #[allow(rustc::potential_query_instability)] pub fn named_universal_regions<'s>( &'s self, ) -> impl Iterator, ty::RegionVid)> + 's { diff --git a/compiler/rustc_borrowck/src/used_muts.rs b/compiler/rustc_borrowck/src/used_muts.rs index e297b1230ea..18dbe24d3b8 100644 --- a/compiler/rustc_borrowck/src/used_muts.rs +++ b/compiler/rustc_borrowck/src/used_muts.rs @@ -1,6 +1,6 @@ #![deny(rustc::untranslatable_diagnostic)] #![deny(rustc::diagnostic_outside_of_impl)] -use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::fx::FxIndexSet; use rustc_middle::mir::visit::{PlaceContext, Visitor}; use rustc_middle::mir::{ Local, Location, Place, Statement, StatementKind, Terminator, TerminatorKind, @@ -26,8 +26,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// See #55344 for context. pub(crate) fn gather_used_muts( &mut self, - temporary_used_locals: FxHashSet, - mut never_initialized_mut_locals: FxHashSet, + temporary_used_locals: FxIndexSet, + mut never_initialized_mut_locals: FxIndexSet, ) { { let mut visitor = GatherUsedMutsVisitor { @@ -48,8 +48,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// MIR visitor for collecting used mutable variables. /// The 'visit lifetime represents the duration of the MIR walk. struct GatherUsedMutsVisitor<'visit, 'cx, 'tcx> { - temporary_used_locals: FxHashSet, - never_initialized_mut_locals: &'visit mut FxHashSet, + temporary_used_locals: FxIndexSet, + never_initialized_mut_locals: &'visit mut FxIndexSet, mbcx: &'visit mut MirBorrowckCtxt<'cx, 'tcx>, }