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) -> Self
fn from(id: EditionedFileId) -> Self
source§impl From<MacroCallId> for HirFileId
impl From<MacroCallId> for HirFileId
source§fn from(value: MacroCallId) -> Self
fn from(value: MacroCallId) -> Self
source§impl From<MacroFileId> for HirFileId
impl From<MacroFileId> for HirFileId
source§fn from(_: MacroFileId) -> Self
fn from(_: MacroFileId) -> Self
source§impl Ord for HirFileId
impl Ord for HirFileId
source§impl PartialEq<EditionedFileId> for HirFileId
impl PartialEq<EditionedFileId> for HirFileId
source§impl PartialEq<HirFileId> for EditionedFileId
impl PartialEq<HirFileId> for EditionedFileId
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§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