Skip to content
/ rust Public
forked from rust-lang/rust

Commit 8281a54

Browse files
authored
Rollup merge of rust-lang#139961 - nnethercote:two-rustc_const_eval-cleanups, r=oli-obk
Two `rustc_const_eval` cleanups r? ``@lcnr``
2 parents 7a4525c + 99a60eb commit 8281a54

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

compiler/rustc_const_eval/src/check_consts/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::check_consts::is_fn_or_trait_safe_to_expose_on_stable;
3434
use crate::errors;
3535

3636
type QualifResults<'mir, 'tcx, Q> =
37-
rustc_mir_dataflow::ResultsCursor<'mir, 'tcx, FlowSensitiveAnalysis<'mir, 'mir, 'tcx, Q>>;
37+
rustc_mir_dataflow::ResultsCursor<'mir, 'tcx, FlowSensitiveAnalysis<'mir, 'tcx, Q>>;
3838

3939
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
4040
enum ConstConditionsHold {

compiler/rustc_const_eval/src/check_consts/resolver.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ use super::{ConstCx, Qualif, qualifs};
2222
/// qualified immediately after it is borrowed or its address escapes. The borrow must allow for
2323
/// mutation, which includes shared borrows of places with interior mutability. The type of
2424
/// borrowed place must contain the qualif.
25-
struct TransferFunction<'a, 'mir, 'tcx, Q> {
26-
ccx: &'a ConstCx<'mir, 'tcx>,
27-
state: &'a mut State,
25+
struct TransferFunction<'mir, 'tcx, Q> {
26+
ccx: &'mir ConstCx<'mir, 'tcx>,
27+
state: &'mir mut State,
2828
_qualif: PhantomData<Q>,
2929
}
3030

31-
impl<'a, 'mir, 'tcx, Q> TransferFunction<'a, 'mir, 'tcx, Q>
31+
impl<'mir, 'tcx, Q> TransferFunction<'mir, 'tcx, Q>
3232
where
3333
Q: Qualif,
3434
{
35-
fn new(ccx: &'a ConstCx<'mir, 'tcx>, state: &'a mut State) -> Self {
35+
fn new(ccx: &'mir ConstCx<'mir, 'tcx>, state: &'mir mut State) -> Self {
3636
TransferFunction { ccx, state, _qualif: PhantomData }
3737
}
3838

@@ -124,7 +124,7 @@ where
124124
}
125125
}
126126

127-
impl<'tcx, Q> Visitor<'tcx> for TransferFunction<'_, '_, 'tcx, Q>
127+
impl<'tcx, Q> Visitor<'tcx> for TransferFunction<'_, 'tcx, Q>
128128
where
129129
Q: Qualif,
130130
{
@@ -228,20 +228,20 @@ where
228228
}
229229

230230
/// The dataflow analysis used to propagate qualifs on arbitrary CFGs.
231-
pub(super) struct FlowSensitiveAnalysis<'a, 'mir, 'tcx, Q> {
232-
ccx: &'a ConstCx<'mir, 'tcx>,
231+
pub(super) struct FlowSensitiveAnalysis<'mir, 'tcx, Q> {
232+
ccx: &'mir ConstCx<'mir, 'tcx>,
233233
_qualif: PhantomData<Q>,
234234
}
235235

236-
impl<'a, 'mir, 'tcx, Q> FlowSensitiveAnalysis<'a, 'mir, 'tcx, Q>
236+
impl<'mir, 'tcx, Q> FlowSensitiveAnalysis<'mir, 'tcx, Q>
237237
where
238238
Q: Qualif,
239239
{
240-
pub(super) fn new(_: Q, ccx: &'a ConstCx<'mir, 'tcx>) -> Self {
240+
pub(super) fn new(_: Q, ccx: &'mir ConstCx<'mir, 'tcx>) -> Self {
241241
FlowSensitiveAnalysis { ccx, _qualif: PhantomData }
242242
}
243243

244-
fn transfer_function(&self, state: &'a mut State) -> TransferFunction<'a, 'mir, 'tcx, Q> {
244+
fn transfer_function(&self, state: &'mir mut State) -> TransferFunction<'mir, 'tcx, Q> {
245245
TransferFunction::<Q>::new(self.ccx, state)
246246
}
247247
}
@@ -313,7 +313,7 @@ impl JoinSemiLattice for State {
313313
}
314314
}
315315

316-
impl<'tcx, Q> Analysis<'tcx> for FlowSensitiveAnalysis<'_, '_, 'tcx, Q>
316+
impl<'tcx, Q> Analysis<'tcx> for FlowSensitiveAnalysis<'_, 'tcx, Q>
317317
where
318318
Q: Qualif,
319319
{

compiler/rustc_const_eval/src/interpret/intern.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use super::{
3030
AllocId, Allocation, InterpCx, MPlaceTy, Machine, MemoryKind, PlaceTy, err_ub, interp_ok,
3131
};
3232
use crate::const_eval;
33+
use crate::const_eval::DummyMachine;
3334
use crate::errors::NestedStaticInThreadLocal;
3435

3536
pub trait CompileTimeMachine<'tcx, T> = Machine<
@@ -323,14 +324,17 @@ pub fn intern_const_alloc_for_constprop<'tcx, T, M: CompileTimeMachine<'tcx, T>>
323324
interp_ok(())
324325
}
325326

326-
impl<'tcx, M: super::intern::CompileTimeMachine<'tcx, !>> InterpCx<'tcx, M> {
327+
impl<'tcx> InterpCx<'tcx, DummyMachine> {
327328
/// A helper function that allocates memory for the layout given and gives you access to mutate
328329
/// it. Once your own mutation code is done, the backing `Allocation` is removed from the
329330
/// current `Memory` and interned as read-only into the global memory.
330331
pub fn intern_with_temp_alloc(
331332
&mut self,
332333
layout: TyAndLayout<'tcx>,
333-
f: impl FnOnce(&mut InterpCx<'tcx, M>, &PlaceTy<'tcx, M::Provenance>) -> InterpResult<'tcx, ()>,
334+
f: impl FnOnce(
335+
&mut InterpCx<'tcx, DummyMachine>,
336+
&PlaceTy<'tcx, CtfeProvenance>,
337+
) -> InterpResult<'tcx, ()>,
334338
) -> InterpResult<'tcx, AllocId> {
335339
// `allocate` picks a fresh AllocId that we will associate with its data below.
336340
let dest = self.allocate(layout, MemoryKind::Stack)?;

0 commit comments

Comments
 (0)