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§
§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§
§impl From<MacroFileId> for HirFileId
impl From<MacroFileId> for HirFileId
§fn from(_: MacroFileId) -> HirFileId
fn from(_: MacroFileId) -> HirFileId
§impl HirFileIdExt for HirFileId
impl HirFileIdExt for HirFileId
fn edition(self, db: &dyn ExpandDatabase) -> Edition
§fn original_file(self, db: &dyn ExpandDatabase) -> EditionedFileId
fn original_file(self, db: &dyn ExpandDatabase) -> EditionedFileId
§fn original_file_respecting_includes(
self,
db: &dyn ExpandDatabase,
) -> EditionedFileId
fn original_file_respecting_includes( self, db: &dyn ExpandDatabase, ) -> EditionedFileId
§fn original_call_node(
self,
db: &dyn ExpandDatabase,
) -> Option<InFileWrapper<EditionedFileId, SyntaxNode<RustLanguage>>>
fn original_call_node( self, db: &dyn ExpandDatabase, ) -> Option<InFileWrapper<EditionedFileId, SyntaxNode<RustLanguage>>>
fn as_builtin_derive_attr_node( &self, db: &dyn ExpandDatabase, ) -> Option<InFileWrapper<HirFileId, Attr>>
§impl Ord for HirFileId
impl Ord for HirFileId
§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
§impl<T> Cast for T
impl<T> Cast for T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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