@@ -100,8 +100,7 @@ use syntax::parse::token::InternedString;
100
100
use syntax:: attr:: AttrMetaMethods ;
101
101
use syntax:: attr;
102
102
use rustc_front;
103
- use rustc_front:: visit:: Visitor ;
104
- use rustc_front:: visit;
103
+ use rustc_front:: intravisit:: { self , Visitor } ;
105
104
use rustc_front:: hir;
106
105
use syntax:: ast;
107
106
@@ -1300,7 +1299,7 @@ impl<'v> Visitor<'v> for FindNestedReturn {
1300
1299
hir:: ExprRet ( ..) => {
1301
1300
self . found = true ;
1302
1301
}
1303
- _ => visit :: walk_expr ( self , e)
1302
+ _ => intravisit :: walk_expr ( self , e)
1304
1303
}
1305
1304
}
1306
1305
}
@@ -1369,7 +1368,7 @@ fn has_nested_returns(tcx: &ty::ctxt, cfg: &cfg::CFG, blk_id: ast::NodeId) -> bo
1369
1368
Some ( hir_map:: NodeExpr ( ex) ) => {
1370
1369
if let hir:: ExprRet ( Some ( ref ret_expr) ) = ex. node {
1371
1370
let mut visitor = FindNestedReturn :: new ( ) ;
1372
- visit :: walk_expr ( & mut visitor, & * * ret_expr) ;
1371
+ intravisit :: walk_expr ( & mut visitor, & * * ret_expr) ;
1373
1372
if visitor. found {
1374
1373
return true ;
1375
1374
}
@@ -2302,11 +2301,6 @@ pub fn trans_item(ccx: &CrateContext, item: &hir::Item) {
2302
2301
}
2303
2302
}
2304
2303
}
2305
-
2306
- // Be sure to travel more than just one layer deep to catch nested
2307
- // items in blocks and such.
2308
- let mut v = TransItemVisitor { ccx : ccx } ;
2309
- v. visit_block ( & * * body) ;
2310
2304
}
2311
2305
hir:: ItemImpl ( _, _, ref generics, _, _, ref impl_items) => {
2312
2306
meth:: trans_impl ( ccx,
@@ -2315,8 +2309,9 @@ pub fn trans_item(ccx: &CrateContext, item: &hir::Item) {
2315
2309
generics,
2316
2310
item. id ) ;
2317
2311
}
2318
- hir:: ItemMod ( ref m) => {
2319
- trans_mod ( & ccx. rotate ( ) , m) ;
2312
+ hir:: ItemMod ( _) => {
2313
+ // modules have no equivalent at runtime, they just affect
2314
+ // the mangled names of things contained within
2320
2315
}
2321
2316
hir:: ItemEnum ( ref enum_definition, ref gens) => {
2322
2317
if gens. ty_params . is_empty ( ) {
@@ -2325,16 +2320,9 @@ pub fn trans_item(ccx: &CrateContext, item: &hir::Item) {
2325
2320
enum_variant_size_lint ( ccx, enum_definition, item. span , item. id ) ;
2326
2321
}
2327
2322
}
2328
- hir:: ItemConst ( _, ref expr) => {
2329
- // Recurse on the expression to catch items in blocks
2330
- let mut v = TransItemVisitor { ccx : ccx } ;
2331
- v. visit_expr ( & * * expr) ;
2323
+ hir:: ItemConst ( ..) => {
2332
2324
}
2333
2325
hir:: ItemStatic ( _, m, ref expr) => {
2334
- // Recurse on the expression to catch items in blocks
2335
- let mut v = TransItemVisitor { ccx : ccx } ;
2336
- v. visit_expr ( & * * expr) ;
2337
-
2338
2326
let g = match consts:: trans_static ( ccx, m, expr, item. id , & item. attrs ) {
2339
2327
Ok ( g) => g,
2340
2328
Err ( err) => ccx. tcx ( ) . sess . span_fatal ( expr. span , & err. description ( ) ) ,
@@ -2346,30 +2334,11 @@ pub fn trans_item(ccx: &CrateContext, item: &hir::Item) {
2346
2334
foreign:: trans_foreign_mod ( ccx, foreign_mod) ;
2347
2335
}
2348
2336
hir:: ItemTrait ( ..) => {
2349
- // Inside of this trait definition, we won't be actually translating any
2350
- // functions, but the trait still needs to be walked. Otherwise default
2351
- // methods with items will not get translated and will cause ICE's when
2352
- // metadata time comes around.
2353
- let mut v = TransItemVisitor { ccx : ccx } ;
2354
- visit:: walk_item ( & mut v, item) ;
2355
2337
}
2356
2338
_ => { /* fall through */ }
2357
2339
}
2358
2340
}
2359
2341
2360
- // Translate a module. Doing this amounts to translating the items in the
2361
- // module; there ends up being no artifact (aside from linkage names) of
2362
- // separate modules in the compiled program. That's because modules exist
2363
- // only as a convenience for humans working with the code, to organize names
2364
- // and control visibility.
2365
- pub fn trans_mod ( ccx : & CrateContext , m : & hir:: Mod ) {
2366
- let _icx = push_ctxt ( "trans_mod" ) ;
2367
- for item in & m. items {
2368
- trans_item ( ccx, & * * item) ;
2369
- }
2370
- }
2371
-
2372
-
2373
2342
// only use this for foreign function ABIs and glue, use `register_fn` for Rust functions
2374
2343
pub fn register_fn_llvmty ( ccx : & CrateContext ,
2375
2344
sp : Span ,
@@ -2994,10 +2963,10 @@ pub fn trans_crate<'tcx>(tcx: &ty::ctxt<'tcx>,
2994
2963
// First, verify intrinsics.
2995
2964
intrinsic:: check_intrinsics ( & ccx) ;
2996
2965
2997
- // Next, translate the module .
2966
+ // Next, translate all items .
2998
2967
{
2999
2968
let _icx = push_ctxt ( "text" ) ;
3000
- trans_mod ( & ccx, & krate . module ) ;
2969
+ krate . visit_all_items ( & mut TransItemVisitor { ccx : & ccx } ) ;
3001
2970
}
3002
2971
}
3003
2972
0 commit comments