Struct rustc_hir_analysis::bounds::Bounds
source · pub struct Bounds<'tcx> {
pub region_bounds: Vec<(Binder<'tcx, Region<'tcx>>, Span)>,
pub trait_bounds: Vec<(PolyTraitRef<'tcx>, Span, BoundConstness)>,
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)>
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, BoundConstness)>
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§
source§impl<'tcx> Bounds<'tcx>
impl<'tcx> Bounds<'tcx>
sourcepub fn predicates<'out, 's>(
&'s self,
tcx: TyCtxt<'tcx>,
param_ty: Ty<'tcx>
) -> impl Iterator<Item = (Predicate<'tcx>, Span)> + 'outwhere
'tcx: 'out,
's: 'out,
pub fn predicates<'out, 's>(
&'s self,
tcx: TyCtxt<'tcx>,
param_ty: Ty<'tcx>
) -> impl Iterator<Item = (Predicate<'tcx>, Span)> + 'outwhere
'tcx: 'out,
's: 'out,
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§
source§impl<'tcx> PartialEq<Bounds<'tcx>> for Bounds<'tcx>
impl<'tcx> PartialEq<Bounds<'tcx>> for Bounds<'tcx>
impl<'tcx> Eq for Bounds<'tcx>
impl<'tcx> StructuralEq for Bounds<'tcx>
impl<'tcx> StructuralPartialEq for Bounds<'tcx>
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§
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 88 bytes