Skip to main content

Facts

Struct Facts 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for Facts

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Facts

Source§

fn default() -> Facts

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Facts

§

impl RefUnwindSafe for Facts

§

impl Send for Facts

§

impl Sync for Facts

§

impl Unpin for Facts

§

impl UnsafeUnpin for Facts

§

impl UnwindSafe for Facts

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.