fix: Syntax fixup now removes subtrees with fake spans

This commit is contained in:
Lukas Wirth 2023-12-15 13:52:49 +01:00
parent 96f660813c
commit 4c45d23948
5 changed files with 54 additions and 14 deletions

View file

@ -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)
}