struct Generalization<'tcx> {
ty: Ty<'tcx>,
needs_wf: bool,
}
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Result from a generalization operation. This includes
not only the generalized type, but also a bool flag
indicating whether further WF checks are needed.
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
If true, then the generalized type may not be well-formed,
even if the source type is well-formed, so we should add an
additional check to enforce that it is. This arises in
particular around 'bivariant' type parameters that are only
constrained by 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 that Foo<?A, ?B> <: Foo<?C, ?D>
(or >:
), we will wind up with the requirement that ?A <: ?C
, but no particular relationship between ?B
and ?D
(after all, we do not know the variance of the normalized form
of A::Item
with respect to A
). If we do nothing else, this
may mean that ?D
goes unconstrained (as in #41677). So, in
this scenario where we create a new type variable in a
bivariant context, we set the needs_wf
flag to true. This
will force the calling code to check that WF(Foo<?C, ?D>)
holds, which in turn implies that ?C::Item == ?D
. So once
?C
is constrained, that should suffice to restrict ?D
.
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Create an error for a missing method specialization. Defaults to panicking with type, trait & method names. S
is the encoder/decoder state type, T
is the type being encoded/decoded, and the arguments are the names of the trait and method that should've been overridden. Read more