Struct hax_frontend_exporter::types::mir_traits::ParamsInfo
source · pub struct ParamsInfo {
pub num_generic_params: usize,
pub num_region_params: usize,
pub num_type_params: usize,
pub num_const_generic_params: usize,
pub num_trait_clauses: usize,
pub num_regions_outlive: usize,
pub num_types_outlive: usize,
pub num_trait_type_constraints: usize,
}
Expand description
We use this to store information about the parameters in parent blocks. This is necessary because when querying the generics of a definition, rustc gives us all the generics used in this definition, including those coming from the outer impl block.
For instance:
impl Foo<T> {
^^^
outer block generics
fn bar<U>(...) { ... }
^^^
generics local to the function bar
}
TyCtxt.generics_of(bar)
gives us: [T, U]
.
We however sometimes need to make a distinction between those two kinds of generics, in particular when manipulating trait instances. For instance:
impl<T> Foo for Bar<T> {
fn baz<U>(...) { ... }
}
fn test(...) {
// Here:
x.baz(...);
// We should refer to this call as:
// > Foo<T>::baz<U>(...)
//
// If baz hadn't been a method implementation of a trait,
// we would have refered to it as:
// > baz<T, U>(...)
//
// The reason is that with traits, we refer to the whole
// trait implementation (as if it were a structure), then
// pick a specific method inside (as if projecting a field
// from a structure).
}
Remark: Rust only allows refering to the generics of the immediately outer block. For this reason, when we need to store the information about the generics of the outer block(s), we need to do it only for one level (this definitely makes things simpler). Additional remark: it is not possible to directly write an impl block or a trait definition inside an impl/trait block. However it is possible to define an impl/trait inside a function, which can itself be inside a block, leading to nested impl blocks.
Fields§
§num_generic_params: usize
The total number of generic parameters (regions + types + consts). We do not consider the trait clauses as generic parameters.
num_region_params: usize
§num_type_params: usize
§num_const_generic_params: usize
§num_trait_clauses: usize
§num_regions_outlive: usize
§num_types_outlive: usize
§num_trait_type_constraints: usize
Trait Implementations§
source§impl<'__de> BorrowDecode<'__de> for ParamsInfo
impl<'__de> BorrowDecode<'__de> for ParamsInfo
source§fn borrow_decode<__D: BorrowDecoder<'__de>>(
decoder: &mut __D,
) -> Result<Self, DecodeError>
fn borrow_decode<__D: BorrowDecoder<'__de>>( decoder: &mut __D, ) -> Result<Self, DecodeError>
source§impl Clone for ParamsInfo
impl Clone for ParamsInfo
source§fn clone(&self) -> ParamsInfo
fn clone(&self) -> ParamsInfo
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ParamsInfo
impl Debug for ParamsInfo
source§impl Decode for ParamsInfo
impl Decode for ParamsInfo
source§impl<'de> Deserialize<'de> for ParamsInfo
impl<'de> Deserialize<'de> for ParamsInfo
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 Encode for ParamsInfo
impl Encode for ParamsInfo
source§impl JsonSchema for ParamsInfo
impl JsonSchema for ParamsInfo
source§fn schema_name() -> String
fn schema_name() -> String
source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moreAuto Trait Implementations§
impl Freeze for ParamsInfo
impl RefUnwindSafe for ParamsInfo
impl Send for ParamsInfo
impl Sync for ParamsInfo
impl Unpin for ParamsInfo
impl UnwindSafe for ParamsInfo
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)