@@ -21,6 +21,7 @@ use rustc::middle::mem_categorization::{cmt};
21
21
use rustc:: middle:: region:: RegionMaps ;
22
22
use rustc:: session:: Session ;
23
23
use rustc:: ty:: { self , Ty , TyCtxt } ;
24
+ use rustc:: ty:: subst:: Substs ;
24
25
use rustc:: lint;
25
26
use rustc_errors:: { Diagnostic , Level , DiagnosticBuilder } ;
26
27
@@ -51,7 +52,8 @@ impl<'a, 'tcx> Visitor<'tcx> for OuterVisitor<'a, 'tcx> {
51
52
tcx : self . tcx ,
52
53
tables : self . tcx . body_tables ( b) ,
53
54
region_maps : & self . tcx . region_maps ( def_id) ,
54
- param_env : self . tcx . param_env ( def_id)
55
+ param_env : self . tcx . param_env ( def_id) ,
56
+ identity_substs : Substs :: identity_for_item ( self . tcx , def_id) ,
55
57
} . visit_body ( self . tcx . hir . body ( b) ) ;
56
58
}
57
59
}
@@ -69,6 +71,7 @@ struct MatchVisitor<'a, 'tcx: 'a> {
69
71
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
70
72
tables : & ' a ty:: TypeckTables < ' tcx > ,
71
73
param_env : ty:: ParamEnv < ' tcx > ,
74
+ identity_substs : & ' tcx Substs < ' tcx > ,
72
75
region_maps : & ' a RegionMaps ,
73
76
}
74
77
@@ -110,7 +113,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MatchVisitor<'a, 'tcx> {
110
113
}
111
114
}
112
115
113
- impl < ' a , ' gcx , ' tcx > PatternContext < ' a , ' gcx , ' tcx > {
116
+ impl < ' a , ' tcx > PatternContext < ' a , ' tcx > {
114
117
fn report_inlining_errors ( & self , pat_span : Span ) {
115
118
for error in & self . errors {
116
119
match * error {
@@ -162,7 +165,9 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> {
162
165
163
166
let inlined_arms : Vec < ( Vec < _ > , _ ) > = arms. iter ( ) . map ( |arm| (
164
167
arm. pats . iter ( ) . map ( |pat| {
165
- let mut patcx = PatternContext :: new ( self . tcx , self . tables ) ;
168
+ let mut patcx = PatternContext :: new ( self . tcx ,
169
+ self . param_env . and ( self . identity_substs ) ,
170
+ self . tables ) ;
166
171
let pattern = expand_pattern ( cx, patcx. lower_pattern ( & pat) ) ;
167
172
if !patcx. errors . is_empty ( ) {
168
173
patcx. report_inlining_errors ( pat. span ) ;
@@ -229,7 +234,9 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> {
229
234
fn check_irrefutable ( & self , pat : & Pat , origin : & str ) {
230
235
let module = self . tcx . hir . get_module_parent ( pat. id ) ;
231
236
MatchCheckCtxt :: create_and_enter ( self . tcx , module, |ref mut cx| {
232
- let mut patcx = PatternContext :: new ( self . tcx , self . tables ) ;
237
+ let mut patcx = PatternContext :: new ( self . tcx ,
238
+ self . param_env . and ( self . identity_substs ) ,
239
+ self . tables ) ;
233
240
let pattern = patcx. lower_pattern ( pat) ;
234
241
let pattern_ty = pattern. ty ;
235
242
let pats : Matrix = vec ! [ vec![
0 commit comments