@@ -31,12 +31,9 @@ use crate::session_diagnostics::{
31
31
HigherRankedErrorCause , HigherRankedLifetimeError , HigherRankedSubtypeError ,
32
32
} ;
33
33
34
- #[ derive( Clone ) ]
35
- pub ( crate ) struct UniverseInfo < ' tcx > ( UniverseInfoInner < ' tcx > ) ;
36
-
37
34
/// What operation a universe was created for.
38
35
#[ derive( Clone ) ]
39
- enum UniverseInfoInner < ' tcx > {
36
+ pub ( crate ) enum UniverseInfo < ' tcx > {
40
37
/// Relating two types which have binders.
41
38
RelateTys { expected : Ty < ' tcx > , found : Ty < ' tcx > } ,
42
39
/// Created from performing a `TypeOp`.
@@ -47,11 +44,11 @@ enum UniverseInfoInner<'tcx> {
47
44
48
45
impl < ' tcx > UniverseInfo < ' tcx > {
49
46
pub ( crate ) fn other ( ) -> UniverseInfo < ' tcx > {
50
- UniverseInfo ( UniverseInfoInner :: Other )
47
+ UniverseInfo :: Other
51
48
}
52
49
53
50
pub ( crate ) fn relate ( expected : Ty < ' tcx > , found : Ty < ' tcx > ) -> UniverseInfo < ' tcx > {
54
- UniverseInfo ( UniverseInfoInner :: RelateTys { expected, found } )
51
+ UniverseInfo :: RelateTys { expected, found }
55
52
}
56
53
57
54
pub ( crate ) fn report_error (
@@ -61,8 +58,8 @@ impl<'tcx> UniverseInfo<'tcx> {
61
58
error_element : RegionElement ,
62
59
cause : ObligationCause < ' tcx > ,
63
60
) {
64
- match self . 0 {
65
- UniverseInfoInner :: RelateTys { expected, found } => {
61
+ match * self {
62
+ UniverseInfo :: RelateTys { expected, found } => {
66
63
let err = mbcx. infcx . err_ctxt ( ) . report_mismatched_types (
67
64
& cause,
68
65
mbcx. param_env ,
@@ -72,10 +69,10 @@ impl<'tcx> UniverseInfo<'tcx> {
72
69
) ;
73
70
mbcx. buffer_error ( err) ;
74
71
}
75
- UniverseInfoInner :: TypeOp ( ref type_op_info) => {
72
+ UniverseInfo :: TypeOp ( ref type_op_info) => {
76
73
type_op_info. report_error ( mbcx, placeholder, error_element, cause) ;
77
74
}
78
- UniverseInfoInner :: Other => {
75
+ UniverseInfo :: Other => {
79
76
// FIXME: This error message isn't great, but it doesn't show
80
77
// up in the existing UI tests. Consider investigating this
81
78
// some more.
@@ -93,39 +90,30 @@ pub(crate) trait ToUniverseInfo<'tcx> {
93
90
94
91
impl < ' tcx > ToUniverseInfo < ' tcx > for crate :: type_check:: InstantiateOpaqueType < ' tcx > {
95
92
fn to_universe_info ( self , base_universe : ty:: UniverseIndex ) -> UniverseInfo < ' tcx > {
96
- UniverseInfo ( UniverseInfoInner :: TypeOp ( Rc :: new ( crate :: type_check:: InstantiateOpaqueType {
93
+ UniverseInfo :: TypeOp ( Rc :: new ( crate :: type_check:: InstantiateOpaqueType {
97
94
base_universe : Some ( base_universe) ,
98
95
..self
99
- } ) ) )
96
+ } ) )
100
97
}
101
98
}
102
99
103
100
impl < ' tcx > ToUniverseInfo < ' tcx > for CanonicalTypeOpProvePredicateGoal < ' tcx > {
104
101
fn to_universe_info ( self , base_universe : ty:: UniverseIndex ) -> UniverseInfo < ' tcx > {
105
- UniverseInfo ( UniverseInfoInner :: TypeOp ( Rc :: new ( PredicateQuery {
106
- canonical_query : self ,
107
- base_universe,
108
- } ) ) )
102
+ UniverseInfo :: TypeOp ( Rc :: new ( PredicateQuery { canonical_query : self , base_universe } ) )
109
103
}
110
104
}
111
105
112
106
impl < ' tcx , T : Copy + fmt:: Display + TypeFoldable < TyCtxt < ' tcx > > + ' tcx > ToUniverseInfo < ' tcx >
113
107
for CanonicalTypeOpNormalizeGoal < ' tcx , T >
114
108
{
115
109
fn to_universe_info ( self , base_universe : ty:: UniverseIndex ) -> UniverseInfo < ' tcx > {
116
- UniverseInfo ( UniverseInfoInner :: TypeOp ( Rc :: new ( NormalizeQuery {
117
- canonical_query : self ,
118
- base_universe,
119
- } ) ) )
110
+ UniverseInfo :: TypeOp ( Rc :: new ( NormalizeQuery { canonical_query : self , base_universe } ) )
120
111
}
121
112
}
122
113
123
114
impl < ' tcx > ToUniverseInfo < ' tcx > for CanonicalTypeOpAscribeUserTypeGoal < ' tcx > {
124
115
fn to_universe_info ( self , base_universe : ty:: UniverseIndex ) -> UniverseInfo < ' tcx > {
125
- UniverseInfo ( UniverseInfoInner :: TypeOp ( Rc :: new ( AscribeUserTypeQuery {
126
- canonical_query : self ,
127
- base_universe,
128
- } ) ) )
116
+ UniverseInfo :: TypeOp ( Rc :: new ( AscribeUserTypeQuery { canonical_query : self , base_universe } ) )
129
117
}
130
118
}
131
119
@@ -143,7 +131,7 @@ impl<'tcx> ToUniverseInfo<'tcx> for ! {
143
131
}
144
132
145
133
#[ allow( unused_lifetimes) ]
146
- trait TypeOpInfo < ' tcx > {
134
+ pub ( crate ) trait TypeOpInfo < ' tcx > {
147
135
/// Returns an error to be reported if rerunning the type op fails to
148
136
/// recover the error's cause.
149
137
fn fallback_error ( & self , tcx : TyCtxt < ' tcx > , span : Span ) -> Diag < ' tcx > ;
0 commit comments