1
1
use std:: fmt;
2
2
use std:: iter:: once;
3
- use std:: ops:: ControlFlow ;
4
3
5
4
use rustc_abi:: { FIRST_VARIANT , FieldIdx , Integer , VariantIdx } ;
6
5
use rustc_arena:: DroplessArena ;
@@ -12,8 +11,7 @@ use rustc_middle::mir::{self, Const};
12
11
use rustc_middle:: thir:: { self , Pat , PatKind , PatRange , PatRangeBoundary } ;
13
12
use rustc_middle:: ty:: layout:: IntegerExt ;
14
13
use rustc_middle:: ty:: {
15
- self , FieldDef , OpaqueTypeKey , ScalarInt , Ty , TyCtxt , TypeSuperVisitable , TypeVisitable ,
16
- TypeVisitableExt , TypeVisitor , VariantDef ,
14
+ self , FieldDef , OpaqueTypeKey , ScalarInt , Ty , TyCtxt , TypeVisitableExt , VariantDef ,
17
15
} ;
18
16
use rustc_middle:: { bug, span_bug} ;
19
17
use rustc_session:: lint;
@@ -137,22 +135,11 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
137
135
/// Returns the hidden type corresponding to this key if the body under analysis is allowed to
138
136
/// know it.
139
137
fn reveal_opaque_key ( & self , key : OpaqueTypeKey < ' tcx > ) -> Option < Ty < ' tcx > > {
140
- if let Some ( hidden_ty) = self . typeck_results . concrete_opaque_types . get ( & key. def_id ) {
141
- let ty = ty:: EarlyBinder :: bind ( hidden_ty. ty ) . instantiate ( self . tcx , key. args ) ;
142
- if ty. visit_with ( & mut RecursiveOpaque { def_id : key. def_id . into ( ) } ) . is_continue ( ) {
143
- Some ( ty)
144
- } else {
145
- // HACK: We skip revealing opaque types which recursively expand
146
- // to themselves. This is because we may infer hidden types like
147
- // `Opaque<T> = Opaque<Opaque<T>>` or `Opaque<T> = Opaque<(T,)>`
148
- // in hir typeck.
149
- None
150
- }
151
- } else {
152
- None
153
- }
138
+ self . typeck_results
139
+ . concrete_opaque_types
140
+ . get ( & key. def_id )
141
+ . map ( |x| ty:: EarlyBinder :: bind ( x. ty ) . instantiate ( self . tcx , key. args ) )
154
142
}
155
-
156
143
// This can take a non-revealed `Ty` because it reveals opaques itself.
157
144
pub fn is_uninhabited ( & self , ty : Ty < ' tcx > ) -> bool {
158
145
!ty. inhabited_predicate ( self . tcx ) . apply_revealing_opaque (
@@ -1118,20 +1105,3 @@ pub fn analyze_match<'p, 'tcx>(
1118
1105
1119
1106
Ok ( report)
1120
1107
}
1121
-
1122
- struct RecursiveOpaque {
1123
- def_id : DefId ,
1124
- }
1125
- impl < ' tcx > TypeVisitor < TyCtxt < ' tcx > > for RecursiveOpaque {
1126
- type Result = ControlFlow < ( ) > ;
1127
-
1128
- fn visit_ty ( & mut self , t : Ty < ' tcx > ) -> Self :: Result {
1129
- if let ty:: Alias ( ty:: Opaque , alias_ty) = t. kind ( ) {
1130
- if alias_ty. def_id == self . def_id {
1131
- return ControlFlow :: Break ( ( ) ) ;
1132
- }
1133
- }
1134
-
1135
- if t. has_opaque_types ( ) { t. super_visit_with ( self ) } else { ControlFlow :: Continue ( ( ) ) }
1136
- }
1137
- }
0 commit comments