Uplift Reveal to rustc_type_ir
This commit is contained in:
parent
f6236f63d2
commit
587173374e
@ -32,54 +32,7 @@ use std::hash::{Hash, Hasher};
|
|||||||
|
|
||||||
pub use self::select::{EvaluationCache, EvaluationResult, OverflowError, SelectionCache};
|
pub use self::select::{EvaluationCache, EvaluationResult, OverflowError, SelectionCache};
|
||||||
// FIXME: Remove this import and import via `solve::`
|
// FIXME: Remove this import and import via `solve::`
|
||||||
pub use rustc_type_ir::solve::BuiltinImplSource;
|
pub use rustc_type_ir::solve::{BuiltinImplSource, Reveal};
|
||||||
|
|
||||||
/// Depending on the stage of compilation, we want projection to be
|
|
||||||
/// more or less conservative.
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, HashStable, Encodable, Decodable)]
|
|
||||||
pub enum Reveal {
|
|
||||||
/// 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:
|
|
||||||
///
|
|
||||||
/// ```compile_fail,E0308
|
|
||||||
/// #![feature(specialization)]
|
|
||||||
/// trait Assoc {
|
|
||||||
/// type Output;
|
|
||||||
/// }
|
|
||||||
///
|
|
||||||
/// impl<T> Assoc for T {
|
|
||||||
/// default type Output = bool;
|
|
||||||
/// }
|
|
||||||
///
|
|
||||||
/// fn main() {
|
|
||||||
/// let x: <() as Assoc>::Output = true;
|
|
||||||
/// }
|
|
||||||
/// ```
|
|
||||||
///
|
|
||||||
/// We also do not reveal the hidden type of opaque types during
|
|
||||||
/// type-checking.
|
|
||||||
UserFacing,
|
|
||||||
|
|
||||||
/// At codegen time, all monomorphic projections will succeed.
|
|
||||||
/// Also, `impl Trait` is normalized to the concrete type,
|
|
||||||
/// which has to be already collected by type-checking.
|
|
||||||
///
|
|
||||||
/// NOTE: as `impl Trait`'s concrete type should *never*
|
|
||||||
/// be observable directly by the user, `Reveal::All`
|
|
||||||
/// should not be used by checks which may expose
|
|
||||||
/// type equality or type contents to the user.
|
|
||||||
/// There are some exceptions, e.g., around auto traits and
|
|
||||||
/// transmute-checking, which expose some details, but
|
|
||||||
/// not the whole concrete type of the `impl Trait`.
|
|
||||||
All,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The reason why we incurred this obligation; used for error reporting.
|
/// The reason why we incurred this obligation; used for error reporting.
|
||||||
///
|
///
|
||||||
|
@ -9,6 +9,54 @@ use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Gen
|
|||||||
|
|
||||||
use crate::{Canonical, CanonicalVarValues, Interner, Upcast};
|
use crate::{Canonical, CanonicalVarValues, Interner, Upcast};
|
||||||
|
|
||||||
|
/// Depending on the stage of compilation, we want projection to be
|
||||||
|
/// more or less conservative.
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||||
|
#[cfg_attr(feature = "nightly", derive(TyDecodable, TyEncodable, HashStable_NoContext))]
|
||||||
|
pub enum Reveal {
|
||||||
|
/// 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:
|
||||||
|
///
|
||||||
|
/// ```compile_fail,E0308
|
||||||
|
/// #![feature(specialization)]
|
||||||
|
/// trait Assoc {
|
||||||
|
/// type Output;
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// impl<T> Assoc for T {
|
||||||
|
/// default type Output = bool;
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// fn main() {
|
||||||
|
/// let x: <() as Assoc>::Output = true;
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// We also do not reveal the hidden type of opaque types during
|
||||||
|
/// type-checking.
|
||||||
|
UserFacing,
|
||||||
|
|
||||||
|
/// At codegen time, all monomorphic projections will succeed.
|
||||||
|
/// Also, `impl Trait` is normalized to the concrete type,
|
||||||
|
/// which has to be already collected by type-checking.
|
||||||
|
///
|
||||||
|
/// NOTE: as `impl Trait`'s concrete type should *never*
|
||||||
|
/// be observable directly by the user, `Reveal::All`
|
||||||
|
/// should not be used by checks which may expose
|
||||||
|
/// type equality or type contents to the user.
|
||||||
|
/// There are some exceptions, e.g., around auto traits and
|
||||||
|
/// transmute-checking, which expose some details, but
|
||||||
|
/// not the whole concrete type of the `impl Trait`.
|
||||||
|
All,
|
||||||
|
}
|
||||||
|
|
||||||
pub type CanonicalInput<I, T = <I as Interner>::Predicate> = Canonical<I, QueryInput<I, T>>;
|
pub type CanonicalInput<I, T = <I as Interner>::Predicate> = Canonical<I, QueryInput<I, T>>;
|
||||||
pub type CanonicalResponse<I> = Canonical<I, Response<I>>;
|
pub type CanonicalResponse<I> = Canonical<I, Response<I>>;
|
||||||
/// The result of evaluating a canonical query.
|
/// The result of evaluating a canonical query.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user