mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Auto merge of #90842 - pierwill:localdefid-indexmap, r=wesleywiser
Use `indexmap` to avoid sorting `LocalDefId`s See discussion in https://github.com/rust-lang/rust/pull/90408#discussion_r745935459. Related to work on https://github.com/rust-lang/rust/issues/90317.
This commit is contained in:
commit
e7825f2b69
@ -1739,12 +1739,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.7.0"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5"
|
||||
checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown 0.11.2",
|
||||
"rustc-rayon",
|
||||
"serde",
|
||||
]
|
||||
|
||||
|
@ -172,9 +172,9 @@ checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.7.0"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5"
|
||||
checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown",
|
||||
|
@ -19,7 +19,7 @@ gimli = { version = "0.25.0", default-features = false, features = ["write"]}
|
||||
object = { version = "0.27.0", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }
|
||||
|
||||
ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" }
|
||||
indexmap = "1.0.2"
|
||||
indexmap = "1.8.0"
|
||||
libloading = { version = "0.6.0", optional = true }
|
||||
smallvec = "1.6.1"
|
||||
|
||||
|
@ -9,7 +9,7 @@ doctest = false
|
||||
[dependencies]
|
||||
arrayvec = { version = "0.7", default-features = false }
|
||||
ena = "0.14"
|
||||
indexmap = "1.5.1"
|
||||
indexmap = { version = "1.8.0", features = ["rustc-rayon"] }
|
||||
tracing = "0.1"
|
||||
jobserver_crate = { version = "0.1.13", package = "jobserver" }
|
||||
rustc_serialize = { path = "../rustc_serialize" }
|
||||
|
@ -1314,7 +1314,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
return;
|
||||
}
|
||||
|
||||
let mut keys_and_jobs = self
|
||||
let keys_and_jobs = self
|
||||
.tcx
|
||||
.mir_keys(())
|
||||
.iter()
|
||||
@ -1327,8 +1327,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
// Sort everything to ensure a stable order for diagnotics.
|
||||
keys_and_jobs.sort_by_key(|&(def_id, _, _)| def_id.index());
|
||||
for (def_id, encode_const, encode_opt) in keys_and_jobs.into_iter() {
|
||||
debug_assert!(encode_const || encode_opt);
|
||||
|
||||
|
@ -252,7 +252,7 @@ rustc_queries! {
|
||||
/// Set of all the `DefId`s in this crate that have MIR associated with
|
||||
/// them. This includes all the body owners, but also things like struct
|
||||
/// constructors.
|
||||
query mir_keys(_: ()) -> FxHashSet<LocalDefId> {
|
||||
query mir_keys(_: ()) -> rustc_data_structures::fx::FxIndexSet<LocalDefId> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { "getting a list of all mir_keys" }
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ extern crate rustc_middle;
|
||||
|
||||
use required_consts::RequiredConstsVisitor;
|
||||
use rustc_const_eval::util;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_data_structures::fx::FxIndexSet;
|
||||
use rustc_data_structures::steal::Steal;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
@ -136,8 +136,8 @@ fn is_mir_available(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||
|
||||
/// Finds the full set of `DefId`s within the current crate that have
|
||||
/// MIR associated with them.
|
||||
fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxHashSet<LocalDefId> {
|
||||
let mut set = FxHashSet::default();
|
||||
fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LocalDefId> {
|
||||
let mut set = FxIndexSet::default();
|
||||
|
||||
// All body-owners have MIR associated with them.
|
||||
set.extend(tcx.hir().body_owners());
|
||||
@ -146,7 +146,7 @@ fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxHashSet<LocalDefId> {
|
||||
// they don't have a BodyId, so we need to build them separately.
|
||||
struct GatherCtors<'a, 'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
set: &'a mut FxHashSet<LocalDefId>,
|
||||
set: &'a mut FxIndexSet<LocalDefId>,
|
||||
}
|
||||
impl<'tcx> Visitor<'tcx> for GatherCtors<'_, 'tcx> {
|
||||
fn visit_variant_data(
|
||||
|
@ -4,7 +4,7 @@ version = "0.0.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
indexmap = "1"
|
||||
indexmap = "1.8.0"
|
||||
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
|
||||
|
||||
[dev-dependencies]
|
||||
|
@ -1,21 +1,5 @@
|
||||
// WARNING: This output format is intended for human consumers only
|
||||
// and is subject to change without notice. Knock yourself out.
|
||||
fn main() -> () {
|
||||
let mut _0: (); // return place in scope 0 at main.rs:8:11: 8:11
|
||||
let _1: i32; // in scope 0 at main.rs:9:5: 9:10
|
||||
|
||||
bb0: {
|
||||
_1 = foo() -> bb1; // scope 0 at main.rs:9:5: 9:10
|
||||
// mir::Constant
|
||||
// + span: main.rs:9:5: 9:8
|
||||
// + literal: Const { ty: fn() -> i32 {foo}, val: Value(Scalar(<ZST>)) }
|
||||
}
|
||||
|
||||
bb1: {
|
||||
return; // scope 0 at main.rs:10:2: 10:2
|
||||
}
|
||||
}
|
||||
|
||||
fn foo() -> i32 {
|
||||
let mut _0: i32; // return place in scope 0 at main.rs:4:19: 4:22
|
||||
|
||||
@ -40,3 +24,19 @@ fn foo() -> i32 {
|
||||
return; // scope 0 at main.rs:6:2: 6:2
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> () {
|
||||
let mut _0: (); // return place in scope 0 at main.rs:8:11: 8:11
|
||||
let _1: i32; // in scope 0 at main.rs:9:5: 9:10
|
||||
|
||||
bb0: {
|
||||
_1 = foo() -> bb1; // scope 0 at main.rs:9:5: 9:10
|
||||
// mir::Constant
|
||||
// + span: main.rs:9:5: 9:8
|
||||
// + literal: Const { ty: fn() -> i32 {foo}, val: Value(Scalar(<ZST>)) }
|
||||
}
|
||||
|
||||
bb1: {
|
||||
return; // scope 0 at main.rs:10:2: 10:2
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user