Skip to content

Commit 4f2a110

Browse files
committed
Remove unneeded callback and just use the new_local value
1 parent 2b2e35b commit 4f2a110

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

src/librustc_mir/util/def_use.rs

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,10 @@ impl DefUseAnalysis {
4747
&self.info[local]
4848
}
4949

50-
fn mutate_defs_and_uses<F>(&self, local: Local, body: &mut Body<'_>, callback: F)
51-
where F: for<'a> Fn(&'a Local,
52-
PlaceContext,
53-
Location) -> Local {
50+
fn mutate_defs_and_uses(&self, local: Local, body: &mut Body<'_>, new_local: Local) {
5451
for place_use in &self.info[local].defs_and_uses {
5552
MutateUseVisitor::new(local,
56-
&callback,
53+
new_local,
5754
body).visit_location(body, place_use.location)
5855
}
5956
}
@@ -63,7 +60,7 @@ impl DefUseAnalysis {
6360
local: Local,
6461
body: &mut Body<'_>,
6562
new_local: Local) {
66-
self.mutate_defs_and_uses(local, body, |_, _, _| new_local)
63+
self.mutate_defs_and_uses(local, body, new_local)
6764
}
6865
}
6966

@@ -117,30 +114,27 @@ impl Info {
117114
}
118115
}
119116

120-
struct MutateUseVisitor<F> {
117+
struct MutateUseVisitor {
121118
query: Local,
122-
callback: F,
119+
new_local: Local,
123120
}
124121

125-
impl<F> MutateUseVisitor<F> {
126-
fn new(query: Local, callback: F, _: &Body<'_>)
127-
-> MutateUseVisitor<F>
128-
where F: for<'a> Fn(&'a Local, PlaceContext, Location) -> Local {
122+
impl MutateUseVisitor {
123+
fn new(query: Local, new_local: Local, _: &Body<'_>) -> MutateUseVisitor {
129124
MutateUseVisitor {
130125
query,
131-
callback,
126+
new_local,
132127
}
133128
}
134129
}
135130

136-
impl<F> MutVisitor<'_> for MutateUseVisitor<F>
137-
where F: for<'a> Fn(&'a Local, PlaceContext, Location) -> Local {
131+
impl MutVisitor<'_> for MutateUseVisitor {
138132
fn visit_local(&mut self,
139133
local: &mut Local,
140-
context: PlaceContext,
141-
location: Location) {
134+
_context: PlaceContext,
135+
_location: Location) {
142136
if *local == self.query {
143-
*local = (self.callback)(local, context, location)
137+
*local = self.new_local;
144138
}
145139
}
146140

@@ -153,7 +147,7 @@ impl<F> MutVisitor<'_> for MutateUseVisitor<F>
153147
let new_projection: Vec<_> = place.projection.iter().map(|elem|
154148
match elem {
155149
PlaceElem::Index(local) if *local == self.query => {
156-
PlaceElem::Index((self.callback)(&local, context, location))
150+
PlaceElem::Index(self.new_local)
157151
}
158152
_ => elem.clone(),
159153
}

0 commit comments

Comments
 (0)