Skip to content

Commit e7825f2

Browse files
committed
Auto merge of #90842 - pierwill:localdefid-indexmap, r=wesleywiser
Use `indexmap` to avoid sorting `LocalDefId`s See discussion in #90408 (comment). Related to work on #90317.
2 parents 51126be + 4f89224 commit e7825f2

File tree

9 files changed

+30
-31
lines changed

9 files changed

+30
-31
lines changed

Cargo.lock

+3-2
Original file line numberDiff line numberDiff line change
@@ -1739,12 +1739,13 @@ dependencies = [
17391739

17401740
[[package]]
17411741
name = "indexmap"
1742-
version = "1.7.0"
1742+
version = "1.8.0"
17431743
source = "registry+https://github.com/rust-lang/crates.io-index"
1744-
checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5"
1744+
checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
17451745
dependencies = [
17461746
"autocfg",
17471747
"hashbrown 0.11.2",
1748+
"rustc-rayon",
17481749
"serde",
17491750
]
17501751

compiler/rustc_codegen_cranelift/Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
172172

173173
[[package]]
174174
name = "indexmap"
175-
version = "1.7.0"
175+
version = "1.8.0"
176176
source = "registry+https://github.com/rust-lang/crates.io-index"
177-
checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5"
177+
checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
178178
dependencies = [
179179
"autocfg",
180180
"hashbrown",

compiler/rustc_codegen_cranelift/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ gimli = { version = "0.25.0", default-features = false, features = ["write"]}
1919
object = { version = "0.27.0", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }
2020

2121
ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" }
22-
indexmap = "1.0.2"
22+
indexmap = "1.8.0"
2323
libloading = { version = "0.6.0", optional = true }
2424
smallvec = "1.6.1"
2525

compiler/rustc_data_structures/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ doctest = false
99
[dependencies]
1010
arrayvec = { version = "0.7", default-features = false }
1111
ena = "0.14"
12-
indexmap = "1.5.1"
12+
indexmap = { version = "1.8.0", features = ["rustc-rayon"] }
1313
tracing = "0.1"
1414
jobserver_crate = { version = "0.1.13", package = "jobserver" }
1515
rustc_serialize = { path = "../rustc_serialize" }

compiler/rustc_metadata/src/rmeta/encoder.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
13141314
return;
13151315
}
13161316

1317-
let mut keys_and_jobs = self
1317+
let keys_and_jobs = self
13181318
.tcx
13191319
.mir_keys(())
13201320
.iter()
@@ -1327,8 +1327,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
13271327
}
13281328
})
13291329
.collect::<Vec<_>>();
1330-
// Sort everything to ensure a stable order for diagnotics.
1331-
keys_and_jobs.sort_by_key(|&(def_id, _, _)| def_id.index());
13321330
for (def_id, encode_const, encode_opt) in keys_and_jobs.into_iter() {
13331331
debug_assert!(encode_const || encode_opt);
13341332

compiler/rustc_middle/src/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ rustc_queries! {
252252
/// Set of all the `DefId`s in this crate that have MIR associated with
253253
/// them. This includes all the body owners, but also things like struct
254254
/// constructors.
255-
query mir_keys(_: ()) -> FxHashSet<LocalDefId> {
255+
query mir_keys(_: ()) -> rustc_data_structures::fx::FxIndexSet<LocalDefId> {
256256
storage(ArenaCacheSelector<'tcx>)
257257
desc { "getting a list of all mir_keys" }
258258
}

compiler/rustc_mir_transform/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extern crate rustc_middle;
1818

1919
use required_consts::RequiredConstsVisitor;
2020
use rustc_const_eval::util;
21-
use rustc_data_structures::fx::FxHashSet;
21+
use rustc_data_structures::fx::FxIndexSet;
2222
use rustc_data_structures::steal::Steal;
2323
use rustc_hir as hir;
2424
use rustc_hir::def_id::{DefId, LocalDefId};
@@ -136,8 +136,8 @@ fn is_mir_available(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
136136

137137
/// Finds the full set of `DefId`s within the current crate that have
138138
/// MIR associated with them.
139-
fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxHashSet<LocalDefId> {
140-
let mut set = FxHashSet::default();
139+
fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LocalDefId> {
140+
let mut set = FxIndexSet::default();
141141

142142
// All body-owners have MIR associated with them.
143143
set.extend(tcx.hir().body_owners());
@@ -146,7 +146,7 @@ fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxHashSet<LocalDefId> {
146146
// they don't have a BodyId, so we need to build them separately.
147147
struct GatherCtors<'a, 'tcx> {
148148
tcx: TyCtxt<'tcx>,
149-
set: &'a mut FxHashSet<LocalDefId>,
149+
set: &'a mut FxIndexSet<LocalDefId>,
150150
}
151151
impl<'tcx> Visitor<'tcx> for GatherCtors<'_, 'tcx> {
152152
fn visit_variant_data(

compiler/rustc_serialize/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.0.0"
44
edition = "2021"
55

66
[dependencies]
7-
indexmap = "1"
7+
indexmap = "1.8.0"
88
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
99

1010
[dev-dependencies]

src/test/run-make/const_fn_mir/dump.mir

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
11
// WARNING: This output format is intended for human consumers only
22
// and is subject to change without notice. Knock yourself out.
3-
fn main() -> () {
4-
let mut _0: (); // return place in scope 0 at main.rs:8:11: 8:11
5-
let _1: i32; // in scope 0 at main.rs:9:5: 9:10
6-
7-
bb0: {
8-
_1 = foo() -> bb1; // scope 0 at main.rs:9:5: 9:10
9-
// mir::Constant
10-
// + span: main.rs:9:5: 9:8
11-
// + literal: Const { ty: fn() -> i32 {foo}, val: Value(Scalar(<ZST>)) }
12-
}
13-
14-
bb1: {
15-
return; // scope 0 at main.rs:10:2: 10:2
16-
}
17-
}
18-
193
fn foo() -> i32 {
204
let mut _0: i32; // return place in scope 0 at main.rs:4:19: 4:22
215

@@ -40,3 +24,19 @@ fn foo() -> i32 {
4024
return; // scope 0 at main.rs:6:2: 6:2
4125
}
4226
}
27+
28+
fn main() -> () {
29+
let mut _0: (); // return place in scope 0 at main.rs:8:11: 8:11
30+
let _1: i32; // in scope 0 at main.rs:9:5: 9:10
31+
32+
bb0: {
33+
_1 = foo() -> bb1; // scope 0 at main.rs:9:5: 9:10
34+
// mir::Constant
35+
// + span: main.rs:9:5: 9:8
36+
// + literal: Const { ty: fn() -> i32 {foo}, val: Value(Scalar(<ZST>)) }
37+
}
38+
39+
bb1: {
40+
return; // scope 0 at main.rs:10:2: 10:2
41+
}
42+
}

0 commit comments

Comments
 (0)