@@ -9,7 +9,6 @@ use rustc_index::{Idx, IndexVec};
99use rustc_middle:: middle:: stability:: EvalResult ;
1010use rustc_middle:: mir:: { self , Const } ;
1111use rustc_middle:: thir:: { self , Pat , PatKind , PatRange , PatRangeBoundary } ;
12- use rustc_middle:: traits:: Reveal ;
1312use rustc_middle:: ty:: layout:: IntegerExt ;
1413use rustc_middle:: ty:: {
1514 self , FieldDef , OpaqueTypeKey , ScalarInt , Ty , TyCtxt , TypeVisitableExt , VariantDef ,
@@ -86,7 +85,7 @@ pub struct RustcPatCtxt<'p, 'tcx: 'p> {
8685 /// not. E.g., `struct Foo { _private: ! }` cannot be seen to be empty
8786 /// outside its module and should not be matchable with an empty match statement.
8887 pub module : DefId ,
89- pub param_env : ty:: ParamEnv < ' tcx > ,
88+ pub typing_env : ty:: TypingEnv < ' tcx > ,
9089 /// To allocate the result of `self.ctor_sub_tys()`
9190 pub dropless_arena : & ' p DroplessArena ,
9291 /// Lint level at the match.
@@ -109,17 +108,6 @@ impl<'p, 'tcx: 'p> fmt::Debug for RustcPatCtxt<'p, 'tcx> {
109108}
110109
111110impl < ' 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-
123111 /// Type inference occasionally gives us opaque types in places where corresponding patterns
124112 /// have more specific types. To avoid inconsistencies as well as detect opaque uninhabited
125113 /// types, we use the corresponding concrete type if possible.
@@ -151,7 +139,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
151139 pub fn is_uninhabited ( & self , ty : Ty < ' tcx > ) -> bool {
152140 !ty. inhabited_predicate ( self . tcx ) . apply_revealing_opaque (
153141 self . tcx ,
154- self . typing_env ( ) ,
142+ self . typing_env ,
155143 self . module ,
156144 & |key| self . reveal_opaque_key ( key) ,
157145 )
@@ -191,7 +179,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
191179 variant. fields . iter ( ) . map ( move |field| {
192180 let ty = field. ty ( self . tcx , args) ;
193181 // `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) ;
195183 let ty = self . reveal_opaque_ty ( ty) ;
196184 ( field, ty)
197185 } )
@@ -381,7 +369,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
381369 let is_inhabited = v
382370 . inhabited_predicate ( cx. tcx , * def)
383371 . 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| {
385373 cx. reveal_opaque_key ( key)
386374 } ) ;
387375 // Variants that depend on a disabled unstable feature.
@@ -442,7 +430,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
442430 match bdy {
443431 PatRangeBoundary :: NegInfinity => MaybeInfiniteInt :: NegInfinity ,
444432 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 ) ;
446434 match * ty. kind ( ) {
447435 ty:: Int ( ity) => {
448436 let size = Integer :: from_int_ty ( & self . tcx , ity) . size ( ) . bits ( ) ;
@@ -551,15 +539,15 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
551539 PatKind :: Constant { value } => {
552540 match ty. kind ( ) {
553541 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 ) {
555543 Some ( b) => Bool ( b) ,
556544 None => Opaque ( OpaqueId :: new ( ) ) ,
557545 } ;
558546 fields = vec ! [ ] ;
559547 arity = 0 ;
560548 }
561549 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 ) {
563551 Some ( bits) => {
564552 let x = match * ty. kind ( ) {
565553 ty:: Int ( ity) => {
@@ -576,7 +564,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
576564 arity = 0 ;
577565 }
578566 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 ) {
580568 Some ( bits) => {
581569 use rustc_apfloat:: Float ;
582570 let value = rustc_apfloat:: ieee:: Half :: from_bits ( bits) ;
@@ -588,7 +576,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
588576 arity = 0 ;
589577 }
590578 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 ) {
592580 Some ( bits) => {
593581 use rustc_apfloat:: Float ;
594582 let value = rustc_apfloat:: ieee:: Single :: from_bits ( bits) ;
@@ -600,7 +588,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
600588 arity = 0 ;
601589 }
602590 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 ) {
604592 Some ( bits) => {
605593 use rustc_apfloat:: Float ;
606594 let value = rustc_apfloat:: ieee:: Double :: from_bits ( bits) ;
@@ -612,7 +600,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
612600 arity = 0 ;
613601 }
614602 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 ) {
616604 Some ( bits) => {
617605 use rustc_apfloat:: Float ;
618606 let value = rustc_apfloat:: ieee:: Quad :: from_bits ( bits) ;
@@ -661,8 +649,8 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
661649 }
662650 ty:: Float ( fty) => {
663651 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 ) ) ;
666654 match fty {
667655 ty:: FloatTy :: F16 => {
668656 use rustc_apfloat:: ieee:: Half ;
0 commit comments