@@ -18,7 +18,7 @@ use rustc_data_structures::fx::FxHashMap;
18
18
use rustc:: util:: common:: ErrorReported ;
19
19
20
20
use syntax:: ast:: Mutability ;
21
- use syntax:: source_map:: DUMMY_SP ;
21
+ use syntax:: source_map:: { Span , DUMMY_SP } ;
22
22
23
23
use crate :: interpret:: { self ,
24
24
PlaceTy , MPlaceTy , MemPlace , OpTy , Operand , Immediate , Scalar , RawConst , ConstValue , Pointer ,
@@ -44,10 +44,11 @@ const DETECTOR_SNAPSHOT_PERIOD: isize = 256;
44
44
/// parameter. These bounds are passed to `mk_eval_cx` via the `ParamEnv` argument.
45
45
pub ( crate ) fn mk_eval_cx < ' a , ' mir , ' tcx > (
46
46
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
47
+ span : Span ,
47
48
param_env : ty:: ParamEnv < ' tcx > ,
48
49
) -> CompileTimeEvalContext < ' a , ' mir , ' tcx > {
49
50
debug ! ( "mk_eval_cx: {:?}" , param_env) ;
50
- EvalContext :: new ( tcx. at ( DUMMY_SP ) , param_env, CompileTimeInterpreter :: new ( ) )
51
+ EvalContext :: new ( tcx. at ( span ) , param_env, CompileTimeInterpreter :: new ( ) )
51
52
}
52
53
53
54
pub ( crate ) fn eval_promoted < ' a , ' mir , ' tcx > (
@@ -56,7 +57,8 @@ pub(crate) fn eval_promoted<'a, 'mir, 'tcx>(
56
57
mir : & ' mir mir:: Mir < ' tcx > ,
57
58
param_env : ty:: ParamEnv < ' tcx > ,
58
59
) -> EvalResult < ' tcx , MPlaceTy < ' tcx > > {
59
- let mut ecx = mk_eval_cx ( tcx, param_env) ;
60
+ let span = tcx. def_span ( cid. instance . def_id ( ) ) ;
61
+ let mut ecx = mk_eval_cx ( tcx, span, param_env) ;
60
62
eval_body_using_ecx ( & mut ecx, cid, Some ( mir) , param_env)
61
63
}
62
64
@@ -482,7 +484,7 @@ pub fn const_field<'a, 'tcx>(
482
484
value : ty:: Const < ' tcx > ,
483
485
) -> :: rustc:: mir:: interpret:: ConstEvalResult < ' tcx > {
484
486
trace ! ( "const_field: {:?}, {:?}" , field, value) ;
485
- let ecx = mk_eval_cx ( tcx, param_env) ;
487
+ let ecx = mk_eval_cx ( tcx, DUMMY_SP , param_env) ;
486
488
let result = ( || {
487
489
// get the operand again
488
490
let op = lazy_const_to_op ( & ecx, ty:: LazyConst :: Evaluated ( value) , value. ty ) ?;
@@ -510,7 +512,7 @@ pub fn const_variant_index<'a, 'tcx>(
510
512
val : ty:: Const < ' tcx > ,
511
513
) -> EvalResult < ' tcx , VariantIdx > {
512
514
trace ! ( "const_variant_index: {:?}" , val) ;
513
- let ecx = mk_eval_cx ( tcx, param_env) ;
515
+ let ecx = mk_eval_cx ( tcx, DUMMY_SP , param_env) ;
514
516
let op = lazy_const_to_op ( & ecx, ty:: LazyConst :: Evaluated ( val) , val. ty ) ?;
515
517
Ok ( ecx. read_discriminant ( op) ?. 1 )
516
518
}
@@ -530,7 +532,7 @@ fn validate_and_turn_into_const<'a, 'tcx>(
530
532
key : ty:: ParamEnvAnd < ' tcx , GlobalId < ' tcx > > ,
531
533
) -> :: rustc:: mir:: interpret:: ConstEvalResult < ' tcx > {
532
534
let cid = key. value ;
533
- let ecx = mk_eval_cx ( tcx, key. param_env ) ;
535
+ let ecx = mk_eval_cx ( tcx, tcx . def_span ( key . value . instance . def_id ( ) ) , key. param_env ) ;
534
536
let val = ( || {
535
537
let op = ecx. raw_const_to_mplace ( constant) ?. into ( ) ;
536
538
// FIXME: Once the visitor infrastructure landed, change validation to
0 commit comments