@@ -94,13 +94,13 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
94
94
}
95
95
}
96
96
ast:: ItemFn ( ..) => {
97
- self . check_item_type ( item) ;
97
+ self . check_item_type ( item. span , item . id ) ;
98
98
}
99
99
ast:: ItemStatic ( ..) => {
100
- self . check_item_type ( item) ;
100
+ self . check_item_type ( item. span , item . id ) ;
101
101
}
102
102
ast:: ItemConst ( ..) => {
103
- self . check_item_type ( item) ;
103
+ self . check_item_type ( item. span , item . id ) ;
104
104
}
105
105
ast:: ItemStruct ( ref struct_def, ref ast_generics) => {
106
106
self . check_type_defn ( item, |fcx| {
@@ -132,31 +132,31 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
132
132
}
133
133
}
134
134
135
- fn with_fcx < F > ( & mut self , item : & ast:: Item , mut f : F ) where
135
+ fn with_fcx < F > ( & mut self , span : Span , id : ast:: NodeId , mut f : F ) where
136
136
F : for < ' fcx > FnMut ( & mut CheckTypeWellFormedVisitor < ' ccx , ' tcx > , & FnCtxt < ' fcx , ' tcx > ) ,
137
137
{
138
138
let ccx = self . ccx ;
139
- let item_def_id = local_def ( item . id ) ;
139
+ let item_def_id = local_def ( id) ;
140
140
let type_scheme = ccx. tcx . lookup_item_type ( item_def_id) ;
141
141
let type_predicates = ccx. tcx . lookup_predicates ( item_def_id) ;
142
- reject_non_type_param_bounds ( ccx. tcx , item . span , & type_predicates) ;
143
- let param_env = ccx. tcx . construct_parameter_environment ( item . span ,
142
+ reject_non_type_param_bounds ( ccx. tcx , span, & type_predicates) ;
143
+ let param_env = ccx. tcx . construct_parameter_environment ( span,
144
144
& type_scheme. generics ,
145
145
& type_predicates,
146
- item . id ) ;
146
+ id) ;
147
147
let tables = RefCell :: new ( ty:: Tables :: empty ( ) ) ;
148
148
let inh = Inherited :: new ( ccx. tcx , & tables, param_env) ;
149
- let fcx = blank_fn_ctxt ( ccx, & inh, ty:: FnConverging ( type_scheme. ty ) , item . id ) ;
149
+ let fcx = blank_fn_ctxt ( ccx, & inh, ty:: FnConverging ( type_scheme. ty ) , id) ;
150
150
f ( self , & fcx) ;
151
151
fcx. select_all_obligations_or_error ( ) ;
152
- regionck:: regionck_item ( & fcx, item ) ;
152
+ regionck:: regionck_item ( & fcx, id ) ;
153
153
}
154
154
155
155
/// In a type definition, we check that to ensure that the types of the fields are well-formed.
156
156
fn check_type_defn < F > ( & mut self , item : & ast:: Item , mut lookup_fields : F ) where
157
157
F : for < ' fcx > FnMut ( & FnCtxt < ' fcx , ' tcx > ) -> Vec < AdtVariant < ' tcx > > ,
158
158
{
159
- self . with_fcx ( item, |this, fcx| {
159
+ self . with_fcx ( item. span , item . id , |this, fcx| {
160
160
let variants = lookup_fields ( fcx) ;
161
161
let mut bounds_checker = BoundsChecker :: new ( fcx,
162
162
item. id ,
@@ -190,31 +190,30 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
190
190
} ) ;
191
191
}
192
192
193
- fn check_item_type ( & mut self ,
194
- item : & ast:: Item )
193
+ fn check_item_type ( & mut self , span : Span , id : ast:: NodeId )
195
194
{
196
- self . with_fcx ( item , |this, fcx| {
195
+ self . with_fcx ( span , id , |this, fcx| {
197
196
let mut bounds_checker = BoundsChecker :: new ( fcx,
198
- item . id ,
197
+ id,
199
198
Some ( & mut this. cache ) ) ;
200
199
debug ! ( "check_item_type at bounds_checker.scope: {:?}" , bounds_checker. scope) ;
201
200
202
- let type_scheme = fcx. tcx ( ) . lookup_item_type ( local_def ( item . id ) ) ;
203
- let item_ty = fcx. instantiate_type_scheme ( item . span ,
201
+ let type_scheme = fcx. tcx ( ) . lookup_item_type ( local_def ( id) ) ;
202
+ let item_ty = fcx. instantiate_type_scheme ( span,
204
203
& fcx. inh
205
204
. infcx
206
205
. parameter_environment
207
206
. free_substs ,
208
207
& type_scheme. ty ) ;
209
208
210
- bounds_checker. check_traits_in_ty ( item_ty, item . span ) ;
209
+ bounds_checker. check_traits_in_ty ( item_ty, span) ;
211
210
} ) ;
212
211
}
213
212
214
213
fn check_impl ( & mut self ,
215
214
item : & ast:: Item )
216
215
{
217
- self . with_fcx ( item, |this, fcx| {
216
+ self . with_fcx ( item. span , item . id , |this, fcx| {
218
217
let mut bounds_checker = BoundsChecker :: new ( fcx,
219
218
item. id ,
220
219
Some ( & mut this. cache ) ) ;
@@ -428,11 +427,16 @@ fn reject_shadowing_type_parameters<'tcx>(tcx: &ty::ctxt<'tcx>,
428
427
}
429
428
430
429
impl < ' ccx , ' tcx , ' v > Visitor < ' v > for CheckTypeWellFormedVisitor < ' ccx , ' tcx > {
431
- fn visit_item ( & mut self , i : & ast:: Item ) {
430
+ fn visit_item ( & mut self , i : & ' v ast:: Item ) {
432
431
self . check_item_well_formed ( i) ;
433
432
visit:: walk_item ( self , i) ;
434
433
}
435
434
435
+ fn visit_foreign_item ( & mut self , i : & ' v ast:: ForeignItem ) {
436
+ self . check_item_type ( i. span , i. id ) ;
437
+ visit:: walk_foreign_item ( self , i) ;
438
+ }
439
+
436
440
fn visit_fn ( & mut self ,
437
441
fk : visit:: FnKind < ' v > , fd : & ' v ast:: FnDecl ,
438
442
b : & ' v ast:: Block , span : Span , id : ast:: NodeId ) {
0 commit comments