@@ -37,12 +37,14 @@ use std::cell::RefCell;
3737use std:: cmp;
3838use std:: mem;
3939use syntax:: ast_util:: IdVisitingOperation ;
40- use syntax :: attr:: AttrMetaMethods ;
41- use syntax :: attr ;
40+ use rustc_front :: attr:: { self , AttrMetaMethods } ;
41+ use rustc_front :: util ;
4242use syntax:: codemap:: Span ;
43- use syntax:: visit:: { Visitor , FnKind } ;
4443use syntax:: parse:: token:: InternedString ;
45- use syntax:: { ast, ast_util, visit} ;
44+ use syntax:: ast;
45+ use rustc_front:: hir;
46+ use rustc_front:: visit:: { self , Visitor , FnKind } ;
47+ use syntax:: visit:: Visitor as SyntaxVisitor ;
4648use syntax:: diagnostic;
4749
4850/// Information about the registered lints.
@@ -252,7 +254,7 @@ pub struct Context<'a, 'tcx: 'a> {
252254 pub tcx : & ' a ty:: ctxt < ' tcx > ,
253255
254256 /// The crate being checked.
255- pub krate : & ' a ast :: Crate ,
257+ pub krate : & ' a hir :: Crate ,
256258
257259 /// Items exported from the crate being checked.
258260 pub exported_items : & ' a ExportedItems ,
@@ -284,7 +286,7 @@ macro_rules! run_lints { ($cx:expr, $f:ident, $($args:expr),*) => ({
284286/// Parse the lint attributes into a vector, with `Err`s for malformed lint
285287/// attributes. Writing this as an iterator is an enormous mess.
286288// See also the hir version just below.
287- pub fn gather_attrs ( attrs : & [ ast :: Attribute ] )
289+ pub fn gather_attrs ( attrs : & [ hir :: Attribute ] )
288290 -> Vec < Result < ( InternedString , Level , Span ) , Span > > {
289291 let mut out = vec ! ( ) ;
290292 for attr in attrs {
@@ -297,7 +299,7 @@ pub fn gather_attrs(attrs: &[ast::Attribute])
297299
298300 let meta = & attr. node . value ;
299301 let metas = match meta. node {
300- ast :: MetaList ( _, ref metas) => metas,
302+ hir :: MetaList ( _, ref metas) => metas,
301303 _ => {
302304 out. push ( Err ( meta. span ) ) ;
303305 continue ;
@@ -306,7 +308,7 @@ pub fn gather_attrs(attrs: &[ast::Attribute])
306308
307309 for meta in metas {
308310 out. push ( match meta. node {
309- ast :: MetaWord ( ref lint_name) => Ok ( ( lint_name. clone ( ) , level, meta. span ) ) ,
311+ hir :: MetaWord ( ref lint_name) => Ok ( ( lint_name. clone ( ) , level, meta. span ) ) ,
310312 _ => Err ( meta. span ) ,
311313 } ) ;
312314 }
@@ -398,7 +400,7 @@ pub fn raw_emit_lint(sess: &Session, lint: &'static Lint,
398400
399401impl < ' a , ' tcx > Context < ' a , ' tcx > {
400402 fn new ( tcx : & ' a ty:: ctxt < ' tcx > ,
401- krate : & ' a ast :: Crate ,
403+ krate : & ' a hir :: Crate ,
402404 exported_items : & ' a ExportedItems ) -> Context < ' a , ' tcx > {
403405 // We want to own the lint store, so move it out of the session.
404406 let lint_store = mem:: replace ( & mut * tcx. sess . lint_store . borrow_mut ( ) ,
@@ -452,7 +454,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
452454 /// current lint context, call the provided function, then reset the
453455 /// lints in effect to their previous state.
454456 fn with_lint_attrs < F > ( & mut self ,
455- attrs : & [ ast :: Attribute ] ,
457+ attrs : & [ hir :: Attribute ] ,
456458 f : F ) where
457459 F : FnOnce ( & mut Context ) ,
458460 {
@@ -519,9 +521,9 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
519521 }
520522
521523 fn visit_ids < F > ( & mut self , f : F ) where
522- F : FnOnce ( & mut ast_util :: IdVisitor < Context > )
524+ F : FnOnce ( & mut util :: IdVisitor < Context > )
523525 {
524- let mut v = ast_util :: IdVisitor {
526+ let mut v = util :: IdVisitor {
525527 operation : self ,
526528 pass_through_items : false ,
527529 visited_outermost : false ,
@@ -531,68 +533,68 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
531533}
532534
533535impl < ' a , ' tcx , ' v > Visitor < ' v > for Context < ' a , ' tcx > {
534- fn visit_item ( & mut self , it : & ast :: Item ) {
536+ fn visit_item ( & mut self , it : & hir :: Item ) {
535537 self . with_lint_attrs ( & it. attrs , |cx| {
536538 run_lints ! ( cx, check_item, it) ;
537539 cx. visit_ids ( |v| v. visit_item ( it) ) ;
538540 visit:: walk_item ( cx, it) ;
539541 } )
540542 }
541543
542- fn visit_foreign_item ( & mut self , it : & ast :: ForeignItem ) {
544+ fn visit_foreign_item ( & mut self , it : & hir :: ForeignItem ) {
543545 self . with_lint_attrs ( & it. attrs , |cx| {
544546 run_lints ! ( cx, check_foreign_item, it) ;
545547 visit:: walk_foreign_item ( cx, it) ;
546548 } )
547549 }
548550
549- fn visit_pat ( & mut self , p : & ast :: Pat ) {
551+ fn visit_pat ( & mut self , p : & hir :: Pat ) {
550552 run_lints ! ( self , check_pat, p) ;
551553 visit:: walk_pat ( self , p) ;
552554 }
553555
554- fn visit_expr ( & mut self , e : & ast :: Expr ) {
556+ fn visit_expr ( & mut self , e : & hir :: Expr ) {
555557 run_lints ! ( self , check_expr, e) ;
556558 visit:: walk_expr ( self , e) ;
557559 }
558560
559- fn visit_stmt ( & mut self , s : & ast :: Stmt ) {
561+ fn visit_stmt ( & mut self , s : & hir :: Stmt ) {
560562 run_lints ! ( self , check_stmt, s) ;
561563 visit:: walk_stmt ( self , s) ;
562564 }
563565
564- fn visit_fn ( & mut self , fk : FnKind < ' v > , decl : & ' v ast :: FnDecl ,
565- body : & ' v ast :: Block , span : Span , id : ast:: NodeId ) {
566+ fn visit_fn ( & mut self , fk : FnKind < ' v > , decl : & ' v hir :: FnDecl ,
567+ body : & ' v hir :: Block , span : Span , id : ast:: NodeId ) {
566568 run_lints ! ( self , check_fn, fk, decl, body, span, id) ;
567569 visit:: walk_fn ( self , fk, decl, body, span) ;
568570 }
569571
570572 fn visit_struct_def ( & mut self ,
571- s : & ast :: StructDef ,
573+ s : & hir :: StructDef ,
572574 ident : ast:: Ident ,
573- g : & ast :: Generics ,
575+ g : & hir :: Generics ,
574576 id : ast:: NodeId ) {
575577 run_lints ! ( self , check_struct_def, s, ident, g, id) ;
576578 visit:: walk_struct_def ( self , s) ;
577579 run_lints ! ( self , check_struct_def_post, s, ident, g, id) ;
578580 }
579581
580- fn visit_struct_field ( & mut self , s : & ast :: StructField ) {
582+ fn visit_struct_field ( & mut self , s : & hir :: StructField ) {
581583 self . with_lint_attrs ( & s. node . attrs , |cx| {
582584 run_lints ! ( cx, check_struct_field, s) ;
583585 visit:: walk_struct_field ( cx, s) ;
584586 } )
585587 }
586588
587- fn visit_variant ( & mut self , v : & ast :: Variant , g : & ast :: Generics ) {
589+ fn visit_variant ( & mut self , v : & hir :: Variant , g : & hir :: Generics ) {
588590 self . with_lint_attrs ( & v. node . attrs , |cx| {
589591 run_lints ! ( cx, check_variant, v, g) ;
590592 visit:: walk_variant ( cx, v, g) ;
591593 run_lints ! ( cx, check_variant_post, v, g) ;
592594 } )
593595 }
594596
595- fn visit_ty ( & mut self , t : & ast :: Ty ) {
597+ fn visit_ty ( & mut self , t : & hir :: Ty ) {
596598 run_lints ! ( self , check_ty, t) ;
597599 visit:: walk_ty ( self , t) ;
598600 }
@@ -601,84 +603,79 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
601603 run_lints ! ( self , check_ident, sp, id) ;
602604 }
603605
604- fn visit_mod ( & mut self , m : & ast :: Mod , s : Span , n : ast:: NodeId ) {
606+ fn visit_mod ( & mut self , m : & hir :: Mod , s : Span , n : ast:: NodeId ) {
605607 run_lints ! ( self , check_mod, m, s, n) ;
606608 visit:: walk_mod ( self , m) ;
607609 }
608610
609- fn visit_local ( & mut self , l : & ast :: Local ) {
611+ fn visit_local ( & mut self , l : & hir :: Local ) {
610612 run_lints ! ( self , check_local, l) ;
611613 visit:: walk_local ( self , l) ;
612614 }
613615
614- fn visit_block ( & mut self , b : & ast :: Block ) {
616+ fn visit_block ( & mut self , b : & hir :: Block ) {
615617 run_lints ! ( self , check_block, b) ;
616618 visit:: walk_block ( self , b) ;
617619 }
618620
619- fn visit_arm ( & mut self , a : & ast :: Arm ) {
621+ fn visit_arm ( & mut self , a : & hir :: Arm ) {
620622 run_lints ! ( self , check_arm, a) ;
621623 visit:: walk_arm ( self , a) ;
622624 }
623625
624- fn visit_decl ( & mut self , d : & ast :: Decl ) {
626+ fn visit_decl ( & mut self , d : & hir :: Decl ) {
625627 run_lints ! ( self , check_decl, d) ;
626628 visit:: walk_decl ( self , d) ;
627629 }
628630
629- fn visit_expr_post ( & mut self , e : & ast :: Expr ) {
631+ fn visit_expr_post ( & mut self , e : & hir :: Expr ) {
630632 run_lints ! ( self , check_expr_post, e) ;
631633 }
632634
633- fn visit_generics ( & mut self , g : & ast :: Generics ) {
635+ fn visit_generics ( & mut self , g : & hir :: Generics ) {
634636 run_lints ! ( self , check_generics, g) ;
635637 visit:: walk_generics ( self , g) ;
636638 }
637639
638- fn visit_trait_item ( & mut self , trait_item : & ast :: TraitItem ) {
640+ fn visit_trait_item ( & mut self , trait_item : & hir :: TraitItem ) {
639641 self . with_lint_attrs ( & trait_item. attrs , |cx| {
640642 run_lints ! ( cx, check_trait_item, trait_item) ;
641643 cx. visit_ids ( |v| v. visit_trait_item ( trait_item) ) ;
642644 visit:: walk_trait_item ( cx, trait_item) ;
643645 } ) ;
644646 }
645647
646- fn visit_impl_item ( & mut self , impl_item : & ast :: ImplItem ) {
648+ fn visit_impl_item ( & mut self , impl_item : & hir :: ImplItem ) {
647649 self . with_lint_attrs ( & impl_item. attrs , |cx| {
648650 run_lints ! ( cx, check_impl_item, impl_item) ;
649651 cx. visit_ids ( |v| v. visit_impl_item ( impl_item) ) ;
650652 visit:: walk_impl_item ( cx, impl_item) ;
651653 } ) ;
652654 }
653655
654- fn visit_opt_lifetime_ref ( & mut self , sp : Span , lt : & Option < ast :: Lifetime > ) {
656+ fn visit_opt_lifetime_ref ( & mut self , sp : Span , lt : & Option < hir :: Lifetime > ) {
655657 run_lints ! ( self , check_opt_lifetime_ref, sp, lt) ;
656658 }
657659
658- fn visit_lifetime_ref ( & mut self , lt : & ast :: Lifetime ) {
660+ fn visit_lifetime_ref ( & mut self , lt : & hir :: Lifetime ) {
659661 run_lints ! ( self , check_lifetime_ref, lt) ;
660662 }
661663
662- fn visit_lifetime_def ( & mut self , lt : & ast :: LifetimeDef ) {
664+ fn visit_lifetime_def ( & mut self , lt : & hir :: LifetimeDef ) {
663665 run_lints ! ( self , check_lifetime_def, lt) ;
664666 }
665667
666- fn visit_explicit_self ( & mut self , es : & ast :: ExplicitSelf ) {
668+ fn visit_explicit_self ( & mut self , es : & hir :: ExplicitSelf ) {
667669 run_lints ! ( self , check_explicit_self, es) ;
668670 visit:: walk_explicit_self ( self , es) ;
669671 }
670672
671- fn visit_mac ( & mut self , mac : & ast:: Mac ) {
672- run_lints ! ( self , check_mac, mac) ;
673- visit:: walk_mac ( self , mac) ;
674- }
675-
676- fn visit_path ( & mut self , p : & ast:: Path , id : ast:: NodeId ) {
673+ fn visit_path ( & mut self , p : & hir:: Path , id : ast:: NodeId ) {
677674 run_lints ! ( self , check_path, p, id) ;
678675 visit:: walk_path ( self , p) ;
679676 }
680677
681- fn visit_attribute ( & mut self , attr : & ast :: Attribute ) {
678+ fn visit_attribute ( & mut self , attr : & hir :: Attribute ) {
682679 run_lints ! ( self , check_attribute, attr) ;
683680 }
684681}
@@ -709,9 +706,9 @@ impl LintPass for GatherNodeLevels {
709706 lint_array ! ( )
710707 }
711708
712- fn check_item ( & mut self , cx : & Context , it : & ast :: Item ) {
709+ fn check_item ( & mut self , cx : & Context , it : & hir :: Item ) {
713710 match it. node {
714- ast :: ItemEnum ( ..) => {
711+ hir :: ItemEnum ( ..) => {
715712 let lint_id = LintId :: of ( builtin:: VARIANT_SIZE_DIFFERENCES ) ;
716713 let lvlsrc = cx. lints . get_level_source ( lint_id) ;
717714 match lvlsrc {
@@ -731,7 +728,7 @@ impl LintPass for GatherNodeLevels {
731728///
732729/// Consumes the `lint_store` field of the `Session`.
733730pub fn check_crate ( tcx : & ty:: ctxt ,
734- krate : & ast :: Crate ,
731+ krate : & hir :: Crate ,
735732 exported_items : & ExportedItems ) {
736733
737734 let mut cx = Context :: new ( tcx, krate, exported_items) ;
0 commit comments