Skip to content

Commit 941c443

Browse files
committed
Auto merge of #17954 - Noratrieb:rustc-blazing-hash, r=Veykril
Update rustc-hash to version 2 This brings in the new optimized algorithm that was shown to have small performance benefits for rustc. I haven't run the rust-analyzer benchmarks. See rust-lang/rustc-hash#37.
2 parents f21a01f + 2adc6c3 commit 941c443

File tree

13 files changed

+227
-218
lines changed

13 files changed

+227
-218
lines changed

src/tools/rust-analyzer/Cargo.lock

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ dependencies = [
7373
"intern",
7474
"la-arena 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
7575
"lz4_flex",
76-
"rustc-hash",
76+
"rustc-hash 2.0.0",
7777
"salsa",
7878
"semver",
7979
"span",
@@ -161,7 +161,7 @@ dependencies = [
161161
"expect-test",
162162
"intern",
163163
"oorandom",
164-
"rustc-hash",
164+
"rustc-hash 2.0.0",
165165
"syntax",
166166
"syntax-bridge",
167167
"tt",
@@ -216,7 +216,7 @@ dependencies = [
216216
"chalk-derive",
217217
"chalk-ir",
218218
"chalk-solve",
219-
"rustc-hash",
219+
"rustc-hash 1.1.0",
220220
"tracing",
221221
]
222222

@@ -232,7 +232,7 @@ dependencies = [
232232
"indexmap",
233233
"itertools",
234234
"petgraph",
235-
"rustc-hash",
235+
"rustc-hash 1.1.0",
236236
"tracing",
237237
]
238238

@@ -513,7 +513,7 @@ dependencies = [
513513
"hir-ty",
514514
"intern",
515515
"itertools",
516-
"rustc-hash",
516+
"rustc-hash 2.0.0",
517517
"smallvec",
518518
"span",
519519
"stdx",
@@ -547,7 +547,7 @@ dependencies = [
547547
"mbe",
548548
"ra-ap-rustc_abi",
549549
"ra-ap-rustc_parse_format",
550-
"rustc-hash",
550+
"rustc-hash 2.0.0",
551551
"rustc_apfloat",
552552
"smallvec",
553553
"span",
@@ -577,7 +577,7 @@ dependencies = [
577577
"limit",
578578
"mbe",
579579
"parser",
580-
"rustc-hash",
580+
"rustc-hash 2.0.0",
581581
"smallvec",
582582
"span",
583583
"stdx",
@@ -616,7 +616,7 @@ dependencies = [
616616
"ra-ap-rustc_abi",
617617
"ra-ap-rustc_index",
618618
"ra-ap-rustc_pattern_analysis",
619-
"rustc-hash",
619+
"rustc-hash 2.0.0",
620620
"rustc_apfloat",
621621
"scoped-tls",
622622
"smallvec",
@@ -737,7 +737,7 @@ dependencies = [
737737
"parser",
738738
"profile",
739739
"rayon",
740-
"rustc-hash",
740+
"rustc-hash 2.0.0",
741741
"span",
742742
"stdx",
743743
"syntax",
@@ -834,7 +834,7 @@ version = "0.0.0"
834834
dependencies = [
835835
"dashmap",
836836
"hashbrown",
837-
"rustc-hash",
837+
"rustc-hash 2.0.0",
838838
"sptr",
839839
"triomphe",
840840
]
@@ -1051,7 +1051,7 @@ dependencies = [
10511051
"intern",
10521052
"parser",
10531053
"ra-ap-rustc_lexer",
1054-
"rustc-hash",
1054+
"rustc-hash 2.0.0",
10551055
"smallvec",
10561056
"span",
10571057
"stdx",
@@ -1345,7 +1345,7 @@ dependencies = [
13451345
"indexmap",
13461346
"intern",
13471347
"paths",
1348-
"rustc-hash",
1348+
"rustc-hash 2.0.0",
13491349
"serde",
13501350
"serde_json",
13511351
"span",
@@ -1435,7 +1435,7 @@ dependencies = [
14351435
"itertools",
14361436
"la-arena 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
14371437
"paths",
1438-
"rustc-hash",
1438+
"rustc-hash 2.0.0",
14391439
"semver",
14401440
"serde",
14411441
"serde_json",
@@ -1555,7 +1555,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
15551555
checksum = "273d5f72926a58c7eea27aebc898d1d5b32d23d2342f692a94a2cf8746aa4a2f"
15561556
dependencies = [
15571557
"ra-ap-rustc_index",
1558-
"rustc-hash",
1558+
"rustc-hash 1.1.0",
15591559
"rustc_apfloat",
15601560
"smallvec",
15611561
"tracing",
@@ -1640,7 +1640,7 @@ dependencies = [
16401640
"countme",
16411641
"hashbrown",
16421642
"memoffset",
1643-
"rustc-hash",
1643+
"rustc-hash 1.1.0",
16441644
"text-size",
16451645
]
16461646

@@ -1680,7 +1680,7 @@ dependencies = [
16801680
"profile",
16811681
"project-model",
16821682
"rayon",
1683-
"rustc-hash",
1683+
"rustc-hash 2.0.0",
16841684
"scip",
16851685
"semver",
16861686
"serde",
@@ -1717,6 +1717,12 @@ version = "1.1.0"
17171717
source = "registry+https://github.com/rust-lang/crates.io-index"
17181718
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
17191719

1720+
[[package]]
1721+
name = "rustc-hash"
1722+
version = "2.0.0"
1723+
source = "registry+https://github.com/rust-lang/crates.io-index"
1724+
checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152"
1725+
17201726
[[package]]
17211727
name = "rustc_apfloat"
17221728
version = "0.2.1+llvm-462a31f5a5ab"
@@ -1746,7 +1752,7 @@ dependencies = [
17461752
"oorandom",
17471753
"parking_lot",
17481754
"rand",
1749-
"rustc-hash",
1755+
"rustc-hash 2.0.0",
17501756
"salsa-macros",
17511757
"smallvec",
17521758
"tracing",
@@ -1898,7 +1904,7 @@ version = "0.0.0"
18981904
dependencies = [
18991905
"hashbrown",
19001906
"la-arena 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
1901-
"rustc-hash",
1907+
"rustc-hash 2.0.0",
19021908
"salsa",
19031909
"stdx",
19041910
"syntax",
@@ -1967,7 +1973,7 @@ dependencies = [
19671973
"ra-ap-rustc_lexer",
19681974
"rayon",
19691975
"rowan",
1970-
"rustc-hash",
1976+
"rustc-hash 2.0.0",
19711977
"rustc_apfloat",
19721978
"smol_str",
19731979
"stdx",
@@ -1983,7 +1989,7 @@ version = "0.0.0"
19831989
dependencies = [
19841990
"intern",
19851991
"parser",
1986-
"rustc-hash",
1992+
"rustc-hash 2.0.0",
19871993
"span",
19881994
"stdx",
19891995
"syntax",
@@ -2000,7 +2006,7 @@ dependencies = [
20002006
"cfg",
20012007
"hir-expand",
20022008
"intern",
2003-
"rustc-hash",
2009+
"rustc-hash 2.0.0",
20042010
"span",
20052011
"stdx",
20062012
"test-utils",
@@ -2014,7 +2020,7 @@ dependencies = [
20142020
"dissimilar",
20152021
"paths",
20162022
"profile",
2017-
"rustc-hash",
2023+
"rustc-hash 2.0.0",
20182024
"stdx",
20192025
"text-size",
20202026
"tracing",
@@ -2361,7 +2367,7 @@ dependencies = [
23612367
"indexmap",
23622368
"nohash-hasher",
23632369
"paths",
2364-
"rustc-hash",
2370+
"rustc-hash 2.0.0",
23652371
"stdx",
23662372
"tracing",
23672373
]
@@ -2374,7 +2380,7 @@ dependencies = [
23742380
"notify",
23752381
"paths",
23762382
"rayon",
2377-
"rustc-hash",
2383+
"rustc-hash 2.0.0",
23782384
"stdx",
23792385
"tracing",
23802386
"vfs",

src/tools/rust-analyzer/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ process-wrap = { version = "8.0.2", features = ["std"] }
136136
pulldown-cmark-to-cmark = "10.0.4"
137137
pulldown-cmark = { version = "0.9.0", default-features = false }
138138
rayon = "1.8.0"
139-
rustc-hash = "1.1.0"
139+
rustc-hash = "2.0.0"
140140
semver = "1.0.14"
141141
serde = { version = "1.0.192", features = ["derive"] }
142142
serde_json = "1.0.108"

src/tools/rust-analyzer/crates/hir-ty/src/consteval/tests.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ fn check_answer(ra_fixture: &str, check: impl FnOnce(&[u8], &MemoryMap)) {
9595
fn pretty_print_err(e: ConstEvalError, db: TestDB) -> String {
9696
let mut err = String::new();
9797
let span_formatter = |file, range| format!("{file:?} {range:?}");
98-
let edition = db.crate_graph()[db.test_crate()].edition;
98+
let edition =
99+
db.crate_graph()[*db.crate_graph().crates_in_topological_order().last().unwrap()].edition;
99100
match e {
100101
ConstEvalError::MirLowerError(e) => e.pretty_print(&mut err, &db, span_formatter, edition),
101102
ConstEvalError::MirEvalError(e) => e.pretty_print(&mut err, &db, span_formatter, edition),
@@ -2896,7 +2897,7 @@ fn recursive_adt() {
28962897
{
28972898
const VARIANT_TAG_TREE: TagTree = TagTree::Choice(
28982899
&[
2899-
TagTree::Leaf,
2900+
TAG_TREE,
29002901
],
29012902
);
29022903
VARIANT_TAG_TREE
@@ -2905,6 +2906,6 @@ fn recursive_adt() {
29052906
TAG_TREE
29062907
};
29072908
"#,
2908-
|e| matches!(e, ConstEvalError::MirEvalError(MirEvalError::StackOverflow)),
2909+
|e| matches!(e, ConstEvalError::MirLowerError(MirLowerError::Loop)),
29092910
);
29102911
}

src/tools/rust-analyzer/crates/hir-ty/src/lib.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ mod test_db;
5151
#[cfg(test)]
5252
mod tests;
5353

54-
use std::{
55-
collections::hash_map::Entry,
56-
hash::{BuildHasherDefault, Hash},
57-
};
54+
use std::hash::Hash;
5855

5956
use base_db::ra_salsa::InternValueTrivial;
6057
use chalk_ir::{
@@ -65,10 +62,11 @@ use chalk_ir::{
6562
use either::Either;
6663
use hir_def::{hir::ExprId, type_ref::Rawness, CallableDefId, GeneralConstId, TypeOrConstParamId};
6764
use hir_expand::name::Name;
65+
use indexmap::{map::Entry, IndexMap};
6866
use intern::{sym, Symbol};
6967
use la_arena::{Arena, Idx};
7068
use mir::{MirEvalError, VTableMap};
71-
use rustc_hash::{FxHashMap, FxHashSet};
69+
use rustc_hash::{FxBuildHasher, FxHashMap, FxHashSet};
7270
use span::Edition;
7371
use syntax::ast::{make, ConstArg};
7472
use traits::FnTrait;
@@ -199,7 +197,7 @@ pub enum MemoryMap {
199197

200198
#[derive(Debug, Default, Clone, PartialEq, Eq)]
201199
pub struct ComplexMemoryMap {
202-
memory: FxHashMap<usize, Box<[u8]>>,
200+
memory: IndexMap<usize, Box<[u8]>, FxBuildHasher>,
203201
vtable: VTableMap,
204202
}
205203

@@ -245,7 +243,7 @@ impl MemoryMap {
245243
match self {
246244
MemoryMap::Empty => Ok(Default::default()),
247245
MemoryMap::Simple(m) => transform((&0, m)).map(|(addr, val)| {
248-
let mut map = FxHashMap::with_capacity_and_hasher(1, BuildHasherDefault::default());
246+
let mut map = FxHashMap::with_capacity_and_hasher(1, rustc_hash::FxBuildHasher);
249247
map.insert(addr, val);
250248
map
251249
}),

src/tools/rust-analyzer/crates/ide-assists/src/handlers/bool_to_enum.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,7 @@ fn main() {
10951095

10961096
#[test]
10971097
fn field_enum_cross_file() {
1098+
// FIXME: The import is missing
10981099
check_assist(
10991100
bool_to_enum,
11001101
r#"
@@ -1132,7 +1133,7 @@ fn foo() {
11321133
}
11331134
11341135
//- /main.rs
1135-
use foo::{Bool, Foo};
1136+
use foo::Foo;
11361137
11371138
mod foo;
11381139

src/tools/rust-analyzer/crates/ide-completion/src/render.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1853,8 +1853,8 @@ fn f() { A { bar: b$0 }; }
18531853
expect![[r#"
18541854
fn bar() [type+name]
18551855
fn baz() [type]
1856-
ex baz() [type]
18571856
ex bar() [type]
1857+
ex baz() [type]
18581858
st A []
18591859
fn f() []
18601860
"#]],

0 commit comments

Comments
 (0)