@@ -3,41 +3,38 @@ use rustc_mir::const_eval::const_field;
3
3
use rustc:: mir;
4
4
use rustc_data_structures:: indexed_vec:: Idx ;
5
5
use rustc:: mir:: interpret:: GlobalId ;
6
- use rustc:: ty:: { self , Ty } ;
7
- use rustc:: ty:: layout;
6
+ use rustc:: ty:: { self , Ty , TyCtxt } ;
7
+ use rustc:: ty:: layout:: { self , HasTyCtxt } ;
8
8
use syntax:: source_map:: Span ;
9
9
use crate :: traits:: * ;
10
10
11
11
use super :: FunctionCx ;
12
12
13
- impl < ' a , ' tcx : ' a , Bx : BuilderMethods < ' a , ' tcx > > FunctionCx < ' a , ' tcx , Bx > {
14
- fn fully_evaluate (
15
- & mut self ,
16
- bx : & Bx ,
17
- constant : & ' tcx ty:: LazyConst < ' tcx > ,
18
- ) -> Result < ty:: Const < ' tcx > , ErrorHandled > {
19
- match * constant {
20
- ty:: LazyConst :: Unevaluated ( def_id, ref substs) => {
21
- let tcx = bx. tcx ( ) ;
22
- let param_env = ty:: ParamEnv :: reveal_all ( ) ;
23
- let instance = ty:: Instance :: resolve ( tcx, param_env, def_id, substs) . unwrap ( ) ;
24
- let cid = GlobalId {
25
- instance,
26
- promoted : None ,
27
- } ;
28
- tcx. const_eval ( param_env. and ( cid) )
29
- } ,
30
- ty:: LazyConst :: Evaluated ( constant) => Ok ( constant) ,
31
- }
13
+ fn fully_evaluate < ' a , ' tcx : ' a > (
14
+ tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
15
+ constant : & ' tcx ty:: LazyConst < ' tcx > ,
16
+ ) -> Result < ty:: Const < ' tcx > , ErrorHandled > {
17
+ match * constant {
18
+ ty:: LazyConst :: Unevaluated ( def_id, ref substs) => {
19
+ let param_env = ty:: ParamEnv :: reveal_all ( ) ;
20
+ let instance = ty:: Instance :: resolve ( tcx, param_env, def_id, substs) . unwrap ( ) ;
21
+ let cid = GlobalId {
22
+ instance,
23
+ promoted : None ,
24
+ } ;
25
+ tcx. const_eval ( param_env. and ( cid) )
26
+ } ,
27
+ ty:: LazyConst :: Evaluated ( constant) => Ok ( constant) ,
32
28
}
29
+ }
33
30
31
+ impl < ' a , ' tcx : ' a , Bx : BuilderMethods < ' a , ' tcx > > FunctionCx < ' a , ' tcx , Bx > {
34
32
pub fn eval_mir_constant (
35
- & mut self ,
36
- bx : & Bx ,
33
+ & self ,
37
34
constant : & mir:: Constant < ' tcx > ,
38
35
) -> Result < ty:: Const < ' tcx > , ErrorHandled > {
39
36
let c = self . monomorphize ( & constant. literal ) ;
40
- self . fully_evaluate ( bx , c)
37
+ fully_evaluate ( self . cx . tcx ( ) , c)
41
38
}
42
39
43
40
/// process constant containing SIMD shuffle indices
0 commit comments