pub struct Facts { /* private fields */ }Expand description
What the checker worked out about each expression.
One of these covers a whole package: every file the checker walked,
within each file every expression it settled something about, and the
boundary of every declaration it resolved. It is published on
Program, which is what a consumer of a
checked package already holds.
Implementations§
Source§impl Facts
impl Facts
Sourcepub fn ty(&self, file: FileId, id: ExprId) -> Option<&Ty>
pub fn ty(&self, file: FileId, id: ExprId) -> Option<&Ty>
The type of the expression, if the checker settled one.
None means this expression was never walked — a body the checker
stopped before reaching, or a tree that was never part of a checked
package. It never means the checker was unsure: see the module docs.
Sourcepub fn target(&self, file: FileId, id: ExprId) -> Option<&MethodTarget>
pub fn target(&self, file: FileId, id: ExprId) -> Option<&MethodTarget>
The declaration this call resolved to, if it resolved to one.
Only a call the checker matched against a declaration written in an
impl block answers here. A call to a builtin method, to a host
operation, or through a trait bound answers None, because none of
those names a declaration of this package.
Sourcepub fn signature(&self, file: FileId, decl: Span) -> Option<&Signature>
pub fn signature(&self, file: FileId, decl: Span) -> Option<&Signature>
The boundary of the declaration written at decl, if the checker
resolved one.
decl is the FnDecl’s own span, which is what a consumer holding a
declaration already has and what makes the key need no side channel:
the checker records against the same span, so a declaration found in
the tree and the fact recorded about it meet without either naming
the other.
decl is a fn declaration’s span, a struct declaration’s, or one
enum case’s — see Signature for what each records.
None means the checker never resolved this declaration — a body it
stopped before reaching, or a tree that was never part of a checked
package. As everywhere else here, it does not mean the checker was
unsure: a parameter it could say nothing about is recorded as
Ty::Unknown, which is an answer.
Sourcepub fn types(&self) -> impl Iterator<Item = (FileId, ExprId, &Ty)>
pub fn types(&self) -> impl Iterator<Item = (FileId, ExprId, &Ty)>
Every expression the checker settled a type for, in file and then expression order.
The tables are indexed rather than keyed, so a reader that wants every answer rather than one has no key to ask with. This is that reader’s way in, and it exists for one: the invariant that a package which checked without error carries no unresolved type. Asking that question of one expression at a time would need the question to know which expressions there are, which is exactly what only this table knows.