Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/vfs/src/lib.rs')
-rw-r--r--crates/vfs/src/lib.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/crates/vfs/src/lib.rs b/crates/vfs/src/lib.rs
index 8ffda5d78d..ef5b10ee9d 100644
--- a/crates/vfs/src/lib.rs
+++ b/crates/vfs/src/lib.rs
@@ -61,13 +61,17 @@ 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(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 fn from_raw(raw: u32) -> FileId {
+ pub const fn from_raw(raw: u32) -> FileId {
+ assert!(raw <= Self::MAX_FILE_ID);
FileId(raw)
}