Skip to content

Commit

Permalink
Use rustc-hash everywhere internally as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
obi1kenobi committed Jan 16, 2025
1 parent 2c8290d commit ac0839c
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ jobs:
- name: test with rayon
run: cargo test --features rayon

- name: compile with rayon and rustc-hash
run: cargo test --no-run --features rayon,rustc-hash

- name: test with rayon and rustc-hash
run: cargo test --features rayon,rustc-hash

publish:
name: Publish to crates.io
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion src/adapter/edges.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::{num::NonZeroUsize, rc::Rc};

use rustdoc_types::{
GenericBound::TraitBound, GenericParamDefKind, Id, ItemEnum, VariantKind, WherePredicate,
};
use std::{num::NonZeroUsize, rc::Rc};
use trustfall::provider::{
resolve_neighbors_with, AsVertex, ContextIterator, ContextOutcomeIterator, ResolveEdgeInfo,
VertexIterator,
Expand Down
3 changes: 2 additions & 1 deletion src/adapter/enum_variant.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use rustdoc_types::{Item, ItemEnum, Variant};
use std::borrow::Cow;
use std::cell::OnceCell;
use std::fmt::{self, Debug};
use std::num::ParseIntError;
use std::rc::Rc;
use std::str::FromStr;

use rustdoc_types::{Item, ItemEnum, Variant};

#[non_exhaustive]
#[derive(Debug, Clone)]
pub struct EnumVariant<'a> {
Expand Down
4 changes: 4 additions & 0 deletions src/adapter/optimizations/impl_lookup.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#[cfg(not(feature = "rustc-hash"))]
use std::collections::HashMap;

#[cfg(feature = "rustc-hash")]
use rustc_hash::FxHashMap as HashMap;

use rustdoc_types::{Id, Item};
use trustfall::{
provider::{
Expand Down
8 changes: 7 additions & 1 deletion src/adapter/optimizations/method_lookup.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
use std::collections::{BTreeSet, HashMap};
use std::collections::BTreeSet;

#[cfg(not(feature = "rustc-hash"))]
use std::collections::HashMap;

#[cfg(feature = "rustc-hash")]
use rustc_hash::FxHashMap as HashMap;

use rustdoc_types::{Id, Impl, Item, ItemEnum, Type};
use trustfall::{
Expand Down
12 changes: 9 additions & 3 deletions src/indexed_crate.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
use std::{

Check warning on line 1 in src/indexed_crate.rs

View workflow job for this annotation

GitHub Actions / Check lint and rustfmt

Diff in /home/runner/work/trustfall-rustdoc-adapter/trustfall-rustdoc-adapter/src/indexed_crate.rs
borrow::Borrow,
collections::{hash_map::Entry, HashMap, HashSet},
collections::hash_map::Entry,
sync::Arc,
};

#[cfg(not(feature = "rustc-hash"))]
use std::collections::{HashMap, HashSet};

#[cfg(feature = "rustc-hash")]
use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet};

#[cfg(feature = "rayon")]
use rayon::prelude::*;
use rustdoc_types::{Crate, Id, Item};
Expand Down Expand Up @@ -270,7 +276,7 @@ impl<K: std::cmp::Eq + std::hash::Hash, V> Extend<(K, V)> for MapList<K, V> {
impl<K: std::cmp::Eq + std::hash::Hash, V> MapList<K, V> {
#[inline]
pub fn new() -> Self {
Self(HashMap::new())
Self(HashMap::default())
}

#[inline]
Expand Down Expand Up @@ -786,7 +792,7 @@ fn new_trait(manual_trait_item: &ManualTraitItem, id: Id, crate_id: u32) -> Item
span: None,
visibility: rustdoc_types::Visibility::Public,
docs: None,
links: HashMap::new(),
links: HashMap::default(),
attrs: Vec::new(),
deprecation: None,
inner: rustdoc_types::ItemEnum::Trait(rustdoc_types::Trait {
Expand Down
5 changes: 3 additions & 2 deletions src/visibility_tracker.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#[cfg(feature = "rustc-hash")]
use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet};
#[cfg(not(feature = "rustc-hash"))]
use std::collections::{HashMap, HashSet};

#[cfg(feature = "rustc-hash")]
use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet};

use rustdoc_types::{Crate, GenericArgs, Id, Item, ItemEnum, TypeAlias, Visibility};

#[cfg(feature = "rayon")]
Expand Down

0 comments on commit ac0839c

Please sign in to comment.