summaryrefslogtreecommitdiffstats
path: root/src/tools/rust-analyzer/crates/vfs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /src/tools/rust-analyzer/crates/vfs
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/rust-analyzer/crates/vfs')
-rw-r--r--src/tools/rust-analyzer/crates/vfs/Cargo.toml2
-rw-r--r--src/tools/rust-analyzer/crates/vfs/src/lib.rs23
2 files changed, 22 insertions, 3 deletions
diff --git a/src/tools/rust-analyzer/crates/vfs/Cargo.toml b/src/tools/rust-analyzer/crates/vfs/Cargo.toml
index c35785cf9..11409f2eb 100644
--- a/src/tools/rust-analyzer/crates/vfs/Cargo.toml
+++ b/src/tools/rust-analyzer/crates/vfs/Cargo.toml
@@ -14,7 +14,7 @@ doctest = false
[dependencies]
rustc-hash = "1.1.0"
fst = "0.4.7"
-indexmap = "2.0.0"
+indexmap.workspace = true
nohash-hasher.workspace = true
paths.workspace = true
diff --git a/src/tools/rust-analyzer/crates/vfs/src/lib.rs b/src/tools/rust-analyzer/crates/vfs/src/lib.rs
index 06004adad..ef5b10ee9 100644
--- a/src/tools/rust-analyzer/crates/vfs/src/lib.rs
+++ b/src/tools/rust-analyzer/crates/vfs/src/lib.rs
@@ -38,7 +38,7 @@
//! [`Handle`]: loader::Handle
//! [`Entries`]: loader::Entry
-#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]
+#![warn(rust_2018_idioms, unused_lifetimes)]
mod anchored_path;
pub mod file_set;
@@ -60,7 +60,26 @@ pub use paths::{AbsPath, AbsPathBuf};
///
/// Most functions in rust-analyzer use this when they need to refer to a file.
#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)]
-pub struct FileId(pub u32);
+pub struct FileId(u32);
+// pub struct FileId(NonMaxU32);
+
+impl FileId {
+ /// Think twice about using this outside of tests. If this ends up in a wrong place it will cause panics!
+ // FIXME: To be removed once we get rid of all `SpanData::DUMMY` usages.
+ pub const BOGUS: FileId = FileId(0xe4e4e);
+ pub const MAX_FILE_ID: u32 = 0x7fff_ffff;
+
+ #[inline]
+ pub const fn from_raw(raw: u32) -> FileId {
+ assert!(raw <= Self::MAX_FILE_ID);
+ FileId(raw)
+ }
+
+ #[inline]
+ pub fn index(self) -> u32 {
+ self.0
+ }
+}
/// safe because `FileId` is a newtype of `u32`
impl nohash_hasher::IsEnabled for FileId {}