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
9 changed files with 30 additions and 31 deletions
|
@ -1739,12 +1739,13 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "1.7.0"
|
version = "1.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5"
|
checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"hashbrown 0.11.2",
|
"hashbrown 0.11.2",
|
||||||
|
"rustc-rayon",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -172,9 +172,9 @@ checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "1.7.0"
|
version = "1.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5"
|
checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"hashbrown",
|
"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"] }
|
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" }
|
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 }
|
libloading = { version = "0.6.0", optional = true }
|
||||||
smallvec = "1.6.1"
|
smallvec = "1.6.1"
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ doctest = false
|
||||||
[dependencies]
|
[dependencies]
|
||||||
arrayvec = { version = "0.7", default-features = false }
|
arrayvec = { version = "0.7", default-features = false }
|
||||||
ena = "0.14"
|
ena = "0.14"
|
||||||
indexmap = "1.5.1"
|
indexmap = { version = "1.8.0", features = ["rustc-rayon"] }
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
jobserver_crate = { version = "0.1.13", package = "jobserver" }
|
jobserver_crate = { version = "0.1.13", package = "jobserver" }
|
||||||
rustc_serialize = { path = "../rustc_serialize" }
|
rustc_serialize = { path = "../rustc_serialize" }
|
||||||
|
|
|
@ -1314,7 +1314,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut keys_and_jobs = self
|
let keys_and_jobs = self
|
||||||
.tcx
|
.tcx
|
||||||
.mir_keys(())
|
.mir_keys(())
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -1327,8 +1327,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.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() {
|
for (def_id, encode_const, encode_opt) in keys_and_jobs.into_iter() {
|
||||||
debug_assert!(encode_const || encode_opt);
|
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
|
/// 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
|
/// them. This includes all the body owners, but also things like struct
|
||||||
/// constructors.
|
/// constructors.
|
||||||
query mir_keys(_: ()) -> FxHashSet<LocalDefId> {
|
query mir_keys(_: ()) -> rustc_data_structures::fx::FxIndexSet<LocalDefId> {
|
||||||
storage(ArenaCacheSelector<'tcx>)
|
storage(ArenaCacheSelector<'tcx>)
|
||||||
desc { "getting a list of all mir_keys" }
|
desc { "getting a list of all mir_keys" }
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ extern crate rustc_middle;
|
||||||
|
|
||||||
use required_consts::RequiredConstsVisitor;
|
use required_consts::RequiredConstsVisitor;
|
||||||
use rustc_const_eval::util;
|
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_data_structures::steal::Steal;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
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
|
/// Finds the full set of `DefId`s within the current crate that have
|
||||||
/// MIR associated with them.
|
/// MIR associated with them.
|
||||||
fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxHashSet<LocalDefId> {
|
fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LocalDefId> {
|
||||||
let mut set = FxHashSet::default();
|
let mut set = FxIndexSet::default();
|
||||||
|
|
||||||
// All body-owners have MIR associated with them.
|
// All body-owners have MIR associated with them.
|
||||||
set.extend(tcx.hir().body_owners());
|
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.
|
// they don't have a BodyId, so we need to build them separately.
|
||||||
struct GatherCtors<'a, 'tcx> {
|
struct GatherCtors<'a, 'tcx> {
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
set: &'a mut FxHashSet<LocalDefId>,
|
set: &'a mut FxIndexSet<LocalDefId>,
|
||||||
}
|
}
|
||||||
impl<'tcx> Visitor<'tcx> for GatherCtors<'_, 'tcx> {
|
impl<'tcx> Visitor<'tcx> for GatherCtors<'_, 'tcx> {
|
||||||
fn visit_variant_data(
|
fn visit_variant_data(
|
||||||
|
|
|
@ -4,7 +4,7 @@ version = "0.0.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
indexmap = "1"
|
indexmap = "1.8.0"
|
||||||
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
|
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
|
@ -1,21 +1,5 @@
|
||||||
// WARNING: This output format is intended for human consumers only
|
// WARNING: This output format is intended for human consumers only
|
||||||
// and is subject to change without notice. Knock yourself out.
|
// 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 {
|
fn foo() -> i32 {
|
||||||
let mut _0: i32; // return place in scope 0 at main.rs:4:19: 4:22
|
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
|
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…
Add table
Reference in a new issue