Skip to content

Commit

Permalink
Auto merge of #17954 - Noratrieb:rustc-blazing-hash, r=Veykril
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Oct 21, 2024
2 parents 9323b53 + 02e189d commit fb832ff
Show file tree
Hide file tree
Showing 13 changed files with 227 additions and 218 deletions.
54 changes: 30 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ process-wrap = { version = "8.0.2", features = ["std"] }
pulldown-cmark-to-cmark = "10.0.4"
pulldown-cmark = { version = "0.9.0", default-features = false }
rayon = "1.8.0"
rustc-hash = "1.1.0"
rustc-hash = "2.0.0"
semver = "1.0.14"
serde = { version = "1.0.192", features = ["derive"] }
serde_json = "1.0.108"
Expand Down
7 changes: 4 additions & 3 deletions crates/hir-ty/src/consteval/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ fn check_answer(ra_fixture: &str, check: impl FnOnce(&[u8], &MemoryMap)) {
fn pretty_print_err(e: ConstEvalError, db: TestDB) -> String {
let mut err = String::new();
let span_formatter = |file, range| format!("{file:?} {range:?}");
let edition = db.crate_graph()[db.test_crate()].edition;
let edition =
db.crate_graph()[*db.crate_graph().crates_in_topological_order().last().unwrap()].edition;
match e {
ConstEvalError::MirLowerError(e) => e.pretty_print(&mut err, &db, span_formatter, edition),
ConstEvalError::MirEvalError(e) => e.pretty_print(&mut err, &db, span_formatter, edition),
Expand Down Expand Up @@ -2896,7 +2897,7 @@ fn recursive_adt() {
{
const VARIANT_TAG_TREE: TagTree = TagTree::Choice(
&[
TagTree::Leaf,
TAG_TREE,
],
);
VARIANT_TAG_TREE
Expand All @@ -2905,6 +2906,6 @@ fn recursive_adt() {
TAG_TREE
};
"#,
|e| matches!(e, ConstEvalError::MirEvalError(MirEvalError::StackOverflow)),
|e| matches!(e, ConstEvalError::MirLowerError(MirLowerError::Loop)),
);
}
12 changes: 5 additions & 7 deletions crates/hir-ty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ mod test_db;
#[cfg(test)]
mod tests;

use std::{
collections::hash_map::Entry,
hash::{BuildHasherDefault, Hash},
};
use std::hash::Hash;

use base_db::ra_salsa::InternValueTrivial;
use chalk_ir::{
Expand All @@ -65,10 +62,11 @@ use chalk_ir::{
use either::Either;
use hir_def::{hir::ExprId, type_ref::Rawness, CallableDefId, GeneralConstId, TypeOrConstParamId};
use hir_expand::name::Name;
use indexmap::{map::Entry, IndexMap};
use intern::{sym, Symbol};
use la_arena::{Arena, Idx};
use mir::{MirEvalError, VTableMap};
use rustc_hash::{FxHashMap, FxHashSet};
use rustc_hash::{FxBuildHasher, FxHashMap, FxHashSet};
use span::Edition;
use syntax::ast::{make, ConstArg};
use traits::FnTrait;
Expand Down Expand Up @@ -199,7 +197,7 @@ pub enum MemoryMap {

#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct ComplexMemoryMap {
memory: FxHashMap<usize, Box<[u8]>>,
memory: IndexMap<usize, Box<[u8]>, FxBuildHasher>,
vtable: VTableMap,
}

Expand Down Expand Up @@ -245,7 +243,7 @@ impl MemoryMap {
match self {
MemoryMap::Empty => Ok(Default::default()),
MemoryMap::Simple(m) => transform((&0, m)).map(|(addr, val)| {
let mut map = FxHashMap::with_capacity_and_hasher(1, BuildHasherDefault::default());
let mut map = FxHashMap::with_capacity_and_hasher(1, rustc_hash::FxBuildHasher);
map.insert(addr, val);
map
}),
Expand Down
3 changes: 2 additions & 1 deletion crates/ide-assists/src/handlers/bool_to_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ fn main() {

#[test]
fn field_enum_cross_file() {
// FIXME: The import is missing
check_assist(
bool_to_enum,
r#"
Expand Down Expand Up @@ -1132,7 +1133,7 @@ fn foo() {
}
//- /main.rs
use foo::{Bool, Foo};
use foo::Foo;
mod foo;
Expand Down
2 changes: 1 addition & 1 deletion crates/ide-completion/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1853,8 +1853,8 @@ fn f() { A { bar: b$0 }; }
expect![[r#"
fn bar() [type+name]
fn baz() [type]
ex baz() [type]
ex bar() [type]
ex baz() [type]
st A []
fn f() []
"#]],
Expand Down
Loading

0 comments on commit fb832ff

Please sign in to comment.