Enum rustc::traits::ProjectionMode
[−]
[src]
pub enum ProjectionMode { Topmost, AnyFinal, Any, }
rustc_private
)Depending on the stage of compilation, we want projection to be more or less conservative.
Variants
Topmost
rustc_private
)FIXME (#32205)
At coherence-checking time, we're still constructing the
specialization graph, and thus we only project
non-default
associated types that are defined directly in
the applicable impl. (This behavior should be improved over
time, to allow for successful projections modulo cycles
between different impls).
Here's an example that will fail due to the restriction:
trait Assoc { type Output; } impl<T> Assoc for T { type Output = bool; } impl Assoc for u8 {} // <- inherits the non-default type from above trait Foo {} impl Foo for u32 {} impl Foo for <u8 as Assoc>::Output {} // <- this projection will fail
The projection would succeed if Output
had been defined
directly in the impl for u8
.
AnyFinal
rustc_private
)At type-checking time, we refuse to project any associated
type that is marked default
. Non-default
("final") types
are always projected. This is necessary in general for
soundness of specialization. However, we could allow
projections in fully-monomorphic cases. We choose not to,
because we prefer for default type
to force the type
definition to be treated abstractly by any consumers of the
impl. Concretely, that means that the following example will
fail to compile:
trait Assoc { type Output; } impl<T> Assoc for T { default type Output = bool; } fn main() { let <() as Assoc>::Output = true; }
Any
rustc_private
)At trans time, all projections will succeed.
Methods
impl ProjectionMode
[src]
Trait Implementations
Derived Implementations
impl Eq for ProjectionMode
[src]
impl PartialEq for ProjectionMode
[src]
fn eq(&self, __arg_0: &ProjectionMode) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl Clone for ProjectionMode
[src]
fn clone(&self) -> ProjectionMode
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more