charon_lib::ast::types

Enum TraitRefKind

source
pub enum TraitRefKind {
    TraitImpl(TraitImplId, GenericArgs),
    Clause(TraitClauseId),
    ParentClause(Box<TraitRefKind>, TraitDeclId, TraitClauseId),
    ItemClause(Box<TraitRefKind>, TraitDeclId, TraitItemName, TraitClauseId),
    SelfId,
    BuiltinOrAuto(PolyTraitDeclRef),
    Dyn(PolyTraitDeclRef),
    Unknown(String),
}
Expand description

Identifier of a trait instance. This is derived from the trait resolution.

Should be read as a path inside the trait clauses which apply to the current definition. Note that every path designated by [TraitInstanceId] refers to a trait instance, which is why the [Clause] variant may seem redundant with some of the other variants.

Variants§

§

TraitImpl(TraitImplId, GenericArgs)

A specific top-level implementation item.

§

Clause(TraitClauseId)

One of the local clauses.

Example:

fn f<T>(...) where T : Foo
                   ^^^^^^^
                   Clause(0)
§

ParentClause(Box<TraitRefKind>, TraitDeclId, TraitClauseId)

A parent clause

Remark: the TraitDeclId gives the trait declaration which is implemented by the instance id from which we take the parent clause (see example below). It is not necessary and included for convenience.

Remark: Ideally we should store a full TraitRef instead, but hax does not give us enough information to get the right generic args.

Example:

trait Foo1 {}
trait Foo2 { fn f(); }

trait Bar : Foo1 + Foo2 {}
            ^^^^   ^^^^
                   parent clause 1
    parent clause 0

fn g<T : Bar>(x : T) {
  x.f()
  ^^^^^
  Parent(Clause(0), Bar, 1)::f(x)
                         ^
                         parent clause 1 of clause 0
                    ^^^
             clause 0 implements Bar
}
§

ItemClause(Box<TraitRefKind>, TraitDeclId, TraitItemName, TraitClauseId)

A clause defined on an associated type. This variant is only used during translation; after the lift_associated_item_clauses pass, clauses on items become ParentClauses.

Remark: the TraitDeclId gives the trait declaration which is implemented by the trait implementation from which we take the item (see below). It is not necessary and provided for convenience.

Example:

trait Foo {
  type W: Bar0 + Bar1 // Bar1 contains a method bar1
                 ^^^^
              this is the clause 1 applying to W
}

fn f<T : Foo>(x : T::W) {
  x.bar1();
  ^^^^^^^
  ItemClause(Clause(0), Foo, W, 1)
                             ^^^^
                             clause 1 from item W (from local clause 0)
                        ^^^
               local clause 0 implements Foo
}
§

SelfId

Self, in case of trait declarations/implementations.

Putting Self at the end on purpose, so that when ordering the clauses we start with the other clauses (in particular, the local clauses). It is useful to give priority to the local clauses when solving the trait obligations which are fullfilled by the trait parameters.

§

BuiltinOrAuto(PolyTraitDeclRef)

A specific builtin trait implementation like core::marker::Sized or auto trait implementation like [core::marker::Syn].

§

Dyn(PolyTraitDeclRef)

The automatically-generated implementation for dyn Trait.

§

Unknown(String)

For error reporting.

Trait Implementations§

source§

impl Clone for TraitRefKind

source§

fn clone(&self) -> TraitRefKind

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for TraitRefKind

source§

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

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

impl<'de> Deserialize<'de> for TraitRefKind

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Drive for TraitRefKind

source§

fn drive<V: Visitor>(&self, visitor: &mut V)

source§

impl DriveMut for TraitRefKind

source§

fn drive_mut<V: VisitorMut>(&mut self, visitor: &mut V)

source§

impl<C: AstFormatter> FmtWithCtx<C> for TraitRefKind

source§

fn fmt_with_ctx(&self, ctx: &C) -> String

source§

fn fmt_with_ctx_and_indent(&self, _tab: &str, _ctx: &C) -> String

source§

fn with_ctx<'a>(&'a self, ctx: &'a C) -> impl Display + 'a

Returns a struct that implements Display. This allows the following: Read more
source§

impl Hash for TraitRefKind

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for TraitRefKind

source§

fn eq(&self, other: &TraitRefKind) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for TraitRefKind

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for TraitRefKind

source§

impl StructuralPartialEq for TraitRefKind

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

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
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<I, T> ExtractContext<I, ()> for T

§

fn extract_context(self, _original_input: I)

Given the context attached to a nom error, and given the original input to the nom parser, extract more the useful context information. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<I> RecreateContext<I> for I

§

fn recreate_context(_original_input: I, tail: I) -> I

Given the original input, as well as the context reported by nom, recreate a context in the original string where the error occurred. Read more
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,