@@ -37,12 +37,14 @@ use std::cell::RefCell;
37
37
use std:: cmp;
38
38
use std:: mem;
39
39
use 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 ;
42
42
use syntax:: codemap:: Span ;
43
- use syntax:: visit:: { Visitor , FnKind } ;
44
43
use 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 ;
46
48
use syntax:: diagnostic;
47
49
48
50
/// Information about the registered lints.
@@ -252,7 +254,7 @@ pub struct Context<'a, 'tcx: 'a> {
252
254
pub tcx : & ' a ty:: ctxt < ' tcx > ,
253
255
254
256
/// The crate being checked.
255
- pub krate : & ' a ast :: Crate ,
257
+ pub krate : & ' a hir :: Crate ,
256
258
257
259
/// Items exported from the crate being checked.
258
260
pub exported_items : & ' a ExportedItems ,
@@ -284,7 +286,7 @@ macro_rules! run_lints { ($cx:expr, $f:ident, $($args:expr),*) => ({
284
286
/// Parse the lint attributes into a vector, with `Err`s for malformed lint
285
287
/// attributes. Writing this as an iterator is an enormous mess.
286
288
// See also the hir version just below.
287
- pub fn gather_attrs ( attrs : & [ ast :: Attribute ] )
289
+ pub fn gather_attrs ( attrs : & [ hir :: Attribute ] )
288
290
-> Vec < Result < ( InternedString , Level , Span ) , Span > > {
289
291
let mut out = vec ! ( ) ;
290
292
for attr in attrs {
@@ -297,7 +299,7 @@ pub fn gather_attrs(attrs: &[ast::Attribute])
297
299
298
300
let meta = & attr. node . value ;
299
301
let metas = match meta. node {
300
- ast :: MetaList ( _, ref metas) => metas,
302
+ hir :: MetaList ( _, ref metas) => metas,
301
303
_ => {
302
304
out. push ( Err ( meta. span ) ) ;
303
305
continue ;
@@ -306,7 +308,7 @@ pub fn gather_attrs(attrs: &[ast::Attribute])
306
308
307
309
for meta in metas {
308
310
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 ) ) ,
310
312
_ => Err ( meta. span ) ,
311
313
} ) ;
312
314
}
@@ -398,7 +400,7 @@ pub fn raw_emit_lint(sess: &Session, lint: &'static Lint,
398
400
399
401
impl < ' a , ' tcx > Context < ' a , ' tcx > {
400
402
fn new ( tcx : & ' a ty:: ctxt < ' tcx > ,
401
- krate : & ' a ast :: Crate ,
403
+ krate : & ' a hir :: Crate ,
402
404
exported_items : & ' a ExportedItems ) -> Context < ' a , ' tcx > {
403
405
// We want to own the lint store, so move it out of the session.
404
406
let lint_store = mem:: replace ( & mut * tcx. sess . lint_store . borrow_mut ( ) ,
@@ -452,7 +454,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
452
454
/// current lint context, call the provided function, then reset the
453
455
/// lints in effect to their previous state.
454
456
fn with_lint_attrs < F > ( & mut self ,
455
- attrs : & [ ast :: Attribute ] ,
457
+ attrs : & [ hir :: Attribute ] ,
456
458
f : F ) where
457
459
F : FnOnce ( & mut Context ) ,
458
460
{
@@ -519,9 +521,9 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
519
521
}
520
522
521
523
fn visit_ids < F > ( & mut self , f : F ) where
522
- F : FnOnce ( & mut ast_util :: IdVisitor < Context > )
524
+ F : FnOnce ( & mut util :: IdVisitor < Context > )
523
525
{
524
- let mut v = ast_util :: IdVisitor {
526
+ let mut v = util :: IdVisitor {
525
527
operation : self ,
526
528
pass_through_items : false ,
527
529
visited_outermost : false ,
@@ -531,68 +533,68 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
531
533
}
532
534
533
535
impl < ' 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 ) {
535
537
self . with_lint_attrs ( & it. attrs , |cx| {
536
538
run_lints ! ( cx, check_item, it) ;
537
539
cx. visit_ids ( |v| v. visit_item ( it) ) ;
538
540
visit:: walk_item ( cx, it) ;
539
541
} )
540
542
}
541
543
542
- fn visit_foreign_item ( & mut self , it : & ast :: ForeignItem ) {
544
+ fn visit_foreign_item ( & mut self , it : & hir :: ForeignItem ) {
543
545
self . with_lint_attrs ( & it. attrs , |cx| {
544
546
run_lints ! ( cx, check_foreign_item, it) ;
545
547
visit:: walk_foreign_item ( cx, it) ;
546
548
} )
547
549
}
548
550
549
- fn visit_pat ( & mut self , p : & ast :: Pat ) {
551
+ fn visit_pat ( & mut self , p : & hir :: Pat ) {
550
552
run_lints ! ( self , check_pat, p) ;
551
553
visit:: walk_pat ( self , p) ;
552
554
}
553
555
554
- fn visit_expr ( & mut self , e : & ast :: Expr ) {
556
+ fn visit_expr ( & mut self , e : & hir :: Expr ) {
555
557
run_lints ! ( self , check_expr, e) ;
556
558
visit:: walk_expr ( self , e) ;
557
559
}
558
560
559
- fn visit_stmt ( & mut self , s : & ast :: Stmt ) {
561
+ fn visit_stmt ( & mut self , s : & hir :: Stmt ) {
560
562
run_lints ! ( self , check_stmt, s) ;
561
563
visit:: walk_stmt ( self , s) ;
562
564
}
563
565
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 ) {
566
568
run_lints ! ( self , check_fn, fk, decl, body, span, id) ;
567
569
visit:: walk_fn ( self , fk, decl, body, span) ;
568
570
}
569
571
570
572
fn visit_struct_def ( & mut self ,
571
- s : & ast :: StructDef ,
573
+ s : & hir :: StructDef ,
572
574
ident : ast:: Ident ,
573
- g : & ast :: Generics ,
575
+ g : & hir :: Generics ,
574
576
id : ast:: NodeId ) {
575
577
run_lints ! ( self , check_struct_def, s, ident, g, id) ;
576
578
visit:: walk_struct_def ( self , s) ;
577
579
run_lints ! ( self , check_struct_def_post, s, ident, g, id) ;
578
580
}
579
581
580
- fn visit_struct_field ( & mut self , s : & ast :: StructField ) {
582
+ fn visit_struct_field ( & mut self , s : & hir :: StructField ) {
581
583
self . with_lint_attrs ( & s. node . attrs , |cx| {
582
584
run_lints ! ( cx, check_struct_field, s) ;
583
585
visit:: walk_struct_field ( cx, s) ;
584
586
} )
585
587
}
586
588
587
- fn visit_variant ( & mut self , v : & ast :: Variant , g : & ast :: Generics ) {
589
+ fn visit_variant ( & mut self , v : & hir :: Variant , g : & hir :: Generics ) {
588
590
self . with_lint_attrs ( & v. node . attrs , |cx| {
589
591
run_lints ! ( cx, check_variant, v, g) ;
590
592
visit:: walk_variant ( cx, v, g) ;
591
593
run_lints ! ( cx, check_variant_post, v, g) ;
592
594
} )
593
595
}
594
596
595
- fn visit_ty ( & mut self , t : & ast :: Ty ) {
597
+ fn visit_ty ( & mut self , t : & hir :: Ty ) {
596
598
run_lints ! ( self , check_ty, t) ;
597
599
visit:: walk_ty ( self , t) ;
598
600
}
@@ -601,84 +603,79 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
601
603
run_lints ! ( self , check_ident, sp, id) ;
602
604
}
603
605
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 ) {
605
607
run_lints ! ( self , check_mod, m, s, n) ;
606
608
visit:: walk_mod ( self , m) ;
607
609
}
608
610
609
- fn visit_local ( & mut self , l : & ast :: Local ) {
611
+ fn visit_local ( & mut self , l : & hir :: Local ) {
610
612
run_lints ! ( self , check_local, l) ;
611
613
visit:: walk_local ( self , l) ;
612
614
}
613
615
614
- fn visit_block ( & mut self , b : & ast :: Block ) {
616
+ fn visit_block ( & mut self , b : & hir :: Block ) {
615
617
run_lints ! ( self , check_block, b) ;
616
618
visit:: walk_block ( self , b) ;
617
619
}
618
620
619
- fn visit_arm ( & mut self , a : & ast :: Arm ) {
621
+ fn visit_arm ( & mut self , a : & hir :: Arm ) {
620
622
run_lints ! ( self , check_arm, a) ;
621
623
visit:: walk_arm ( self , a) ;
622
624
}
623
625
624
- fn visit_decl ( & mut self , d : & ast :: Decl ) {
626
+ fn visit_decl ( & mut self , d : & hir :: Decl ) {
625
627
run_lints ! ( self , check_decl, d) ;
626
628
visit:: walk_decl ( self , d) ;
627
629
}
628
630
629
- fn visit_expr_post ( & mut self , e : & ast :: Expr ) {
631
+ fn visit_expr_post ( & mut self , e : & hir :: Expr ) {
630
632
run_lints ! ( self , check_expr_post, e) ;
631
633
}
632
634
633
- fn visit_generics ( & mut self , g : & ast :: Generics ) {
635
+ fn visit_generics ( & mut self , g : & hir :: Generics ) {
634
636
run_lints ! ( self , check_generics, g) ;
635
637
visit:: walk_generics ( self , g) ;
636
638
}
637
639
638
- fn visit_trait_item ( & mut self , trait_item : & ast :: TraitItem ) {
640
+ fn visit_trait_item ( & mut self , trait_item : & hir :: TraitItem ) {
639
641
self . with_lint_attrs ( & trait_item. attrs , |cx| {
640
642
run_lints ! ( cx, check_trait_item, trait_item) ;
641
643
cx. visit_ids ( |v| v. visit_trait_item ( trait_item) ) ;
642
644
visit:: walk_trait_item ( cx, trait_item) ;
643
645
} ) ;
644
646
}
645
647
646
- fn visit_impl_item ( & mut self , impl_item : & ast :: ImplItem ) {
648
+ fn visit_impl_item ( & mut self , impl_item : & hir :: ImplItem ) {
647
649
self . with_lint_attrs ( & impl_item. attrs , |cx| {
648
650
run_lints ! ( cx, check_impl_item, impl_item) ;
649
651
cx. visit_ids ( |v| v. visit_impl_item ( impl_item) ) ;
650
652
visit:: walk_impl_item ( cx, impl_item) ;
651
653
} ) ;
652
654
}
653
655
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 > ) {
655
657
run_lints ! ( self , check_opt_lifetime_ref, sp, lt) ;
656
658
}
657
659
658
- fn visit_lifetime_ref ( & mut self , lt : & ast :: Lifetime ) {
660
+ fn visit_lifetime_ref ( & mut self , lt : & hir :: Lifetime ) {
659
661
run_lints ! ( self , check_lifetime_ref, lt) ;
660
662
}
661
663
662
- fn visit_lifetime_def ( & mut self , lt : & ast :: LifetimeDef ) {
664
+ fn visit_lifetime_def ( & mut self , lt : & hir :: LifetimeDef ) {
663
665
run_lints ! ( self , check_lifetime_def, lt) ;
664
666
}
665
667
666
- fn visit_explicit_self ( & mut self , es : & ast :: ExplicitSelf ) {
668
+ fn visit_explicit_self ( & mut self , es : & hir :: ExplicitSelf ) {
667
669
run_lints ! ( self , check_explicit_self, es) ;
668
670
visit:: walk_explicit_self ( self , es) ;
669
671
}
670
672
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 ) {
677
674
run_lints ! ( self , check_path, p, id) ;
678
675
visit:: walk_path ( self , p) ;
679
676
}
680
677
681
- fn visit_attribute ( & mut self , attr : & ast :: Attribute ) {
678
+ fn visit_attribute ( & mut self , attr : & hir :: Attribute ) {
682
679
run_lints ! ( self , check_attribute, attr) ;
683
680
}
684
681
}
@@ -709,9 +706,9 @@ impl LintPass for GatherNodeLevels {
709
706
lint_array ! ( )
710
707
}
711
708
712
- fn check_item ( & mut self , cx : & Context , it : & ast :: Item ) {
709
+ fn check_item ( & mut self , cx : & Context , it : & hir :: Item ) {
713
710
match it. node {
714
- ast :: ItemEnum ( ..) => {
711
+ hir :: ItemEnum ( ..) => {
715
712
let lint_id = LintId :: of ( builtin:: VARIANT_SIZE_DIFFERENCES ) ;
716
713
let lvlsrc = cx. lints . get_level_source ( lint_id) ;
717
714
match lvlsrc {
@@ -731,7 +728,7 @@ impl LintPass for GatherNodeLevels {
731
728
///
732
729
/// Consumes the `lint_store` field of the `Session`.
733
730
pub fn check_crate ( tcx : & ty:: ctxt ,
734
- krate : & ast :: Crate ,
731
+ krate : & hir :: Crate ,
735
732
exported_items : & ExportedItems ) {
736
733
737
734
let mut cx = Context :: new ( tcx, krate, exported_items) ;
0 commit comments