Enum ra_ap_hir_ty::Ty [−][src]
A type.
See also the TyKind
enum in rustc (librustc/ty/sty.rs), which represents
the same thing (but in a different way).
This should be cheap to clone.
Variants
Structures, enumerations and unions.
AssociatedType(TypeAliasId, Substs)
Represents an associated item like Iterator::Item
. This is used
when we have tried to normalize a projection like T::Item
but
couldn’t find a better representation. In that case, we generate
an application type like (Iterator::Item)<T>
.
Scalar(Scalar)
a scalar type like bool
or u32
A tuple type. For example, (i32, bool)
.
Array(Substs)
An array with the given length. Written as [T; n]
.
Slice(Substs)
The pointee of an array slice. Written as [T]
.
Raw(Mutability, Substs)
A raw pointer. Written as *mut T
or *const T
Ref(Mutability, Substs)
A reference; a pointer with an associated lifetime. Written as
&'a mut T
or &'a T
.
OpaqueType(OpaqueTyId, Substs)
This represents a placeholder for an opaque type in situations where we
don’t know the hidden type (i.e. currently almost always). This is
analogous to the AssociatedType
type constructor.
It is also used as the type of async block, with one type parameter
representing the Future::Output type.
FnDef(CallableDefId, Substs)
The anonymous type of a function declaration/definition. Each
function has a unique type, which is output (for a function
named foo
returning an i32
) as fn() -> i32 {foo}
.
This includes tuple struct / enum variant constructors as well.
For example the type of bar
here:
fn foo() -> i32 { 1 } let bar = foo; // bar: fn() -> i32 {foo}
The pointee of a string slice. Written as str
.
The never type !
.
Closure(DefWithBodyId, ExprId, Substs)
The type of a specific closure.
The closure signature is stored in a FnPtr
type in the first type
parameter.
ForeignType(TypeAliasId)
Represents a foreign type declared in external blocks.
Function(FnPointer)
A pointer to a function. Written as fn() -> i32
.
For example the type of bar
here:
fn foo() -> i32 { 1 } let bar: fn() -> i32 = foo;
Alias(AliasTy)
An “alias” type represents some form of type alias, such as:
- An associated type projection like
<T as Iterator>::Item
impl Trait
types- Named type aliases like
type Foo<X> = Vec<X>
Placeholder(TypeParamId)
A placeholder for a type parameter; for example, T
in fn f<T>(x: T) {}
when we’re type-checking the body of that function. In this
situation, we know this stands for some type, but don’t know the exact
type.
BoundVar(BoundVar)
A bound type variable. This is used in various places: when representing
some polymorphic type like the type of function fn f<T>
, the type
parameters get turned into variables; during trait resolution, inference
variables get turned into bound variables and back; and in Dyn
the
Self
type is represented with a bound variable as well.
InferenceVar(InferenceVar, TyVariableKind)
A type variable used during type checking.
Dyn(Arc<[GenericPredicate]>)
A trait object (dyn Trait
or bare Trait
in pre-2018 Rust).
The predicates are quantified over the Self
type, i.e. Ty::Bound(0)
represents the Self
type inside the bounds. This is currently
implicit; Chalk has the Binders
struct to make it explicit, but it
didn’t seem worth the overhead yet.
A placeholder for a type which could not be computed; this is propagated to avoid useless error messages. Doubles as a placeholder where type variables are inserted before type checking, since we want to try to infer a better type here anyway – for the IDE use case, we want to try to infer as much as possible even in the presence of type errors.
Implementations
impl Ty
[src]
pub fn def_crates(
&self,
db: &dyn HirDatabase,
cur_crate: CrateId
) -> Option<ArrayVec<[CrateId; 2]>>
[src]
&self,
db: &dyn HirDatabase,
cur_crate: CrateId
) -> Option<ArrayVec<[CrateId; 2]>>
impl Ty
[src]
pub fn from_hir(ctx: &TyLoweringContext<'_>, type_ref: &TypeRef) -> Self
[src]
pub fn from_hir_ext(
ctx: &TyLoweringContext<'_>,
type_ref: &TypeRef
) -> (Self, Option<TypeNs>)
[src]
ctx: &TyLoweringContext<'_>,
type_ref: &TypeRef
) -> (Self, Option<TypeNs>)
impl Ty
[src]
pub fn unit() -> Self
[src]
pub fn adt_ty(adt: AdtId, substs: Substs) -> Ty
[src]
pub fn fn_ptr(sig: CallableSig) -> Self
[src]
pub fn builtin(builtin: BuiltinType) -> Self
[src]
pub fn as_reference(&self) -> Option<(&Ty, Mutability)>
[src]
pub fn as_reference_or_ptr(&self) -> Option<(&Ty, Rawness, Mutability)>
[src]
pub fn strip_references(&self) -> &Ty
[src]
pub fn as_adt(&self) -> Option<(AdtId, &Substs)>
[src]
pub fn as_tuple(&self) -> Option<&Substs>
[src]
pub fn as_generic_def(&self) -> Option<GenericDefId>
[src]
pub fn is_never(&self) -> bool
[src]
pub fn is_unknown(&self) -> bool
[src]
pub fn equals_ctor(&self, other: &Ty) -> bool
[src]
pub fn dyn_trait_ref(&self) -> Option<&TraitRef>
[src]
If this is a dyn Trait
type, this returns the Trait
part.
pub fn dyn_trait(&self) -> Option<TraitId>
[src]
If this is a dyn Trait
, returns that trait.
pub fn as_fn_def(&self) -> Option<FunctionId>
[src]
pub fn callable_sig(&self, db: &dyn HirDatabase) -> Option<CallableSig>
[src]
pub fn apply_substs(self, new_substs: Substs) -> Ty
[src]
If this is a type with type parameters (an ADT or function), replaces
the Substs
for these type parameters with the given ones. (So e.g. if
self
is Option<_>
and the substs contain u32
, we’ll have
Option<u32>
afterwards.)
pub fn substs(&self) -> Option<&Substs>
[src]
Returns the type parameters of this type if it has some (i.e. is an ADT
or function); so if self
is Option<u32>
, this returns the u32
.
pub fn substs_mut(&mut self) -> Option<&mut Substs>
[src]
pub fn impl_trait_bounds(
&self,
db: &dyn HirDatabase
) -> Option<Vec<GenericPredicate>>
[src]
&self,
db: &dyn HirDatabase
) -> Option<Vec<GenericPredicate>>
pub fn associated_type_parent_trait(
&self,
db: &dyn HirDatabase
) -> Option<TraitId>
[src]
&self,
db: &dyn HirDatabase
) -> Option<TraitId>
Trait Implementations
impl Clone for Ty
[src]
impl Debug for Ty
[src]
impl Eq for Ty
[src]
impl Hash for Ty
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl HirDisplay for &Ty
[src]
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError>
[src]
fn into_displayable<'a>(
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>,
omit_verbose_types: bool,
display_target: DisplayTarget
) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
[src]
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>,
omit_verbose_types: bool,
display_target: DisplayTarget
) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
fn display<'a>(&'a self, db: &'a dyn HirDatabase) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
[src]
Self: Sized,
fn display_truncated<'a>(
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>
) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
[src]
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>
) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
fn display_source_code<'a>(
&'a self,
db: &'a dyn HirDatabase,
module_id: ModuleId
) -> Result<String, DisplaySourceCodeError>
[src]
&'a self,
db: &'a dyn HirDatabase,
module_id: ModuleId
) -> Result<String, DisplaySourceCodeError>
fn display_test<'a>(
&'a self,
db: &'a dyn HirDatabase
) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
[src]
&'a self,
db: &'a dyn HirDatabase
) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
impl HirDisplay for Ty
[src]
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError>
[src]
fn into_displayable<'a>(
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>,
omit_verbose_types: bool,
display_target: DisplayTarget
) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
[src]
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>,
omit_verbose_types: bool,
display_target: DisplayTarget
) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
fn display<'a>(&'a self, db: &'a dyn HirDatabase) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
[src]
Self: Sized,
fn display_truncated<'a>(
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>
) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
[src]
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>
) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
fn display_source_code<'a>(
&'a self,
db: &'a dyn HirDatabase,
module_id: ModuleId
) -> Result<String, DisplaySourceCodeError>
[src]
&'a self,
db: &'a dyn HirDatabase,
module_id: ModuleId
) -> Result<String, DisplaySourceCodeError>
fn display_test<'a>(
&'a self,
db: &'a dyn HirDatabase
) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
[src]
&'a self,
db: &'a dyn HirDatabase
) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
impl PartialEq<Ty> for Ty
[src]
impl StructuralEq for Ty
[src]
impl StructuralPartialEq for Ty
[src]
impl TypeWalk for Ty
[src]
fn walk(&self, f: &mut impl FnMut(&Ty))
[src]
fn walk_mut_binders(
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)
[src]
&mut self,
f: &mut impl FnMut(&mut Ty, DebruijnIndex),
binders: DebruijnIndex
)
fn walk_mut(&mut self, f: &mut impl FnMut(&mut Ty))
[src]
fn fold_binders(
self,
f: &mut impl FnMut(Ty, DebruijnIndex) -> Ty,
binders: DebruijnIndex
) -> Self where
Self: Sized,
[src]
self,
f: &mut impl FnMut(Ty, DebruijnIndex) -> Ty,
binders: DebruijnIndex
) -> Self where
Self: Sized,
fn fold(self, f: &mut impl FnMut(Ty) -> Ty) -> Self where
Self: Sized,
[src]
Self: Sized,
fn subst_bound_vars(self, substs: &Substs) -> Self where
Self: Sized,
[src]
Self: Sized,
fn subst_bound_vars_at_depth(
self,
substs: &Substs,
depth: DebruijnIndex
) -> Self where
Self: Sized,
[src]
self,
substs: &Substs,
depth: DebruijnIndex
) -> Self where
Self: Sized,
fn shift_bound_vars(self, n: DebruijnIndex) -> Self where
Self: Sized,
[src]
Self: Sized,
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
T: Any,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Cast for T
[src]
pub fn cast<U>(self, interner: &<U as HasInterner>::Interner) -> U where
Self: CastTo<U>,
U: HasInterner,
[src]
Self: CastTo<U>,
U: HasInterner,
impl<T> CloneAny for T where
T: Clone + Any,
T: Clone + Any,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,