fix warnings

This commit is contained in:
Jake Heinz 2022-01-14 09:25:45 +00:00
parent 343b0ccfb9
commit 2b0d8a86a2
2 changed files with 9 additions and 10 deletions

View file

@ -7,7 +7,7 @@ mod topologic_sort;
use hir::db::DefDatabase; use hir::db::DefDatabase;
use ide_db::base_db::{ use ide_db::base_db::{
salsa::{Database, ParallelDatabase, Snapshot}, salsa::{Database, ParallelDatabase, Snapshot},
Cancelled, CrateGraph, CrateId, SourceDatabase, SourceDatabaseExt, CrateGraph, CrateId, SourceDatabase, SourceDatabaseExt,
}; };
use rustc_hash::{FxHashMap, FxHashSet}; use rustc_hash::{FxHashMap, FxHashSet};
@ -104,7 +104,6 @@ where
let crates_total = crates_to_prime.len(); let crates_total = crates_to_prime.len();
let mut crates_done = 0; let mut crates_done = 0;
let mut crates_currently_indexing = let mut crates_currently_indexing =
FxHashMap::with_capacity_and_hasher(num_worker_threads as _, Default::default()); FxHashMap::with_capacity_and_hasher(num_worker_threads as _, Default::default());

View file

@ -2,7 +2,7 @@ use std::{collections::VecDeque, hash::Hash};
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
pub struct TopologicSortIterBuilder<T> { pub(crate) struct TopologicSortIterBuilder<T> {
nodes: FxHashMap<T, Entry<T>>, nodes: FxHashMap<T, Entry<T>>,
} }
@ -18,7 +18,7 @@ where
self.nodes.entry(item).or_default() self.nodes.entry(item).or_default()
} }
pub fn add(&mut self, item: T, predecessors: impl IntoIterator<Item = T>) { pub(crate) fn add(&mut self, item: T, predecessors: impl IntoIterator<Item = T>) {
let mut num_predecessors = 0; let mut num_predecessors = 0;
for predecessor in predecessors.into_iter() { for predecessor in predecessors.into_iter() {
@ -30,7 +30,7 @@ where
entry.num_predecessors += num_predecessors; entry.num_predecessors += num_predecessors;
} }
pub fn build(self) -> TopologicalSortIter<T> { pub(crate) fn build(self) -> TopologicalSortIter<T> {
let ready = self let ready = self
.nodes .nodes
.iter() .iter()
@ -43,7 +43,7 @@ where
} }
} }
pub struct TopologicalSortIter<T> { pub(crate) struct TopologicalSortIter<T> {
ready: VecDeque<T>, ready: VecDeque<T>,
nodes: FxHashMap<T, Entry<T>>, nodes: FxHashMap<T, Entry<T>>,
} }
@ -52,19 +52,19 @@ impl<T> TopologicalSortIter<T>
where where
T: Copy + Eq + PartialEq + Hash, T: Copy + Eq + PartialEq + Hash,
{ {
pub fn builder() -> TopologicSortIterBuilder<T> { pub(crate) fn builder() -> TopologicSortIterBuilder<T> {
TopologicSortIterBuilder::new() TopologicSortIterBuilder::new()
} }
pub fn len(&self) -> usize { pub(crate) fn len(&self) -> usize {
self.nodes.len() self.nodes.len()
} }
pub fn is_empty(&self) -> bool { pub(crate) fn is_empty(&self) -> bool {
self.len() == 0 self.len() == 0
} }
pub fn mark_done(&mut self, item: T) { pub(crate) fn mark_done(&mut self, item: T) {
let entry = self.nodes.remove(&item).expect("invariant: unknown item marked as done"); let entry = self.nodes.remove(&item).expect("invariant: unknown item marked as done");
for successor in entry.successors { for successor in entry.successors {