diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-02-15 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-02-16 23:52:05 +0100 |
| commit | d06a2a368df2d15cd4e9c3e1c3e8c86727307502 (patch) | |
| tree | 2d0f2397b7229f5eb8156ea5d7a1524dc688db3d /compiler/rustc_mir/src/const_eval | |
| parent | 5888556efe102f855f273cd1a7b343fe08d8fc76 (diff) | |
| download | rust-d06a2a368df2d15cd4e9c3e1c3e8c86727307502.tar.gz rust-d06a2a368df2d15cd4e9c3e1c3e8c86727307502.zip | |
Pass MPlaceTy by reference not value
Diffstat (limited to 'compiler/rustc_mir/src/const_eval')
| -rw-r--r-- | compiler/rustc_mir/src/const_eval/eval_queries.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_mir/src/const_eval/machine.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_mir/src/const_eval/mod.rs | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/compiler/rustc_mir/src/const_eval/eval_queries.rs b/compiler/rustc_mir/src/const_eval/eval_queries.rs index 9a2e659678d..e9a0742d493 100644 --- a/compiler/rustc_mir/src/const_eval/eval_queries.rs +++ b/compiler/rustc_mir/src/const_eval/eval_queries.rs @@ -72,7 +72,7 @@ fn eval_body_using_ecx<'mir, 'tcx>( None => InternKind::Constant, } }; - intern_const_alloc_recursive(ecx, intern_kind, ret)?; + intern_const_alloc_recursive(ecx, intern_kind, &ret)?; debug!("eval_body_using_ecx done: {:?}", *ret); Ok(ret) @@ -137,7 +137,7 @@ pub(super) fn op_to_const<'tcx>( op.try_as_mplace(ecx) }; - let to_const_value = |mplace: MPlaceTy<'_>| match mplace.ptr { + let to_const_value = |mplace: &MPlaceTy<'_>| match mplace.ptr { Scalar::Ptr(ptr) => { let alloc = ecx.tcx.global_alloc(ptr.alloc_id).unwrap_memory(); ConstValue::ByRef { alloc, offset: ptr.offset } @@ -155,12 +155,12 @@ pub(super) fn op_to_const<'tcx>( } }; match immediate { - Ok(mplace) => to_const_value(mplace), + Ok(ref mplace) => to_const_value(mplace), // see comment on `let try_as_immediate` above Err(imm) => match *imm { Immediate::Scalar(x) => match x { ScalarMaybeUninit::Scalar(s) => ConstValue::Scalar(s), - ScalarMaybeUninit::Uninit => to_const_value(op.assert_mem_place(ecx)), + ScalarMaybeUninit::Uninit => to_const_value(&op.assert_mem_place(ecx)), }, Immediate::ScalarPair(a, b) => { let (data, start) = match a.check_init().unwrap() { diff --git a/compiler/rustc_mir/src/const_eval/machine.rs b/compiler/rustc_mir/src/const_eval/machine.rs index 70548c583d6..14b67fe1194 100644 --- a/compiler/rustc_mir/src/const_eval/machine.rs +++ b/compiler/rustc_mir/src/const_eval/machine.rs @@ -40,7 +40,7 @@ impl<'mir, 'tcx> InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>> { assert!(args.len() == 1); let msg_place = self.deref_operand(&args[0])?; - let msg = Symbol::intern(self.read_str(msg_place)?); + let msg = Symbol::intern(self.read_str(&msg_place)?); let span = self.find_closest_untracked_caller_location(); let (file, line, col) = self.location_triple_for_span(span); Err(ConstEvalErrKind::Panic { msg, file, line, col }.into()) diff --git a/compiler/rustc_mir/src/const_eval/mod.rs b/compiler/rustc_mir/src/const_eval/mod.rs index 480489c9bc0..a4e1cd2faa3 100644 --- a/compiler/rustc_mir/src/const_eval/mod.rs +++ b/compiler/rustc_mir/src/const_eval/mod.rs @@ -29,7 +29,7 @@ pub(crate) fn const_caller_location( let mut ecx = mk_eval_cx(tcx, DUMMY_SP, ty::ParamEnv::reveal_all(), false); let loc_place = ecx.alloc_caller_location(file, line, col); - if intern_const_alloc_recursive(&mut ecx, InternKind::Constant, loc_place).is_err() { + if intern_const_alloc_recursive(&mut ecx, InternKind::Constant, &loc_place).is_err() { bug!("intern_const_alloc_recursive should not error in this case") } ConstValue::Scalar(loc_place.ptr) |
