@@ -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 ,
@@ -43,10 +43,11 @@ const DETECTOR_SNAPSHOT_PERIOD: isize = 256;
4343/// parameter. These bounds are passed to `mk_eval_cx` via the `ParamEnv` argument.
4444pub ( crate ) fn mk_eval_cx < ' a , ' mir , ' tcx > (
4545 tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
46+ span : Span ,
4647 param_env : ty:: ParamEnv < ' tcx > ,
4748) -> CompileTimeEvalContext < ' a , ' mir , ' tcx > {
4849 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 ( ) )
5051}
5152
5253pub ( crate ) fn eval_promoted < ' a , ' mir , ' tcx > (
@@ -55,7 +56,8 @@ pub(crate) fn eval_promoted<'a, 'mir, 'tcx>(
5556 mir : & ' mir mir:: Mir < ' tcx > ,
5657 param_env : ty:: ParamEnv < ' tcx > ,
5758) -> 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) ;
5961 eval_body_using_ecx ( & mut ecx, cid, Some ( mir) , param_env)
6062}
6163
@@ -481,7 +483,7 @@ pub fn const_field<'a, 'tcx>(
481483 value : ty:: Const < ' tcx > ,
482484) -> :: rustc:: mir:: interpret:: ConstEvalResult < ' tcx > {
483485 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) ;
485487 let result = ( || {
486488 // get the operand again
487489 let op = lazy_const_to_op ( & ecx, ty:: LazyConst :: Evaluated ( value) , value. ty ) ?;
@@ -509,7 +511,7 @@ pub fn const_variant_index<'a, 'tcx>(
509511 val : ty:: Const < ' tcx > ,
510512) -> EvalResult < ' tcx , VariantIdx > {
511513 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) ;
513515 let op = lazy_const_to_op ( & ecx, ty:: LazyConst :: Evaluated ( val) , val. ty ) ?;
514516 Ok ( ecx. read_discriminant ( op) ?. 1 )
515517}
@@ -529,7 +531,7 @@ fn validate_and_turn_into_const<'a, 'tcx>(
529531 key : ty:: ParamEnvAnd < ' tcx , GlobalId < ' tcx > > ,
530532) -> :: rustc:: mir:: interpret:: ConstEvalResult < ' tcx > {
531533 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 ) ;
533535 let val = ( || {
534536 let op = ecx. raw_const_to_mplace ( constant) ?. into ( ) ;
535537 // FIXME: Once the visitor infrastructure landed, change validation to
0 commit comments