@@ -18,7 +18,7 @@ use rustc_data_structures::fx::FxHashMap;
1818use rustc:: util:: common:: ErrorReported ;
1919
2020use syntax:: ast:: Mutability ;
21- use syntax:: source_map:: DUMMY_SP ;
21+ use syntax:: source_map:: { Span , DUMMY_SP } ;
2222
2323use crate :: interpret:: { self ,
2424 PlaceTy , MPlaceTy , MemPlace , OpTy , Operand , Immediate , Scalar , RawConst , ConstValue , Pointer ,
@@ -44,10 +44,11 @@ const DETECTOR_SNAPSHOT_PERIOD: isize = 256;
4444/// parameter. These bounds are passed to `mk_eval_cx` via the `ParamEnv` argument.
4545pub ( crate ) fn mk_eval_cx < ' a , ' mir , ' tcx > (
4646 tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
47+ span : Span ,
4748 param_env : ty:: ParamEnv < ' tcx > ,
4849) -> CompileTimeEvalContext < ' a , ' mir , ' tcx > {
4950 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 ( ) )
5152}
5253
5354pub ( crate ) fn eval_promoted < ' a , ' mir , ' tcx > (
@@ -56,7 +57,8 @@ pub(crate) fn eval_promoted<'a, 'mir, 'tcx>(
5657 mir : & ' mir mir:: Mir < ' tcx > ,
5758 param_env : ty:: ParamEnv < ' tcx > ,
5859) -> 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) ;
6062 eval_body_using_ecx ( & mut ecx, cid, Some ( mir) , param_env)
6163}
6264
@@ -482,7 +484,7 @@ pub fn const_field<'a, 'tcx>(
482484 value : ty:: Const < ' tcx > ,
483485) -> :: rustc:: mir:: interpret:: ConstEvalResult < ' tcx > {
484486 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) ;
486488 let result = ( || {
487489 // get the operand again
488490 let op = lazy_const_to_op ( & ecx, ty:: LazyConst :: Evaluated ( value) , value. ty ) ?;
@@ -510,7 +512,7 @@ pub fn const_variant_index<'a, 'tcx>(
510512 val : ty:: Const < ' tcx > ,
511513) -> EvalResult < ' tcx , VariantIdx > {
512514 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) ;
514516 let op = lazy_const_to_op ( & ecx, ty:: LazyConst :: Evaluated ( val) , val. ty ) ?;
515517 Ok ( ecx. read_discriminant ( op) ?. 1 )
516518}
@@ -530,7 +532,7 @@ fn validate_and_turn_into_const<'a, 'tcx>(
530532 key : ty:: ParamEnvAnd < ' tcx , GlobalId < ' tcx > > ,
531533) -> :: rustc:: mir:: interpret:: ConstEvalResult < ' tcx > {
532534 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 ) ;
534536 let val = ( || {
535537 let op = ecx. raw_const_to_mplace ( constant) ?. into ( ) ;
536538 // FIXME: Once the visitor infrastructure landed, change validation to
0 commit comments