Skip to content

Commit a409b98

Browse files
committed
Move ty::AliasRelationDirection to its own little module (cute)
1 parent 79f92ae commit a409b98

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use std::fmt;
2+
3+
#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
4+
#[derive(HashStable, Debug)]
5+
pub enum AliasRelationDirection {
6+
Equate,
7+
Subtype,
8+
}
9+
10+
impl fmt::Display for AliasRelationDirection {
11+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
12+
match self {
13+
AliasRelationDirection::Equate => write!(f, "=="),
14+
AliasRelationDirection::Subtype => write!(f, "<:"),
15+
}
16+
}
17+
}

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ mod structural_impls;
141141
mod sty;
142142
mod typeck_results;
143143

144+
mod alias_relation_direction;
144145
mod bound_constness;
145146
mod impl_polarity;
146147
mod param_env;
@@ -149,6 +150,7 @@ mod term;
149150
mod ty_; // FIXME: rename to `ty` once we don't import `crate::ty` here
150151
mod visibility;
151152

153+
pub use alias_relation_direction::AliasRelationDirection;
152154
pub use bound_constness::BoundConstness;
153155
pub use impl_polarity::ImplPolarity;
154156
pub use param_env::{ParamEnv, ParamEnvAnd};
@@ -361,22 +363,6 @@ pub enum Clause<'tcx> {
361363
ConstArgHasType(Const<'tcx>, Ty<'tcx>),
362364
}
363365

364-
#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
365-
#[derive(HashStable, Debug)]
366-
pub enum AliasRelationDirection {
367-
Equate,
368-
Subtype,
369-
}
370-
371-
impl std::fmt::Display for AliasRelationDirection {
372-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
373-
match self {
374-
AliasRelationDirection::Equate => write!(f, "=="),
375-
AliasRelationDirection::Subtype => write!(f, "<:"),
376-
}
377-
}
378-
}
379-
380366
/// The crate outlives map is computed during typeck and contains the
381367
/// outlives of every item in the local crate. You should not use it
382368
/// directly, because to do so will make your pass dependent on the

0 commit comments

Comments
 (0)