Skip to content

Commit 50ac63b

Browse files
spastorinoPaul Daniel Faria
authored andcommitted
Do not move infcx, just borrow it
1 parent 6c52275 commit 50ac63b

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/librustc_mir/transform/nll/infer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl InferenceContext {
8080

8181
pub fn solve<'a, 'gcx, 'tcx>(
8282
&mut self,
83-
infcx: InferCtxt<'a, 'gcx, 'tcx>,
83+
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
8484
mir: &'a Mir<'tcx>,
8585
) -> IndexVec<InferenceErrorIndex, InferenceError>
8686
where
@@ -130,12 +130,12 @@ impl InferenceContext {
130130
}
131131

132132
struct Dfs<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> {
133-
infcx: InferCtxt<'a, 'gcx, 'tcx>,
133+
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
134134
mir: &'a Mir<'tcx>,
135135
}
136136

137137
impl<'a, 'gcx: 'tcx, 'tcx: 'a> Dfs<'a, 'gcx, 'tcx> {
138-
fn new(infcx: InferCtxt<'a, 'gcx, 'tcx>, mir: &'a Mir<'tcx>) -> Self {
138+
fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, mir: &'a Mir<'tcx>) -> Self {
139139
Self { infcx, mir }
140140
}
141141

src/librustc_mir/transform/nll/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ mod infer;
3131
struct NLLVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
3232
lookup_map: HashMap<RegionVid, Lookup>,
3333
regions: IndexVec<RegionIndex, Region>,
34-
infcx: InferCtxt<'a, 'gcx, 'tcx>,
34+
#[allow(dead_code)]
35+
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
3536
}
3637

3738
impl<'a, 'gcx, 'tcx> NLLVisitor<'a, 'gcx, 'tcx> {
38-
pub fn new(infcx: InferCtxt<'a, 'gcx, 'tcx>) -> Self {
39+
pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) -> Self {
3940
NLLVisitor {
4041
infcx,
4142
lookup_map: HashMap::new(),
@@ -150,7 +151,7 @@ impl MirPass for NLL {
150151
tcx.infer_ctxt().enter(|infcx| {
151152
// Clone mir so we can mutate it without disturbing the rest of the compiler
152153
let mut renumbered_mir = mir.clone();
153-
let mut visitor = NLLVisitor::new(infcx);
154+
let mut visitor = NLLVisitor::new(&infcx);
154155
visitor.visit_mir(&mut renumbered_mir);
155156
mir_util::dump_mir(tcx, None, "nll", &0, source, mir, |pass_where, out| {
156157
if let PassWhere::BeforeCFG = pass_where {
@@ -162,7 +163,7 @@ impl MirPass for NLL {
162163
});
163164
let (_lookup_map, regions) = visitor.into_results();
164165
let mut inference_context = InferenceContext::new(regions);
165-
inference_context.solve(infcx, &renumbered_mir);
166+
inference_context.solve(&infcx, &renumbered_mir);
166167
})
167168
}
168169
}

0 commit comments

Comments
 (0)