struct Generalization<T> {
pub value_may_be_infer: T,
pub has_unconstrained_ty_var: bool,
}
Expand description
Result from a generalization operation. This includes not only the generalized type, but also a bool flag indicating whether further WF checks are needed.
Fields§
§value_may_be_infer: T
When generalizing <?0 as Trait>::Assoc
or
<T as Bar<<?0 as Foo>::Assoc>>::Assoc
for ?0
generalization returns an inference
variable.
This has to be handled wotj care as it can otherwise very easily result in infinite recursion.
has_unconstrained_ty_var: bool
In general, we do not check whether all types which occur during type checking are well-formed. We only check wf of user-provided types and when actually using a type, e.g. for method calls.
This means that when subtyping, we may end up with unconstrained inference variables if a generalized type has bivariant parameters. A parameter may only be bivariant if it is constrained by a projection bound in a where-clause. As an example, imagine a type:
struct Foo<A, B> where A: Iterator<Item = B> {
data: A
}
here, A
will be covariant, but B
is unconstrained.
However, whatever it is, for Foo
to be WF, it must be equal to A::Item
.
If we have an input Foo<?A, ?B>
, then after generalization we will wind
up with a type like Foo<?C, ?D>
. When we enforce Foo<?A, ?B> <: Foo<?C, ?D>
,
we will wind up with the requirement that ?A <: ?C
, but no particular
relationship between ?B
and ?D
(after all, these types may be completely
different). If we do nothing else, this may mean that ?D
goes unconstrained
(as in #41677). To avoid this we emit a WellFormed
obligation in these cases.
Trait Implementations§
Auto Trait Implementations§
impl<T> DynSend for Generalization<T>where
T: DynSend,
impl<T> DynSync for Generalization<T>where
T: DynSync,
impl<T> Freeze for Generalization<T>where
T: Freeze,
impl<T> RefUnwindSafe for Generalization<T>where
T: RefUnwindSafe,
impl<T> Send for Generalization<T>where
T: Send,
impl<T> Sync for Generalization<T>where
T: Sync,
impl<T> Unpin for Generalization<T>where
T: Unpin,
impl<T> UnwindSafe for Generalization<T>where
T: UnwindSafe,
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
§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<P> IntoQueryParam<P> for P
impl<P> IntoQueryParam<P> for P
fn into_query_param(self) -> P
Source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
§impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
§impl<I, T> UpcastFrom<I, T> for T
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
Source§impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.