Struct hir_def::body::BodySourceMap
source · pub struct BodySourceMap { /* private fields */ }
Expand description
An item body together with the mapping from syntax nodes to HIR expression IDs. This is needed to go from e.g. a position in a file to the HIR expression containing it; but for type inference etc., we want to operate on a structure that is agnostic to the actual positions of expressions in the file, so that we don’t recompute types whenever some whitespace is typed.
One complication here is that, due to macro expansion, a single Body
might
be spread across several files. So, for each ExprId and PatId, we record
both the HirFileId and the position inside the file. However, we only store
AST -> ExprId mapping for non-macro files, as it is not clear how to handle
this properly for macros.
Implementations§
source§impl BodySourceMap
impl BodySourceMap
pub fn expr_syntax(&self, expr: ExprId) -> Result<ExprSource, SyntheticSyntax>
pub fn node_expr(&self, node: InFile<&Expr>) -> Option<ExprId>
pub fn node_macro_file(&self, node: InFile<&MacroCall>) -> Option<HirFileId>
pub fn pat_syntax(&self, pat: PatId) -> Result<PatSource, SyntheticSyntax>
pub fn self_param_syntax(&self) -> Option<InFile<AstPtr<SelfParam>>>
pub fn node_pat(&self, node: InFile<&Pat>) -> Option<PatId>
pub fn label_syntax(&self, label: LabelId) -> LabelSource
pub fn node_label(&self, node: InFile<&Label>) -> Option<LabelId>
pub fn field_syntax(&self, expr: ExprId) -> FieldSource
pub fn pat_field_syntax(&self, pat: PatId) -> PatFieldSource
pub fn macro_expansion_expr(&self, node: InFile<&MacroExpr>) -> Option<ExprId>
pub fn implicit_format_args( &self, node: InFile<&FormatArgsExpr> ) -> Option<&[(TextRange, Name)]>
sourcepub fn diagnostics(&self) -> &[BodyDiagnostic]
pub fn diagnostics(&self) -> &[BodyDiagnostic]
Get a reference to the body source map’s diagnostics.
Trait Implementations§
source§impl Debug for BodySourceMap
impl Debug for BodySourceMap
source§impl Default for BodySourceMap
impl Default for BodySourceMap
source§fn default() -> BodySourceMap
fn default() -> BodySourceMap
Returns the “default value” for a type. Read more
source§impl PartialEq for BodySourceMap
impl PartialEq for BodySourceMap
source§fn eq(&self, other: &BodySourceMap) -> bool
fn eq(&self, other: &BodySourceMap) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for BodySourceMap
impl StructuralPartialEq for BodySourceMap
Auto Trait Implementations§
impl Freeze for BodySourceMap
impl RefUnwindSafe for BodySourceMap
impl Send for BodySourceMap
impl Sync for BodySourceMap
impl Unpin for BodySourceMap
impl UnwindSafe for BodySourceMap
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
Mutably borrows from an owned value. Read more
§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
Checks if this value is equivalent to the given key. Read more
§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
Compare self to
key
and return true
if they are equal.