Skip to content

Commit 3522d48

Browse files
committed
Don't require owned data in MaybeStorageLive
1 parent 109cccb commit 3522d48

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

compiler/rustc_const_eval/src/transform/validate.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'tcx> MirPass<'tcx> for Validator {
5252
};
5353

5454
let always_live_locals = always_storage_live_locals(body);
55-
let storage_liveness = MaybeStorageLive::new(always_live_locals)
55+
let storage_liveness = MaybeStorageLive::new(std::borrow::Cow::Owned(always_live_locals))
5656
.into_engine(tcx, body)
5757
.iterate_to_fixpoint()
5858
.into_results_cursor(body);
@@ -79,7 +79,7 @@ struct TypeChecker<'a, 'tcx> {
7979
param_env: ParamEnv<'tcx>,
8080
mir_phase: MirPhase,
8181
reachable_blocks: BitSet<BasicBlock>,
82-
storage_liveness: ResultsCursor<'a, 'tcx, MaybeStorageLive>,
82+
storage_liveness: ResultsCursor<'a, 'tcx, MaybeStorageLive<'static>>,
8383
place_cache: Vec<PlaceRef<'tcx>>,
8484
value_cache: Vec<u128>,
8585
}

compiler/rustc_mir_dataflow/src/impls/storage_liveness.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@ pub use super::*;
33
use crate::{CallReturnPlaces, GenKill, Results, ResultsRefCursor};
44
use rustc_middle::mir::visit::{NonMutatingUseContext, PlaceContext, Visitor};
55
use rustc_middle::mir::*;
6+
use std::borrow::Cow;
67
use std::cell::RefCell;
78

89
#[derive(Clone)]
9-
pub struct MaybeStorageLive {
10-
always_live_locals: BitSet<Local>,
10+
pub struct MaybeStorageLive<'a> {
11+
always_live_locals: Cow<'a, BitSet<Local>>,
1112
}
1213

13-
impl MaybeStorageLive {
14-
pub fn new(always_live_locals: BitSet<Local>) -> Self {
14+
impl<'a> MaybeStorageLive<'a> {
15+
pub fn new(always_live_locals: Cow<'a, BitSet<Local>>) -> Self {
1516
MaybeStorageLive { always_live_locals }
1617
}
1718
}
1819

19-
impl<'tcx> crate::AnalysisDomain<'tcx> for MaybeStorageLive {
20+
impl<'tcx, 'a> crate::AnalysisDomain<'tcx> for MaybeStorageLive<'a> {
2021
type Domain = BitSet<Local>;
2122

2223
const NAME: &'static str = "maybe_storage_live";
@@ -38,7 +39,7 @@ impl<'tcx> crate::AnalysisDomain<'tcx> for MaybeStorageLive {
3839
}
3940
}
4041

41-
impl<'tcx> crate::GenKillAnalysis<'tcx> for MaybeStorageLive {
42+
impl<'tcx, 'a> crate::GenKillAnalysis<'tcx> for MaybeStorageLive<'a> {
4243
type Idx = Local;
4344

4445
fn statement_effect(

compiler/rustc_mir_transform/src/generator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ fn locals_live_across_suspend_points<'tcx>(
490490

491491
// Calculate when MIR locals have live storage. This gives us an upper bound of their
492492
// lifetimes.
493-
let mut storage_live = MaybeStorageLive::new(always_live_locals.clone())
493+
let mut storage_live = MaybeStorageLive::new(std::borrow::Cow::Borrowed(always_live_locals))
494494
.into_engine(tcx, body_ref)
495495
.iterate_to_fixpoint()
496496
.into_results_cursor(body_ref);

0 commit comments

Comments
 (0)