Skip to content

Commit 87bef92

Browse files
committed
Span fixup
1 parent 21a0652 commit 87bef92

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/librustc_mir/const_eval.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_data_structures::fx::FxHashMap;
1818
use rustc::util::common::ErrorReported;
1919

2020
use syntax::ast::Mutability;
21-
use syntax::source_map::DUMMY_SP;
21+
use syntax::source_map::{Span, DUMMY_SP};
2222

2323
use 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.
4545
pub(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

5354
pub(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

src/librustc_mir/transform/const_prop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
110110
source: MirSource,
111111
) -> ConstPropagator<'a, 'mir, 'tcx> {
112112
let param_env = tcx.param_env(source.def_id);
113-
let ecx = mk_eval_cx(tcx, param_env);
113+
let ecx = mk_eval_cx(tcx, tcx.def_span(source.def_id), param_env);
114114
ConstPropagator {
115115
ecx,
116116
mir,

0 commit comments

Comments
 (0)