Skip to content

Commit a2cd071

Browse files
committed
Move traits::Reveal to traits::types.
1 parent 369f360 commit a2cd071

File tree

3 files changed

+45
-43
lines changed

3 files changed

+45
-43
lines changed

src/librustc/traits/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub use self::object_safety::ObjectSafetyViolation;
5151
pub use self::on_unimplemented::{OnUnimplementedDirective, OnUnimplementedNote};
5252
pub use self::project::MismatchedProjectionTypes;
5353
pub use self::project::{normalize, normalize_projection_type, poly_project_and_unify_type};
54-
pub use self::project::{Normalized, ProjectionCache, ProjectionCacheSnapshot, Reveal};
54+
pub use self::project::{Normalized, ProjectionCache, ProjectionCacheSnapshot};
5555
pub use self::select::{EvaluationCache, SelectionCache, SelectionContext};
5656
pub use self::select::{EvaluationResult, IntercrateAmbiguityCause, OverflowError};
5757
pub use self::specialize::find_associated_item;

src/librustc/traits/project.rs

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,52 +19,11 @@ use crate::ty::subst::{InternalSubsts, Subst};
1919
use crate::ty::{self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, WithConstness};
2020
use rustc_data_structures::snapshot_map::{Snapshot, SnapshotMap};
2121
use rustc_hir::def_id::DefId;
22-
use rustc_macros::HashStable;
2322
use rustc_span::symbol::sym;
2423
use rustc_span::DUMMY_SP;
2524
use syntax::ast::Ident;
2625

27-
/// Depending on the stage of compilation, we want projection to be
28-
/// more or less conservative.
29-
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, HashStable)]
30-
pub enum Reveal {
31-
/// At type-checking time, we refuse to project any associated
32-
/// type that is marked `default`. Non-`default` ("final") types
33-
/// are always projected. This is necessary in general for
34-
/// soundness of specialization. However, we *could* allow
35-
/// projections in fully-monomorphic cases. We choose not to,
36-
/// because we prefer for `default type` to force the type
37-
/// definition to be treated abstractly by any consumers of the
38-
/// impl. Concretely, that means that the following example will
39-
/// fail to compile:
40-
///
41-
/// ```
42-
/// trait Assoc {
43-
/// type Output;
44-
/// }
45-
///
46-
/// impl<T> Assoc for T {
47-
/// default type Output = bool;
48-
/// }
49-
///
50-
/// fn main() {
51-
/// let <() as Assoc>::Output = true;
52-
/// }
53-
UserFacing,
54-
55-
/// At codegen time, all monomorphic projections will succeed.
56-
/// Also, `impl Trait` is normalized to the concrete type,
57-
/// which has to be already collected by type-checking.
58-
///
59-
/// NOTE: as `impl Trait`'s concrete type should *never*
60-
/// be observable directly by the user, `Reveal::All`
61-
/// should not be used by checks which may expose
62-
/// type equality or type contents to the user.
63-
/// There are some exceptions, e.g., around OIBITS and
64-
/// transmute-checking, which expose some details, but
65-
/// not the whole concrete type of the `impl Trait`.
66-
All,
67-
}
26+
pub use rustc::traits::Reveal;
6827

6928
pub type PolyProjectionObligation<'tcx> = Obligation<'tcx, ty::PolyProjectionPredicate<'tcx>>;
7029

src/librustc/traits/types/mod.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,49 @@ pub use self::ObligationCauseCode::*;
1919
pub use self::SelectionError::*;
2020
pub use self::Vtable::*;
2121

22+
/// Depending on the stage of compilation, we want projection to be
23+
/// more or less conservative.
24+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, HashStable)]
25+
pub enum Reveal {
26+
/// At type-checking time, we refuse to project any associated
27+
/// type that is marked `default`. Non-`default` ("final") types
28+
/// are always projected. This is necessary in general for
29+
/// soundness of specialization. However, we *could* allow
30+
/// projections in fully-monomorphic cases. We choose not to,
31+
/// because we prefer for `default type` to force the type
32+
/// definition to be treated abstractly by any consumers of the
33+
/// impl. Concretely, that means that the following example will
34+
/// fail to compile:
35+
///
36+
/// ```
37+
/// trait Assoc {
38+
/// type Output;
39+
/// }
40+
///
41+
/// impl<T> Assoc for T {
42+
/// default type Output = bool;
43+
/// }
44+
///
45+
/// fn main() {
46+
/// let <() as Assoc>::Output = true;
47+
/// }
48+
/// ```
49+
UserFacing,
50+
51+
/// At codegen time, all monomorphic projections will succeed.
52+
/// Also, `impl Trait` is normalized to the concrete type,
53+
/// which has to be already collected by type-checking.
54+
///
55+
/// NOTE: as `impl Trait`'s concrete type should *never*
56+
/// be observable directly by the user, `Reveal::All`
57+
/// should not be used by checks which may expose
58+
/// type equality or type contents to the user.
59+
/// There are some exceptions, e.g., around OIBITS and
60+
/// transmute-checking, which expose some details, but
61+
/// not the whole concrete type of the `impl Trait`.
62+
All,
63+
}
64+
2265
/// The reason why we incurred this obligation; used for error reporting.
2366
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
2467
pub struct ObligationCause<'tcx> {

0 commit comments

Comments
 (0)