@@ -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| {
@@ -133,32 +133,32 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
133
133
}
134
134
}
135
135
136
- fn with_fcx < F > ( & mut self , item : & ast:: Item , mut f : F ) where
136
+ fn with_fcx < F > ( & mut self , span : Span , id : ast:: NodeId , mut f : F ) where
137
137
F : for < ' fcx > FnMut ( & mut CheckTypeWellFormedVisitor < ' ccx , ' tcx > , & FnCtxt < ' fcx , ' tcx > ) ,
138
138
{
139
139
let ccx = self . ccx ;
140
- let item_def_id = local_def ( item . id ) ;
140
+ let item_def_id = local_def ( id) ;
141
141
let type_scheme = ty:: lookup_item_type ( ccx. tcx , item_def_id) ;
142
142
let type_predicates = ty:: lookup_predicates ( ccx. tcx , item_def_id) ;
143
- reject_non_type_param_bounds ( ccx. tcx , item . span , & type_predicates) ;
143
+ reject_non_type_param_bounds ( ccx. tcx , span, & type_predicates) ;
144
144
let param_env =
145
145
ty:: construct_parameter_environment ( ccx. tcx ,
146
- item . span ,
146
+ span,
147
147
& type_scheme. generics ,
148
148
& type_predicates,
149
- item . id ) ;
149
+ id) ;
150
150
let inh = Inherited :: new ( ccx. tcx , param_env) ;
151
- let fcx = blank_fn_ctxt ( ccx, & inh, ty:: FnConverging ( type_scheme. ty ) , item . id ) ;
151
+ let fcx = blank_fn_ctxt ( ccx, & inh, ty:: FnConverging ( type_scheme. ty ) , id) ;
152
152
f ( self , & fcx) ;
153
153
fcx. select_all_obligations_or_error ( ) ;
154
- regionck:: regionck_item ( & fcx, item ) ;
154
+ regionck:: regionck_item ( & fcx, id ) ;
155
155
}
156
156
157
157
/// In a type definition, we check that to ensure that the types of the fields are well-formed.
158
158
fn check_type_defn < F > ( & mut self , item : & ast:: Item , mut lookup_fields : F ) where
159
159
F : for < ' fcx > FnMut ( & FnCtxt < ' fcx , ' tcx > ) -> Vec < AdtVariant < ' tcx > > ,
160
160
{
161
- self . with_fcx ( item, |this, fcx| {
161
+ self . with_fcx ( item. span , item . id , |this, fcx| {
162
162
let variants = lookup_fields ( fcx) ;
163
163
let mut bounds_checker = BoundsChecker :: new ( fcx,
164
164
item. span ,
@@ -193,18 +193,17 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
193
193
} ) ;
194
194
}
195
195
196
- fn check_item_type ( & mut self ,
197
- item : & ast:: Item )
196
+ fn check_item_type ( & mut self , span : Span , id : ast:: NodeId )
198
197
{
199
- self . with_fcx ( item , |this, fcx| {
198
+ self . with_fcx ( span , id , |this, fcx| {
200
199
let mut bounds_checker = BoundsChecker :: new ( fcx,
201
- item . span ,
202
- item . id ,
200
+ span,
201
+ id,
203
202
Some ( & mut this. cache ) ) ;
204
203
debug ! ( "check_item_type at bounds_checker.scope: {:?}" , bounds_checker. scope) ;
205
204
206
- let type_scheme = ty:: lookup_item_type ( fcx. tcx ( ) , local_def ( item . id ) ) ;
207
- let item_ty = fcx. instantiate_type_scheme ( item . span ,
205
+ let type_scheme = ty:: lookup_item_type ( fcx. tcx ( ) , local_def ( id) ) ;
206
+ let item_ty = fcx. instantiate_type_scheme ( span,
208
207
& fcx. inh . param_env . free_substs ,
209
208
& type_scheme. ty ) ;
210
209
@@ -215,7 +214,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
215
214
fn check_impl ( & mut self ,
216
215
item : & ast:: Item )
217
216
{
218
- self . with_fcx ( item, |this, fcx| {
217
+ self . with_fcx ( item. span , item . id , |this, fcx| {
219
218
let mut bounds_checker = BoundsChecker :: new ( fcx,
220
219
item. span ,
221
220
item. id ,
@@ -426,11 +425,16 @@ fn reject_shadowing_type_parameters<'tcx>(tcx: &ty::ctxt<'tcx>,
426
425
}
427
426
428
427
impl < ' ccx , ' tcx , ' v > Visitor < ' v > for CheckTypeWellFormedVisitor < ' ccx , ' tcx > {
429
- fn visit_item ( & mut self , i : & ast:: Item ) {
428
+ fn visit_item ( & mut self , i : & ' v ast:: Item ) {
430
429
self . check_item_well_formed ( i) ;
431
430
visit:: walk_item ( self , i) ;
432
431
}
433
432
433
+ fn visit_foreign_item ( & mut self , item : & ' v ast:: ForeignItem ) {
434
+ self . check_item_type ( item. span , item. id ) ;
435
+ visit:: walk_foreign_item ( self , item) ;
436
+ }
437
+
434
438
fn visit_fn ( & mut self ,
435
439
fk : visit:: FnKind < ' v > , fd : & ' v ast:: FnDecl ,
436
440
b : & ' v ast:: Block , span : Span , id : ast:: NodeId ) {
0 commit comments