@@ -4,7 +4,7 @@ use rustc_index::vec::IndexVec;
4
4
use rustc_middle:: mir:: patch:: MirPatch ;
5
5
use rustc_middle:: mir:: visit:: * ;
6
6
use rustc_middle:: mir:: * ;
7
- use rustc_middle:: ty:: { Ty , TyCtxt } ;
7
+ use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
8
8
use rustc_mir_dataflow:: value_analysis:: { excluded_locals, iter_fields} ;
9
9
10
10
pub struct ScalarReplacementOfAggregates ;
@@ -18,11 +18,12 @@ impl<'tcx> MirPass<'tcx> for ScalarReplacementOfAggregates {
18
18
fn run_pass ( & self , tcx : TyCtxt < ' tcx > , body : & mut Body < ' tcx > ) {
19
19
debug ! ( def_id = ?body. source. def_id( ) ) ;
20
20
let mut excluded = excluded_locals ( body) ;
21
+ let param_env = tcx. param_env_reveal_all_normalized ( body. source . def_id ( ) ) ;
21
22
loop {
22
23
debug ! ( ?excluded) ;
23
24
let escaping = escaping_locals ( & excluded, body) ;
24
25
debug ! ( ?escaping) ;
25
- let replacements = compute_flattening ( tcx, body, escaping) ;
26
+ let replacements = compute_flattening ( tcx, param_env , body, escaping) ;
26
27
debug ! ( ?replacements) ;
27
28
let all_dead_locals = replace_flattened_locals ( tcx, body, replacements) ;
28
29
if !all_dead_locals. is_empty ( ) {
@@ -144,6 +145,7 @@ impl<'tcx> ReplacementMap<'tcx> {
144
145
/// The replacement will be done later in `ReplacementVisitor`.
145
146
fn compute_flattening < ' tcx > (
146
147
tcx : TyCtxt < ' tcx > ,
148
+ param_env : ty:: ParamEnv < ' tcx > ,
147
149
body : & mut Body < ' tcx > ,
148
150
escaping : BitSet < Local > ,
149
151
) -> ReplacementMap < ' tcx > {
@@ -155,7 +157,7 @@ fn compute_flattening<'tcx>(
155
157
}
156
158
let decl = body. local_decls [ local] . clone ( ) ;
157
159
let ty = decl. ty ;
158
- iter_fields ( ty, tcx, |variant, field, field_ty| {
160
+ iter_fields ( ty, tcx, param_env , |variant, field, field_ty| {
159
161
if variant. is_some ( ) {
160
162
// Downcasts are currently not supported.
161
163
return ;
0 commit comments