Struct rustc_typeck::bounds::Bounds [−][src]
pub struct Bounds<'tcx> {
pub region_bounds: Vec<(Binder<'tcx, Region<'tcx>>, Span)>,
pub trait_bounds: Vec<(PolyTraitRef<'tcx>, Span, Constness)>,
pub projection_bounds: Vec<(PolyProjectionPredicate<'tcx>, Span)>,
pub implicitly_sized: Option<Span>,
}Expand description
Collects together a list of type bounds. These lists of bounds occur in many places in Rust’s syntax:
trait Foo: Bar + Baz { }
^^^^^^^^^ supertrait list bounding the `Self` type parameter
fn foo<T: Bar + Baz>() { }
^^^^^^^^^ bounding the type parameter `T`
impl dyn Bar + Baz
^^^^^^^^^ bounding the forgotten dynamic type
Our representation is a bit mixed here – in some cases, we
include the self type (e.g., trait_bounds) but in others we do not
Fields
region_bounds: Vec<(Binder<'tcx, Region<'tcx>>, Span)>Expand description
A list of region bounds on the (implicit) self type. So if you
had T: 'a + 'b this might would be a list ['a, 'b] (but
the T is not explicitly included).
trait_bounds: Vec<(PolyTraitRef<'tcx>, Span, Constness)>Expand description
A list of trait bounds. So if you had T: Debug this would be
T: Debug. Note that the self-type is explicit here.
projection_bounds: Vec<(PolyProjectionPredicate<'tcx>, Span)>Expand description
A list of projection equality bounds. So if you had T: Iterator<Item = u32> this would include <T as Iterator>::Item => u32. Note that the self-type is explicit
here.
implicitly_sized: Option<Span>Expand description
Some if there is no ?Sized predicate. The span
is the location in the source of the T declaration which can
be cited as the source of the T: Sized requirement.
Implementations
impl<'tcx> Bounds<'tcx>[src]
impl<'tcx> Bounds<'tcx>[src]pub fn predicates(
&self,
tcx: TyCtxt<'tcx>,
param_ty: Ty<'tcx>
) -> Vec<(Predicate<'tcx>, Span)>[src]
pub fn predicates(
&self,
tcx: TyCtxt<'tcx>,
param_ty: Ty<'tcx>
) -> Vec<(Predicate<'tcx>, Span)>[src]Converts a bounds list into a flat set of predicates (like
where-clauses). Because some of our bounds listings (e.g.,
regions) don’t include the self-type, you must supply the
self-type here (the param_ty parameter).
Trait Implementations
impl<'tcx> Eq for Bounds<'tcx>[src]
impl<'tcx> StructuralEq for Bounds<'tcx>[src]
impl<'tcx> StructuralPartialEq for Bounds<'tcx>[src]
Auto Trait Implementations
impl<'tcx> !RefUnwindSafe for Bounds<'tcx>
impl<'tcx> !Send for Bounds<'tcx>
impl<'tcx> !Sync for Bounds<'tcx>
impl<'tcx> Unpin for Bounds<'tcx>
impl<'tcx> !UnwindSafe for Bounds<'tcx>
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]pub fn borrow_mut(&mut self) -> &mut T[src]
pub fn borrow_mut(&mut self) -> &mut T[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, [src]type Owned = T
type Owned = TThe resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn to_owned(&self) -> T[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)[src]
pub fn clone_into(&self, target: &mut T)[src]🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> WithConstness for T[src]
impl<T> WithConstness for T[src]fn with_constness(self, constness: Constness) -> ConstnessAnd<Self>[src]
fn with_const(self) -> ConstnessAnd<Self>[src]
fn without_const(self) -> ConstnessAnd<Self>[src]
impl<'a, T> Captures<'a> for T where
T: ?Sized, [src]
T: ?Sized,