Make use of NoHash hashing for FileId and CrateId

This commit is contained in:
Lukas Wirth 2022-08-25 20:31:02 +02:00
parent 8dcf4c70c4
commit d025c5d8d6
22 changed files with 189 additions and 72 deletions

View file

@ -59,9 +59,16 @@ pub use paths::{AbsPath, AbsPathBuf};
/// Handle to a file in [`Vfs`]
///
/// Most functions in rust-analyzer use this when they need to refer to a file.
#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)]
#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq)]
pub struct FileId(pub u32);
impl stdx::hash::NoHashHashable for FileId {}
impl std::hash::Hash for FileId {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.0.hash(state);
}
}
/// Storage for all files read by rust-analyzer.
///
/// For more information see the [crate-level](crate) documentation.