@@ -7,7 +7,6 @@ use rustc_errors::{Applicability, ErrorGuaranteed, MultiSpan, struct_span_code_e
77use rustc_hir:: def:: * ;
88use rustc_hir:: def_id:: LocalDefId ;
99use rustc_hir:: { self as hir, BindingMode , ByRef , HirId } ;
10- use rustc_infer:: traits:: Reveal ;
1110use rustc_middle:: bug;
1211use rustc_middle:: middle:: limits:: get_limit_size;
1312use rustc_middle:: thir:: visit:: Visitor ;
@@ -39,7 +38,8 @@ pub(crate) fn check_match(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), Err
3938 tcx,
4039 thir : & * thir,
4140 typeck_results,
42- param_env : tcx. param_env ( def_id) ,
41+ // FIXME(#132279): We're in a body, should handle opaques.
42+ typing_env : ty:: TypingEnv :: non_body_analysis ( tcx, def_id) ,
4343 lint_level : tcx. local_def_id_to_hir_id ( def_id) ,
4444 let_source : LetSource :: None ,
4545 pattern_arena : & pattern_arena,
@@ -86,7 +86,7 @@ enum LetSource {
8686
8787struct MatchVisitor < ' p , ' tcx > {
8888 tcx : TyCtxt < ' tcx > ,
89- param_env : ty:: ParamEnv < ' tcx > ,
89+ typing_env : ty:: TypingEnv < ' tcx > ,
9090 typeck_results : & ' tcx ty:: TypeckResults < ' tcx > ,
9191 thir : & ' p Thir < ' tcx > ,
9292 lint_level : HirId ,
@@ -192,15 +192,6 @@ impl<'p, 'tcx> Visitor<'p, 'tcx> for MatchVisitor<'p, 'tcx> {
192192}
193193
194194impl < ' p , ' tcx > MatchVisitor < ' p , ' tcx > {
195- fn typing_env ( & self ) -> ty:: TypingEnv < ' tcx > {
196- // FIXME(#132279): We're in a body, should handle opaques.
197- debug_assert_eq ! ( self . param_env. reveal( ) , Reveal :: UserFacing ) ;
198- ty:: TypingEnv {
199- typing_mode : ty:: TypingMode :: non_body_analysis ( ) ,
200- param_env : self . param_env ,
201- }
202- }
203-
204195 #[ instrument( level = "trace" , skip( self , f) ) ]
205196 fn with_let_source ( & mut self , let_source : LetSource , f : impl FnOnce ( & mut Self ) ) {
206197 let old_let_source = self . let_source ;
@@ -391,7 +382,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
391382 PatCtxt {
392383 tcx : self . tcx ,
393384 typeck_results : self . typeck_results ,
394- param_env : self . param_env ,
385+ typing_env : self . typing_env ,
395386 module : self . tcx . parent_module ( self . lint_level ) . to_def_id ( ) ,
396387 dropless_arena : self . dropless_arena ,
397388 match_lint_level : self . lint_level ,
@@ -731,8 +722,8 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
731722 . variant ( * variant_index)
732723 . inhabited_predicate ( self . tcx , * adt)
733724 . instantiate ( self . tcx , args) ;
734- variant_inhabited. apply ( self . tcx , cx. typing_env ( ) , cx. module )
735- && !variant_inhabited. apply_ignore_module ( self . tcx , cx. typing_env ( ) )
725+ variant_inhabited. apply ( self . tcx , cx. typing_env , cx. module )
726+ && !variant_inhabited. apply_ignore_module ( self . tcx , cx. typing_env )
736727 } else {
737728 false
738729 } ;
@@ -770,7 +761,7 @@ fn check_borrow_conflicts_in_at_patterns<'tcx>(cx: &MatchVisitor<'_, 'tcx>, pat:
770761 return ;
771762 } ;
772763
773- let is_binding_by_move = |ty : Ty < ' tcx > | !ty. is_copy_modulo_regions ( cx. tcx , cx. typing_env ( ) ) ;
764+ let is_binding_by_move = |ty : Ty < ' tcx > | !ty. is_copy_modulo_regions ( cx. tcx , cx. typing_env ) ;
774765
775766 let sess = cx. tcx . sess ;
776767
@@ -1134,7 +1125,7 @@ fn report_non_exhaustive_match<'p, 'tcx>(
11341125 }
11351126
11361127 if let ty:: Ref ( _, sub_ty, _) = scrut_ty. kind ( ) {
1137- if !sub_ty. is_inhabited_from ( cx. tcx , cx. module , cx. typing_env ( ) ) {
1128+ if !sub_ty. is_inhabited_from ( cx. tcx , cx. module , cx. typing_env ) {
11381129 err. note ( "references are always considered inhabited" ) ;
11391130 }
11401131 }
0 commit comments