Skip to content

Commit b487775

Browse files
committed
Don't require owned data in MaybeStorageDead
1 parent 1d36e3a commit b487775

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

Diff for: compiler/rustc_mir_dataflow/src/impls/storage_liveness.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,17 @@ impl<'tcx, 'a> crate::GenKillAnalysis<'tcx> for MaybeStorageLive<'a> {
8181
}
8282

8383
#[derive(Clone)]
84-
pub struct MaybeStorageDead {
85-
always_live_locals: BitSet<Local>,
84+
pub struct MaybeStorageDead<'a> {
85+
always_live_locals: Cow<'a, BitSet<Local>>,
8686
}
8787

88-
impl MaybeStorageDead {
89-
pub fn new(always_live_locals: BitSet<Local>) -> Self {
88+
impl<'a> MaybeStorageDead<'a> {
89+
pub fn new(always_live_locals: Cow<'a, BitSet<Local>>) -> Self {
9090
MaybeStorageDead { always_live_locals }
9191
}
9292
}
9393

94-
impl<'tcx> crate::AnalysisDomain<'tcx> for MaybeStorageDead {
94+
impl<'tcx, 'a> crate::AnalysisDomain<'tcx> for MaybeStorageDead<'a> {
9595
type Domain = BitSet<Local>;
9696

9797
const NAME: &'static str = "maybe_storage_dead";
@@ -112,7 +112,7 @@ impl<'tcx> crate::AnalysisDomain<'tcx> for MaybeStorageDead {
112112
}
113113
}
114114

115-
impl<'tcx> crate::GenKillAnalysis<'tcx> for MaybeStorageDead {
115+
impl<'tcx, 'a> crate::GenKillAnalysis<'tcx> for MaybeStorageDead<'a> {
116116
type Idx = Local;
117117

118118
fn domain_size(&self, body: &Body<'tcx>) -> usize {

Diff for: compiler/rustc_mir_transform/src/ref_prop.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rustc_middle::ty::TyCtxt;
77
use rustc_mir_dataflow::impls::MaybeStorageDead;
88
use rustc_mir_dataflow::storage::always_storage_live_locals;
99
use rustc_mir_dataflow::Analysis;
10+
use std::borrow::Cow;
1011

1112
use crate::ssa::{SsaLocals, StorageLiveLocals};
1213

@@ -120,7 +121,7 @@ fn compute_replacement<'tcx>(
120121

121122
// Compute `MaybeStorageDead` dataflow to check that we only replace when the pointee is
122123
// definitely live.
123-
let mut maybe_dead = MaybeStorageDead::new(always_live_locals)
124+
let mut maybe_dead = MaybeStorageDead::new(Cow::Owned(always_live_locals))
124125
.into_engine(tcx, body)
125126
.iterate_to_fixpoint()
126127
.into_results_cursor(body);

0 commit comments

Comments
 (0)