[−][src]Struct rustc_typeck::bounds::Bounds

pub struct Bounds<'tcx> {
    pub region_bounds: Vec<(Region<'tcx>, Span)>,
    pub trait_bounds: Vec<(PolyTraitRef<'tcx>, Span, Constness)>,
    pub projection_bounds: Vec<(PolyProjectionPredicate<'tcx>, Span)>,
    pub implicitly_sized: Option<Span>,
}

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<(Region<'tcx>, Span)>

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)>

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)>

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>

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]

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> Clone for Bounds<'tcx>[src]

impl<'tcx> Debug for Bounds<'tcx>[src]

impl<'tcx> Default for Bounds<'tcx>[src]

impl<'tcx> Eq for Bounds<'tcx>[src]

impl<'tcx> PartialEq<Bounds<'tcx>> 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> Any for T where
    T: 'static + ?Sized, 
[src]

impl<T> Borrow<T> for T where
    T: ?Sized, 
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized, 
[src]

impl<'a, T> Captures<'a> for T where
    T: ?Sized, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone, 
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> WithConstness for T[src]