pub struct HirFileId(_);
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
sourcepub fn original_file(self, db: &dyn AstDatabase) -> FileId
pub fn original_file(self, db: &dyn AstDatabase) -> FileId
For macro-expansion files, returns the file original source file the expansion originated from.
pub fn expansion_level(self, db: &dyn AstDatabase) -> u32
sourcepub fn call_node(
self,
db: &dyn AstDatabase
) -> Option<InFile<SyntaxNode<RustLanguage>>>
pub fn call_node(
self,
db: &dyn AstDatabase
) -> Option<InFile<SyntaxNode<RustLanguage>>>
If this is a macro call, returns the syntax node of the call.
sourcepub fn original_call_node(
self,
db: &dyn AstDatabase
) -> Option<(FileId, SyntaxNode<RustLanguage>)>
pub fn original_call_node(
self,
db: &dyn AstDatabase
) -> Option<(FileId, SyntaxNode<RustLanguage>)>
If this is a macro call, returns the syntax node of the very first macro call this file resides in.
sourcepub fn expansion_info(self, db: &dyn AstDatabase) -> Option<ExpansionInfo>
pub fn expansion_info(self, db: &dyn AstDatabase) -> Option<ExpansionInfo>
Return expansion information if it is a macro-expansion file
sourcepub fn is_builtin_derive(&self, db: &dyn AstDatabase) -> Option<InFile<Attr>>
pub fn is_builtin_derive(&self, db: &dyn AstDatabase) -> Option<InFile<Attr>>
Indicate it is macro file generated for builtin derive
pub fn is_custom_derive(&self, db: &dyn AstDatabase) -> bool
sourcepub fn is_include_macro(&self, db: &dyn AstDatabase) -> bool
pub fn is_include_macro(&self, db: &dyn AstDatabase) -> bool
Return whether this file is an include macro
sourcepub fn is_attr_macro(&self, db: &dyn AstDatabase) -> bool
pub fn is_attr_macro(&self, db: &dyn AstDatabase) -> bool
Return whether this file is an attr macro
sourcepub fn is_derive_attr_pseudo_expansion(&self, db: &dyn AstDatabase) -> bool
pub fn is_derive_attr_pseudo_expansion(&self, db: &dyn AstDatabase) -> bool
Return whether this file is the pseudo expansion of the derive attribute.
See [crate::builtin_attr_macro::derive_attr_expand
].
pub fn is_macro(self) -> bool
pub fn macro_file(self) -> Option<MacroFile>
pub fn file_id(self) -> Option<FileId>
Trait Implementations§
source§impl PartialEq<HirFileId> for HirFileId
impl PartialEq<HirFileId> for HirFileId
impl Copy for HirFileId
impl Eq for HirFileId
impl StructuralEq for HirFileId
impl StructuralPartialEq for HirFileId
Auto Trait Implementations§
impl RefUnwindSafe for HirFileId
impl Send for HirFileId
impl Sync for HirFileId
impl Unpin for HirFileId
impl UnwindSafe for HirFileId
Blanket Implementations§
§impl<T> Cast for T
impl<T> Cast for T
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.