@@ -9,7 +9,6 @@ use rustc_index::{Idx, IndexVec};
9
9
use rustc_middle:: middle:: stability:: EvalResult ;
10
10
use rustc_middle:: mir:: { self , Const } ;
11
11
use rustc_middle:: thir:: { self , Pat , PatKind , PatRange , PatRangeBoundary } ;
12
- use rustc_middle:: traits:: Reveal ;
13
12
use rustc_middle:: ty:: layout:: IntegerExt ;
14
13
use rustc_middle:: ty:: {
15
14
self , FieldDef , OpaqueTypeKey , ScalarInt , Ty , TyCtxt , TypeVisitableExt , VariantDef ,
@@ -86,7 +85,7 @@ pub struct RustcPatCtxt<'p, 'tcx: 'p> {
86
85
/// not. E.g., `struct Foo { _private: ! }` cannot be seen to be empty
87
86
/// outside its module and should not be matchable with an empty match statement.
88
87
pub module : DefId ,
89
- pub param_env : ty:: ParamEnv < ' tcx > ,
88
+ pub typing_env : ty:: TypingEnv < ' tcx > ,
90
89
/// To allocate the result of `self.ctor_sub_tys()`
91
90
pub dropless_arena : & ' p DroplessArena ,
92
91
/// Lint level at the match.
@@ -109,17 +108,6 @@ impl<'p, 'tcx: 'p> fmt::Debug for RustcPatCtxt<'p, 'tcx> {
109
108
}
110
109
111
110
impl < ' p , ' tcx : ' p > RustcPatCtxt < ' p , ' tcx > {
112
- pub fn typing_mode ( & self ) -> ty:: TypingMode < ' tcx > {
113
- debug_assert_eq ! ( self . param_env. reveal( ) , Reveal :: UserFacing ) ;
114
- // FIXME(#132279): This is inside of a body. If we need to use the `param_env`
115
- // and `typing_mode` we should reveal opaques defined by that body.
116
- ty:: TypingMode :: non_body_analysis ( )
117
- }
118
-
119
- pub fn typing_env ( & self ) -> ty:: TypingEnv < ' tcx > {
120
- ty:: TypingEnv { typing_mode : self . typing_mode ( ) , param_env : self . param_env }
121
- }
122
-
123
111
/// Type inference occasionally gives us opaque types in places where corresponding patterns
124
112
/// have more specific types. To avoid inconsistencies as well as detect opaque uninhabited
125
113
/// types, we use the corresponding concrete type if possible.
@@ -151,7 +139,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
151
139
pub fn is_uninhabited ( & self , ty : Ty < ' tcx > ) -> bool {
152
140
!ty. inhabited_predicate ( self . tcx ) . apply_revealing_opaque (
153
141
self . tcx ,
154
- self . typing_env ( ) ,
142
+ self . typing_env ,
155
143
self . module ,
156
144
& |key| self . reveal_opaque_key ( key) ,
157
145
)
@@ -191,7 +179,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
191
179
variant. fields . iter ( ) . map ( move |field| {
192
180
let ty = field. ty ( self . tcx , args) ;
193
181
// `field.ty()` doesn't normalize after instantiating.
194
- let ty = self . tcx . normalize_erasing_regions ( self . typing_env ( ) , ty) ;
182
+ let ty = self . tcx . normalize_erasing_regions ( self . typing_env , ty) ;
195
183
let ty = self . reveal_opaque_ty ( ty) ;
196
184
( field, ty)
197
185
} )
@@ -381,7 +369,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
381
369
let is_inhabited = v
382
370
. inhabited_predicate ( cx. tcx , * def)
383
371
. instantiate ( cx. tcx , args)
384
- . apply_revealing_opaque ( cx. tcx , cx. typing_env ( ) , cx. module , & |key| {
372
+ . apply_revealing_opaque ( cx. tcx , cx. typing_env , cx. module , & |key| {
385
373
cx. reveal_opaque_key ( key)
386
374
} ) ;
387
375
// Variants that depend on a disabled unstable feature.
@@ -442,7 +430,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
442
430
match bdy {
443
431
PatRangeBoundary :: NegInfinity => MaybeInfiniteInt :: NegInfinity ,
444
432
PatRangeBoundary :: Finite ( value) => {
445
- let bits = value. eval_bits ( self . tcx , self . typing_env ( ) ) ;
433
+ let bits = value. eval_bits ( self . tcx , self . typing_env ) ;
446
434
match * ty. kind ( ) {
447
435
ty:: Int ( ity) => {
448
436
let size = Integer :: from_int_ty ( & self . tcx , ity) . size ( ) . bits ( ) ;
@@ -551,15 +539,15 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
551
539
PatKind :: Constant { value } => {
552
540
match ty. kind ( ) {
553
541
ty:: Bool => {
554
- ctor = match value. try_eval_bool ( cx. tcx , cx. typing_env ( ) ) {
542
+ ctor = match value. try_eval_bool ( cx. tcx , cx. typing_env ) {
555
543
Some ( b) => Bool ( b) ,
556
544
None => Opaque ( OpaqueId :: new ( ) ) ,
557
545
} ;
558
546
fields = vec ! [ ] ;
559
547
arity = 0 ;
560
548
}
561
549
ty:: Char | ty:: Int ( _) | ty:: Uint ( _) => {
562
- ctor = match value. try_eval_bits ( cx. tcx , cx. typing_env ( ) ) {
550
+ ctor = match value. try_eval_bits ( cx. tcx , cx. typing_env ) {
563
551
Some ( bits) => {
564
552
let x = match * ty. kind ( ) {
565
553
ty:: Int ( ity) => {
@@ -576,7 +564,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
576
564
arity = 0 ;
577
565
}
578
566
ty:: Float ( ty:: FloatTy :: F16 ) => {
579
- ctor = match value. try_eval_bits ( cx. tcx , cx. typing_env ( ) ) {
567
+ ctor = match value. try_eval_bits ( cx. tcx , cx. typing_env ) {
580
568
Some ( bits) => {
581
569
use rustc_apfloat:: Float ;
582
570
let value = rustc_apfloat:: ieee:: Half :: from_bits ( bits) ;
@@ -588,7 +576,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
588
576
arity = 0 ;
589
577
}
590
578
ty:: Float ( ty:: FloatTy :: F32 ) => {
591
- ctor = match value. try_eval_bits ( cx. tcx , cx. typing_env ( ) ) {
579
+ ctor = match value. try_eval_bits ( cx. tcx , cx. typing_env ) {
592
580
Some ( bits) => {
593
581
use rustc_apfloat:: Float ;
594
582
let value = rustc_apfloat:: ieee:: Single :: from_bits ( bits) ;
@@ -600,7 +588,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
600
588
arity = 0 ;
601
589
}
602
590
ty:: Float ( ty:: FloatTy :: F64 ) => {
603
- ctor = match value. try_eval_bits ( cx. tcx , cx. typing_env ( ) ) {
591
+ ctor = match value. try_eval_bits ( cx. tcx , cx. typing_env ) {
604
592
Some ( bits) => {
605
593
use rustc_apfloat:: Float ;
606
594
let value = rustc_apfloat:: ieee:: Double :: from_bits ( bits) ;
@@ -612,7 +600,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
612
600
arity = 0 ;
613
601
}
614
602
ty:: Float ( ty:: FloatTy :: F128 ) => {
615
- ctor = match value. try_eval_bits ( cx. tcx , cx. typing_env ( ) ) {
603
+ ctor = match value. try_eval_bits ( cx. tcx , cx. typing_env ) {
616
604
Some ( bits) => {
617
605
use rustc_apfloat:: Float ;
618
606
let value = rustc_apfloat:: ieee:: Quad :: from_bits ( bits) ;
@@ -661,8 +649,8 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
661
649
}
662
650
ty:: Float ( fty) => {
663
651
use rustc_apfloat:: Float ;
664
- let lo = lo. as_finite ( ) . map ( |c| c. eval_bits ( cx. tcx , cx. typing_env ( ) ) ) ;
665
- let hi = hi. as_finite ( ) . map ( |c| c. eval_bits ( cx. tcx , cx. typing_env ( ) ) ) ;
652
+ let lo = lo. as_finite ( ) . map ( |c| c. eval_bits ( cx. tcx , cx. typing_env ) ) ;
653
+ let hi = hi. as_finite ( ) . map ( |c| c. eval_bits ( cx. tcx , cx. typing_env ) ) ;
666
654
match fty {
667
655
ty:: FloatTy :: F16 => {
668
656
use rustc_apfloat:: ieee:: Half ;
0 commit comments