From f5fe6cd27748d519f8c0751b62bc008595736733 Mon Sep 17 00:00:00 2001 From: pierwill Date: Tue, 25 Jan 2022 17:40:10 -0600 Subject: [PATCH] Return an indexmap in `all_local_trait_impls` query The data structure previously used here required Ord. As part of #90317, we do not want DefId to implement Ord. --- compiler/rustc_middle/src/query/mod.rs | 2 +- compiler/rustc_middle/src/ty/mod.rs | 5 ++--- compiler/rustc_middle/src/ty/query.rs | 1 - compiler/rustc_resolve/src/lib.rs | 4 ++-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 715a1fa25a1c6..131a459146d1f 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -1089,7 +1089,7 @@ rustc_queries! { } /// Return all `impl` blocks in the current crate. - query all_local_trait_impls(_: ()) -> &'tcx BTreeMap> { + query all_local_trait_impls(_: ()) -> &'tcx rustc_data_structures::fx::FxIndexMap> { desc { "local trait impls" } } diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 64c00c353ca1b..a497b46d92c54 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -28,7 +28,7 @@ use crate::ty::subst::{GenericArg, InternalSubsts, Subst, SubstsRef}; use crate::ty::util::Discr; use rustc_ast as ast; use rustc_attr as attr; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::tagged_ptr::CopyTaggedPtr; use rustc_hir as hir; @@ -43,7 +43,6 @@ use rustc_span::{sym, Span}; use rustc_target::abi::Align; use std::cmp::Ordering; -use std::collections::BTreeMap; use std::hash::{Hash, Hasher}; use std::ops::ControlFlow; use std::{fmt, ptr, str}; @@ -136,7 +135,7 @@ pub struct ResolverOutputs { /// via `extern crate` item and not `--extern` option or compiler built-in. pub extern_prelude: FxHashMap, pub main_def: Option, - pub trait_impls: BTreeMap>, + pub trait_impls: FxIndexMap>, /// A list of proc macro LocalDefIds, written out in the order in which /// they are declared in the static array generated by proc_macro_harness. pub proc_macros: Vec, diff --git a/compiler/rustc_middle/src/ty/query.rs b/compiler/rustc_middle/src/ty/query.rs index 4a38d1c422f92..040e642b7b6d6 100644 --- a/compiler/rustc_middle/src/ty/query.rs +++ b/compiler/rustc_middle/src/ty/query.rs @@ -56,7 +56,6 @@ use rustc_ast as ast; use rustc_attr as attr; use rustc_span::symbol::Symbol; use rustc_span::{Span, DUMMY_SP}; -use std::collections::BTreeMap; use std::ops::Deref; use std::path::PathBuf; use std::sync::Arc; diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index f6625ac021b30..d06fc159285e6 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -67,7 +67,7 @@ use rustc_span::{Span, DUMMY_SP}; use smallvec::{smallvec, SmallVec}; use std::cell::{Cell, RefCell}; -use std::collections::{BTreeMap, BTreeSet}; +use std::collections::BTreeSet; use std::ops::ControlFlow; use std::{cmp, fmt, iter, mem, ptr}; use tracing::debug; @@ -1059,7 +1059,7 @@ pub struct Resolver<'a> { item_generics_num_lifetimes: FxHashMap, main_def: Option, - trait_impls: BTreeMap>, + trait_impls: FxIndexMap>, /// A list of proc macro LocalDefIds, written out in the order in which /// they are declared in the static array generated by proc_macro_harness. proc_macros: Vec,