@@ -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 ,
@@ -43,10 +43,11 @@ const DETECTOR_SNAPSHOT_PERIOD: isize = 256;
43
43
/// parameter. These bounds are passed to `mk_eval_cx` via the `ParamEnv` argument.
44
44
pub ( crate ) fn mk_eval_cx < ' a , ' mir , ' tcx > (
45
45
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
46
+ span : Span ,
46
47
param_env : ty:: ParamEnv < ' tcx > ,
47
48
) -> CompileTimeEvalContext < ' a , ' mir , ' tcx > {
48
49
debug ! ( "mk_eval_cx: {:?}" , param_env) ;
49
- EvalContext :: new ( tcx. at ( DUMMY_SP ) , param_env, CompileTimeInterpreter :: new ( ) )
50
+ EvalContext :: new ( tcx. at ( span ) , param_env, CompileTimeInterpreter :: new ( ) )
50
51
}
51
52
52
53
pub ( crate ) fn eval_promoted < ' a , ' mir , ' tcx > (
@@ -55,7 +56,8 @@ pub(crate) fn eval_promoted<'a, 'mir, 'tcx>(
55
56
mir : & ' mir mir:: Mir < ' tcx > ,
56
57
param_env : ty:: ParamEnv < ' tcx > ,
57
58
) -> EvalResult < ' tcx , MPlaceTy < ' tcx > > {
58
- let mut ecx = mk_eval_cx ( tcx, param_env) ;
59
+ let span = tcx. def_span ( cid. instance . def_id ( ) ) ;
60
+ let mut ecx = mk_eval_cx ( tcx, span, param_env) ;
59
61
eval_body_using_ecx ( & mut ecx, cid, Some ( mir) , param_env)
60
62
}
61
63
@@ -481,7 +483,7 @@ pub fn const_field<'a, 'tcx>(
481
483
value : ty:: Const < ' tcx > ,
482
484
) -> :: rustc:: mir:: interpret:: ConstEvalResult < ' tcx > {
483
485
trace ! ( "const_field: {:?}, {:?}" , field, value) ;
484
- let ecx = mk_eval_cx ( tcx, param_env) ;
486
+ let ecx = mk_eval_cx ( tcx, DUMMY_SP , param_env) ;
485
487
let result = ( || {
486
488
// get the operand again
487
489
let op = lazy_const_to_op ( & ecx, ty:: LazyConst :: Evaluated ( value) , value. ty ) ?;
@@ -509,7 +511,7 @@ pub fn const_variant_index<'a, 'tcx>(
509
511
val : ty:: Const < ' tcx > ,
510
512
) -> EvalResult < ' tcx , VariantIdx > {
511
513
trace ! ( "const_variant_index: {:?}" , val) ;
512
- let ecx = mk_eval_cx ( tcx, param_env) ;
514
+ let ecx = mk_eval_cx ( tcx, DUMMY_SP , param_env) ;
513
515
let op = lazy_const_to_op ( & ecx, ty:: LazyConst :: Evaluated ( val) , val. ty ) ?;
514
516
Ok ( ecx. read_discriminant ( op) ?. 1 )
515
517
}
@@ -529,7 +531,7 @@ fn validate_and_turn_into_const<'a, 'tcx>(
529
531
key : ty:: ParamEnvAnd < ' tcx , GlobalId < ' tcx > > ,
530
532
) -> :: rustc:: mir:: interpret:: ConstEvalResult < ' tcx > {
531
533
let cid = key. value ;
532
- let ecx = mk_eval_cx ( tcx, key. param_env ) ;
534
+ let ecx = mk_eval_cx ( tcx, tcx . def_span ( key . value . instance . def_id ( ) ) , key. param_env ) ;
533
535
let val = ( || {
534
536
let op = ecx. raw_const_to_mplace ( constant) ?. into ( ) ;
535
537
// FIXME: Once the visitor infrastructure landed, change validation to
0 commit comments