Struct ra_ap_hir_expand::HirFileId
source · [−]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).
Implementations
sourceimpl 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>>
pub fn call_node(self, db: &dyn AstDatabase) -> Option<InFile<SyntaxNode>>
If this is a macro call, returns the syntax node of the call.
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>
Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more