pub struct GenericParams {
pub regions: Vector<RegionId, RegionVar>,
pub types: Vector<TypeVarId, TypeVar>,
pub const_generics: Vector<ConstGenericVarId, ConstGenericVar>,
pub trait_clauses: Vector<TraitClauseId, TraitClause>,
pub regions_outlive: Vec<RegionBinder<RegionOutlives>>,
pub types_outlive: Vec<RegionBinder<TypeOutlives>>,
pub trait_type_constraints: Vec<RegionBinder<TraitTypeConstraint>>,
}
Expand description
Generic parameters for a declaration. We group the generics which come from the Rust compiler substitutions (the regions, types and const generics) as well as the trait clauses. The reason is that we consider that those are parameters that need to be filled. We group in a different place the predicates which are not trait clauses, because those enforce constraints but do not need to be filled with witnesses/instances.
Fields§
§regions: Vector<RegionId, RegionVar>
§types: Vector<TypeVarId, TypeVar>
§const_generics: Vector<ConstGenericVarId, ConstGenericVar>
§trait_clauses: Vector<TraitClauseId, TraitClause>
§regions_outlive: Vec<RegionBinder<RegionOutlives>>
The first region in the pair outlives the second region
types_outlive: Vec<RegionBinder<TypeOutlives>>
The type outlives the region
trait_type_constraints: Vec<RegionBinder<TraitTypeConstraint>>
Constraints over trait associated types
Implementations§
source§impl GenericParams
impl GenericParams
pub fn empty() -> Self
pub fn is_empty(&self) -> bool
pub fn has_predicates(&self) -> bool
sourcepub fn check_consistency(&self)
pub fn check_consistency(&self)
Run some sanity checks.
pub fn len(&self) -> usize
sourcepub fn identity_args(&self, target: GenericsSource) -> GenericArgs
pub fn identity_args(&self, target: GenericsSource) -> GenericArgs
Construct a set of generic arguments in the scope of self
that matches self
and feeds
each required parameter with itself. E.g. given parameters for <T, U> where U: PartialEq<T>
, the arguments would be <T, U>[@TraitClause0]
.
sourcepub fn identity_args_at_depth(
&self,
target: GenericsSource,
depth: DeBruijnId,
) -> GenericArgs
pub fn identity_args_at_depth( &self, target: GenericsSource, depth: DeBruijnId, ) -> GenericArgs
Like identity_args
but uses variables bound at the given depth.
source§impl GenericParams
impl GenericParams
fn format_params<'a, C>(
&'a self,
ctx: &'a C,
) -> impl Iterator<Item = String> + use<'a, C>where
C: AstFormatter,
fn format_clauses<'a, C>(
&'a self,
ctx: &'a C,
) -> impl Iterator<Item = String> + use<'a, C>where
C: AstFormatter,
pub fn fmt_with_ctx_with_trait_clauses<C>(
&self,
ctx: &C,
tab: &str,
) -> (String, String)where
C: AstFormatter,
pub fn fmt_with_ctx_single_line<C>(&self, ctx: &C) -> Stringwhere
C: AstFormatter,
Trait Implementations§
source§impl AstVisitable for GenericParams
impl AstVisitable for GenericParams
source§fn drive<V: VisitAst>(&self, v: &mut V) -> ControlFlow<V::Break>
fn drive<V: VisitAst>(&self, v: &mut V) -> ControlFlow<V::Break>
visit_$any
method if it exists, otherwise visit_inner
.source§fn drive_mut<V: VisitAstMut>(&mut self, v: &mut V) -> ControlFlow<V::Break>
fn drive_mut<V: VisitAstMut>(&mut self, v: &mut V) -> ControlFlow<V::Break>
visit_$any
method if it exists, otherwise visit_inner
.source§fn dyn_visit<T: AstVisitable>(&self, f: impl FnMut(&T))
fn dyn_visit<T: AstVisitable>(&self, f: impl FnMut(&T))
self
, in pre-order traversal.source§fn dyn_visit_mut<T: AstVisitable>(&mut self, f: impl FnMut(&mut T))
fn dyn_visit_mut<T: AstVisitable>(&mut self, f: impl FnMut(&mut T))
self
, in pre-order traversal.source§impl Clone for GenericParams
impl Clone for GenericParams
source§fn clone(&self) -> GenericParams
fn clone(&self) -> GenericParams
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for GenericParams
impl Debug for GenericParams
source§impl Default for GenericParams
impl Default for GenericParams
source§fn default() -> GenericParams
fn default() -> GenericParams
source§impl<'de> Deserialize<'de> for GenericParams
impl<'de> Deserialize<'de> for GenericParams
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Display for GenericParams
impl Display for GenericParams
source§impl<'s, V> Drive<'s, V> for GenericParamswhere
V: Visitor + Visit<'s, Vector<RegionId, RegionVar>> + Visit<'s, Vector<TypeVarId, TypeVar>> + Visit<'s, Vector<ConstGenericVarId, ConstGenericVar>> + Visit<'s, Vector<TraitClauseId, TraitClause>> + Visit<'s, Vec<RegionBinder<RegionOutlives>>> + Visit<'s, Vec<RegionBinder<TypeOutlives>>> + Visit<'s, Vec<RegionBinder<TraitTypeConstraint>>>,
impl<'s, V> Drive<'s, V> for GenericParamswhere
V: Visitor + Visit<'s, Vector<RegionId, RegionVar>> + Visit<'s, Vector<TypeVarId, TypeVar>> + Visit<'s, Vector<ConstGenericVarId, ConstGenericVar>> + Visit<'s, Vector<TraitClauseId, TraitClause>> + Visit<'s, Vec<RegionBinder<RegionOutlives>>> + Visit<'s, Vec<RegionBinder<TypeOutlives>>> + Visit<'s, Vec<RegionBinder<TraitTypeConstraint>>>,
source§fn drive_inner(&'s self, visitor: &mut V) -> ControlFlow<V::Break>
fn drive_inner(&'s self, visitor: &mut V) -> ControlFlow<V::Break>
v.visit()
on the immediate contents of self
.source§impl<'s, V> DriveMut<'s, V> for GenericParamswhere
V: Visitor + VisitMut<'s, Vector<RegionId, RegionVar>> + VisitMut<'s, Vector<TypeVarId, TypeVar>> + VisitMut<'s, Vector<ConstGenericVarId, ConstGenericVar>> + VisitMut<'s, Vector<TraitClauseId, TraitClause>> + VisitMut<'s, Vec<RegionBinder<RegionOutlives>>> + VisitMut<'s, Vec<RegionBinder<TypeOutlives>>> + VisitMut<'s, Vec<RegionBinder<TraitTypeConstraint>>>,
impl<'s, V> DriveMut<'s, V> for GenericParamswhere
V: Visitor + VisitMut<'s, Vector<RegionId, RegionVar>> + VisitMut<'s, Vector<TypeVarId, TypeVar>> + VisitMut<'s, Vector<ConstGenericVarId, ConstGenericVar>> + VisitMut<'s, Vector<TraitClauseId, TraitClause>> + VisitMut<'s, Vec<RegionBinder<RegionOutlives>>> + VisitMut<'s, Vec<RegionBinder<TypeOutlives>>> + VisitMut<'s, Vec<RegionBinder<TraitTypeConstraint>>>,
source§fn drive_inner_mut(&'s mut self, visitor: &mut V) -> ControlFlow<V::Break>
fn drive_inner_mut(&'s mut self, visitor: &mut V) -> ControlFlow<V::Break>
v.visit()
on the immediate contents of self
.source§impl Hash for GenericParams
impl Hash for GenericParams
source§impl Index<ConstGenericVarId> for GenericParams
impl Index<ConstGenericVarId> for GenericParams
source§type Output = ConstGenericVar
type Output = ConstGenericVar
source§impl Index<RegionId> for GenericParams
impl Index<RegionId> for GenericParams
source§impl Index<TraitClauseId> for GenericParams
impl Index<TraitClauseId> for GenericParams
source§type Output = TraitClause
type Output = TraitClause
source§impl Index<TypeVarId> for GenericParams
impl Index<TypeVarId> for GenericParams
source§impl IndexMut<ConstGenericVarId> for GenericParams
impl IndexMut<ConstGenericVarId> for GenericParams
source§impl IndexMut<RegionId> for GenericParams
impl IndexMut<RegionId> for GenericParams
source§impl IndexMut<TraitClauseId> for GenericParams
impl IndexMut<TraitClauseId> for GenericParams
source§impl IndexMut<TypeVarId> for GenericParams
impl IndexMut<TypeVarId> for GenericParams
source§impl PartialEq for GenericParams
impl PartialEq for GenericParams
source§impl Serialize for GenericParams
impl Serialize for GenericParams
impl Eq for GenericParams
impl StructuralPartialEq for GenericParams
Auto Trait Implementations§
impl Freeze for GenericParams
impl RefUnwindSafe for GenericParams
impl Send for GenericParams
impl Sync for GenericParams
impl Unpin for GenericParams
impl UnwindSafe for GenericParams
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§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
§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
§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
key
and return true
if they are equal.§impl<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
§fn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
§impl<T> Indentable for Twhere
T: Display,
impl<T> Indentable for Twhere
T: Display,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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
impl<I> RecreateContext<I> for I
§fn recreate_context(_original_input: I, tail: I) -> I
fn recreate_context(_original_input: I, tail: I) -> I
source§impl<T> TyVisitable for Twhere
T: AstVisitable,
impl<T> TyVisitable for Twhere
T: AstVisitable,
fn substitute(&mut self, generics: &GenericArgs)
source§fn move_under_binder(self) -> Self
fn move_under_binder(self) -> Self
source§fn move_under_binders(self, depth: DeBruijnId) -> Self
fn move_under_binders(self, depth: DeBruijnId) -> Self
depth
binders.source§fn move_from_under_binders(self, depth: DeBruijnId) -> Option<Self>
fn move_from_under_binders(self, depth: DeBruijnId) -> Option<Self>
depth
binders. Returns None
if it contains a variable bound in
one of these depth
binders.source§fn visit_db_id<B>(
&mut self,
f: impl FnMut(&mut DeBruijnId) -> ControlFlow<B>,
) -> ControlFlow<B>
fn visit_db_id<B>( &mut self, f: impl FnMut(&mut DeBruijnId) -> ControlFlow<B>, ) -> ControlFlow<B>
self
, as seen from the outside of self
. This means
that any variable bound inside self
will be skipped, and all the seen indices will count
from the outside of self.