Skip to content

Commit 2ceebf1

Browse files
committed
Fold context into TransItemVisitor.
1 parent 411dce8 commit 2ceebf1

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/librustc/middle/trans/base.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,11 +2194,13 @@ pub fn trans_enum_def(ccx: @mut CrateContext, enum_definition: &ast::enum_def,
21942194
}
21952195
}
21962196

2197-
pub struct TransItemVisitor;
2197+
pub struct TransItemVisitor {
2198+
ccx: @mut CrateContext,
2199+
}
21982200

2199-
impl Visitor<@mut CrateContext> for TransItemVisitor {
2200-
fn visit_item(&mut self, i: @ast::item, ccx: @mut CrateContext) {
2201-
trans_item(ccx, i);
2201+
impl Visitor<()> for TransItemVisitor {
2202+
fn visit_item(&mut self, i: @ast::item, _:()) {
2203+
trans_item(self.ccx, i);
22022204
}
22032205
}
22042206

@@ -2235,8 +2237,8 @@ pub fn trans_item(ccx: @mut CrateContext, item: &ast::item) {
22352237
} else {
22362238
// Be sure to travel more than just one layer deep to catch nested
22372239
// items in blocks and such.
2238-
let mut v = TransItemVisitor;
2239-
v.visit_block(body, ccx);
2240+
let mut v = TransItemVisitor{ ccx: ccx };
2241+
v.visit_block(body, ());
22402242
}
22412243
}
22422244
ast::item_impl(ref generics, _, _, ref ms) => {
@@ -2288,8 +2290,8 @@ pub fn trans_item(ccx: @mut CrateContext, item: &ast::item) {
22882290
// functions, but the trait still needs to be walked. Otherwise default
22892291
// methods with items will not get translated and will cause ICE's when
22902292
// metadata time comes around.
2291-
let mut v = TransItemVisitor;
2292-
visit::walk_item(&mut v, item, ccx);
2293+
let mut v = TransItemVisitor{ ccx: ccx };
2294+
visit::walk_item(&mut v, item, ());
22932295
}
22942296
_ => {/* fall through */ }
22952297
}

src/librustc/middle/trans/meth.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ pub fn trans_impl(ccx: @mut CrateContext,
6161
// Both here and below with generic methods, be sure to recurse and look for
6262
// items that we need to translate.
6363
if !generics.ty_params.is_empty() {
64-
let mut v = TransItemVisitor;
64+
let mut v = TransItemVisitor{ ccx: ccx };
6565
for method in methods.iter() {
66-
visit::walk_method_helper(&mut v, *method, ccx);
66+
visit::walk_method_helper(&mut v, *method, ());
6767
}
6868
return;
6969
}
@@ -80,8 +80,8 @@ pub fn trans_impl(ccx: @mut CrateContext,
8080
None,
8181
llfn);
8282
} else {
83-
let mut v = TransItemVisitor;
84-
visit::walk_method_helper(&mut v, *method, ccx);
83+
let mut v = TransItemVisitor{ ccx: ccx };
84+
visit::walk_method_helper(&mut v, *method, ());
8585
}
8686
}
8787
}

0 commit comments

Comments
 (0)