@@ -7,7 +7,6 @@ use rustc_errors::{Applicability, ErrorGuaranteed, MultiSpan, struct_span_code_e
7
7
use rustc_hir:: def:: * ;
8
8
use rustc_hir:: def_id:: LocalDefId ;
9
9
use rustc_hir:: { self as hir, BindingMode , ByRef , HirId } ;
10
- use rustc_infer:: traits:: Reveal ;
11
10
use rustc_middle:: bug;
12
11
use rustc_middle:: middle:: limits:: get_limit_size;
13
12
use rustc_middle:: thir:: visit:: Visitor ;
@@ -39,7 +38,8 @@ pub(crate) fn check_match(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), Err
39
38
tcx,
40
39
thir : & * thir,
41
40
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) ,
43
43
lint_level : tcx. local_def_id_to_hir_id ( def_id) ,
44
44
let_source : LetSource :: None ,
45
45
pattern_arena : & pattern_arena,
@@ -86,7 +86,7 @@ enum LetSource {
86
86
87
87
struct MatchVisitor < ' p , ' tcx > {
88
88
tcx : TyCtxt < ' tcx > ,
89
- param_env : ty:: ParamEnv < ' tcx > ,
89
+ typing_env : ty:: TypingEnv < ' tcx > ,
90
90
typeck_results : & ' tcx ty:: TypeckResults < ' tcx > ,
91
91
thir : & ' p Thir < ' tcx > ,
92
92
lint_level : HirId ,
@@ -192,15 +192,6 @@ impl<'p, 'tcx> Visitor<'p, 'tcx> for MatchVisitor<'p, 'tcx> {
192
192
}
193
193
194
194
impl < ' 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
-
204
195
#[ instrument( level = "trace" , skip( self , f) ) ]
205
196
fn with_let_source ( & mut self , let_source : LetSource , f : impl FnOnce ( & mut Self ) ) {
206
197
let old_let_source = self . let_source ;
@@ -391,7 +382,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
391
382
PatCtxt {
392
383
tcx : self . tcx ,
393
384
typeck_results : self . typeck_results ,
394
- param_env : self . param_env ,
385
+ typing_env : self . typing_env ,
395
386
module : self . tcx . parent_module ( self . lint_level ) . to_def_id ( ) ,
396
387
dropless_arena : self . dropless_arena ,
397
388
match_lint_level : self . lint_level ,
@@ -745,8 +736,8 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
745
736
. variant ( * variant_index)
746
737
. inhabited_predicate ( self . tcx , * adt)
747
738
. instantiate ( self . tcx , args) ;
748
- variant_inhabited. apply ( self . tcx , cx. typing_env ( ) , cx. module )
749
- && !variant_inhabited. apply_ignore_module ( self . tcx , cx. typing_env ( ) )
739
+ variant_inhabited. apply ( self . tcx , cx. typing_env , cx. module )
740
+ && !variant_inhabited. apply_ignore_module ( self . tcx , cx. typing_env )
750
741
} else {
751
742
false
752
743
} ;
@@ -785,7 +776,7 @@ fn check_borrow_conflicts_in_at_patterns<'tcx>(cx: &MatchVisitor<'_, 'tcx>, pat:
785
776
return ;
786
777
} ;
787
778
788
- let is_binding_by_move = |ty : Ty < ' tcx > | !ty. is_copy_modulo_regions ( cx. tcx , cx. typing_env ( ) ) ;
779
+ let is_binding_by_move = |ty : Ty < ' tcx > | !ty. is_copy_modulo_regions ( cx. tcx , cx. typing_env ) ;
789
780
790
781
let sess = cx. tcx . sess ;
791
782
@@ -1149,7 +1140,7 @@ fn report_non_exhaustive_match<'p, 'tcx>(
1149
1140
}
1150
1141
1151
1142
if let ty:: Ref ( _, sub_ty, _) = scrut_ty. kind ( ) {
1152
- if !sub_ty. is_inhabited_from ( cx. tcx , cx. module , cx. typing_env ( ) ) {
1143
+ if !sub_ty. is_inhabited_from ( cx. tcx , cx. module , cx. typing_env ) {
1153
1144
err. note ( "references are always considered inhabited" ) ;
1154
1145
}
1155
1146
}
0 commit comments