pub struct HirFileId(/* private fields */);Expand description
Input to the analyzer is a set of files, where each file is identified by
FileId and contains source code. However, another source of source code in
Rust are macros: each macro can be thought of as producing a “temporary
file”. To assign an id to such a file, we use the id of the macro call that
produced the file. So, a HirFileId is either a FileId (source code
written by user), or a MacroCallId (source code produced by macro).
What is a MacroCallId? Simplifying, it’s a HirFileId of a file
containing the call plus the offset of the macro call in the file. Note that
this is a recursive definition! However, the size_of of HirFileId is
finite (because everything bottoms out at the real FileId) and small
(MacroCallId uses the location interning. You can check details here:
https://en.wikipedia.org/wiki/String_interning).
The two variants are encoded in a single u32 which are differentiated by the MSB.
If the MSB is 0, the value represents a FileId, otherwise the remaining 31 bits represent a
MacroCallId.
Implementations§
Source§impl HirFileId
impl HirFileId
pub fn is_macro(self) -> bool
pub fn macro_file(self) -> Option<MacroFileId>
pub fn file_id(self) -> Option<EditionedFileId>
pub fn repr(self) -> HirFileIdRepr
Trait Implementations§
Source§impl From<EditionedFileId> for HirFileId
impl From<EditionedFileId> for HirFileId
Source§fn from(id: EditionedFileId) -> HirFileId
fn from(id: EditionedFileId) -> HirFileId
Source§impl From<MacroCallId> for HirFileId
impl From<MacroCallId> for HirFileId
Source§fn from(value: MacroCallId) -> HirFileId
fn from(value: MacroCallId) -> HirFileId
Source§impl From<MacroFileId> for HirFileId
impl From<MacroFileId> for HirFileId
Source§fn from(_: MacroFileId) -> HirFileId
fn from(_: MacroFileId) -> HirFileId
Source§impl HirFileIdExt for HirFileId
impl HirFileIdExt for HirFileId
fn edition(self, db: &dyn ExpandDatabase) -> Edition
Source§fn original_file(self, db: &dyn ExpandDatabase) -> EditionedFileId
fn original_file(self, db: &dyn ExpandDatabase) -> EditionedFileId
Source§fn original_file_respecting_includes(
self,
db: &dyn ExpandDatabase,
) -> EditionedFileId
fn original_file_respecting_includes( self, db: &dyn ExpandDatabase, ) -> EditionedFileId
Source§fn original_call_node(
self,
db: &dyn ExpandDatabase,
) -> Option<InRealFile<SyntaxNode>>
fn original_call_node( self, db: &dyn ExpandDatabase, ) -> Option<InRealFile<SyntaxNode>>
fn as_builtin_derive_attr_node( &self, db: &dyn ExpandDatabase, ) -> Option<InFile<Attr>>
Source§impl Ord for HirFileId
impl Ord for HirFileId
Source§impl PartialEq<EditionedFileId> for HirFileId
impl PartialEq<EditionedFileId> for HirFileId
Source§impl PartialOrd for HirFileId
impl PartialOrd for HirFileId
impl Copy for HirFileId
impl Eq for HirFileId
impl StructuralPartialEq for HirFileId
Auto Trait Implementations§
impl Freeze for HirFileId
impl RefUnwindSafe for HirFileId
impl Send for HirFileId
impl Sync for HirFileId
impl Unpin for HirFileId
impl UnwindSafe for HirFileId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FromIdWithDb for Twhere
T: FromId,
impl<T> FromIdWithDb for Twhere
T: FromId,
Source§impl<T> HashEqLike<&T> for T
impl<T> HashEqLike<&T> for T
Source§impl<T> HashEqLike<T> for T
impl<T> HashEqLike<T> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more