@@ -45,7 +45,7 @@ use syntax_pos::{MultiSpan, Span};
45
45
use errors:: DiagnosticBuilder ;
46
46
47
47
use rustc:: hir;
48
- use rustc:: hir:: intravisit:: { self , Visitor , FnKind , NestedVisitorMap } ;
48
+ use rustc:: hir:: intravisit:: { self , Visitor } ;
49
49
50
50
pub mod check_loans;
51
51
@@ -60,65 +60,14 @@ pub struct LoanDataFlowOperator;
60
60
61
61
pub type LoanDataFlow < ' a , ' tcx > = DataFlowContext < ' a , ' tcx , LoanDataFlowOperator > ;
62
62
63
- impl < ' a , ' tcx > Visitor < ' tcx > for BorrowckCtxt < ' a , ' tcx > {
64
- fn nested_visit_map < ' this > ( & ' this mut self ) -> NestedVisitorMap < ' this , ' tcx > {
65
- NestedVisitorMap :: OnlyBodies ( & self . tcx . hir )
66
- }
67
-
68
- fn visit_fn ( & mut self , fk : FnKind < ' tcx > , fd : & ' tcx hir:: FnDecl ,
69
- b : hir:: BodyId , s : Span , id : ast:: NodeId ) {
70
- match fk {
71
- FnKind :: ItemFn ( ..) |
72
- FnKind :: Method ( ..) => {
73
- borrowck_fn ( self . tcx , b) ;
74
- intravisit:: walk_fn ( self , fk, fd, b, s, id) ;
75
- }
76
-
77
- FnKind :: Closure ( ..) => {
78
- borrowck_fn ( self . tcx , b) ;
79
- intravisit:: walk_fn ( self , fk, fd, b, s, id) ;
80
- }
81
- }
82
- }
83
-
84
- fn visit_item ( & mut self , item : & ' tcx hir:: Item ) {
85
- // Gather loans for items. Note that we don't need
86
- // to check loans for single expressions. The check
87
- // loan step is intended for things that have a data
88
- // flow dependent conditions.
89
- match item. node {
90
- hir:: ItemStatic ( .., ex) |
91
- hir:: ItemConst ( _, ex) => {
92
- borrowck_fn ( self . tcx , ex) ;
93
- }
94
- _ => { }
95
- }
96
-
97
- intravisit:: walk_item ( self , item) ;
98
- }
99
-
100
- fn visit_trait_item ( & mut self , ti : & ' tcx hir:: TraitItem ) {
101
- if let hir:: TraitItemKind :: Const ( _, Some ( expr) ) = ti. node {
102
- borrowck_fn ( self . tcx , expr) ;
103
- }
104
- intravisit:: walk_trait_item ( self , ti) ;
105
- }
106
-
107
- fn visit_impl_item ( & mut self , ii : & ' tcx hir:: ImplItem ) {
108
- if let hir:: ImplItemKind :: Const ( _, expr) = ii. node {
109
- borrowck_fn ( self . tcx , expr) ;
110
- }
111
- intravisit:: walk_impl_item ( self , ii) ;
112
- }
113
- }
114
-
115
63
pub fn check_crate < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ) {
116
- let mut bccx = BorrowckCtxt {
117
- tcx : tcx,
118
- tables : None ,
119
- } ;
120
-
121
- tcx. visit_all_item_likes_in_krate ( DepNode :: BorrowCheck , & mut bccx. as_deep_visitor ( ) ) ;
64
+ tcx. dep_graph . with_task ( DepNode :: BorrowCheckKrate , || {
65
+ tcx. visit_all_bodies_in_krate ( |body_owner_def_id, body_id| {
66
+ tcx. dep_graph . with_task ( DepNode :: BorrowCheck ( body_owner_def_id) , || {
67
+ borrowck_fn ( tcx, body_id) ;
68
+ } ) ;
69
+ } ) ;
70
+ } ) ;
122
71
}
123
72
124
73
/// Collection of conclusions determined via borrow checker analyses.
0 commit comments