@@ -23,7 +23,7 @@ use util::ppaux::{Repr, UserString};
2323use std:: collections:: HashSet ;
2424use syntax:: ast;
2525use syntax:: ast_util:: local_def;
26- use syntax:: codemap:: Span ;
26+ use syntax:: codemap:: { DUMMY_SP , Span } ;
2727use syntax:: parse:: token:: { self , special_idents} ;
2828use syntax:: visit;
2929use syntax:: visit:: Visitor ;
@@ -162,15 +162,14 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
162162 self . with_fcx ( item, |this, fcx| {
163163 let variants = lookup_fields ( fcx) ;
164164 let mut bounds_checker = BoundsChecker :: new ( fcx,
165- item. span ,
166165 item. id ,
167166 Some ( & mut this. cache ) ) ;
168167 debug ! ( "check_type_defn at bounds_checker.scope: {:?}" , bounds_checker. scope) ;
169168
170- for variant in & variants {
169+ for variant in & variants {
171170 for field in & variant. fields {
172171 // Regions are checked below.
173- bounds_checker. check_traits_in_ty ( field. ty ) ;
172+ bounds_checker. check_traits_in_ty ( field. ty , field . span ) ;
174173 }
175174
176175 // For DST, all intermediate types must be sized.
@@ -199,7 +198,6 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
199198 {
200199 self . with_fcx ( item, |this, fcx| {
201200 let mut bounds_checker = BoundsChecker :: new ( fcx,
202- item. span ,
203201 item. id ,
204202 Some ( & mut this. cache ) ) ;
205203 debug ! ( "check_item_type at bounds_checker.scope: {:?}" , bounds_checker. scope) ;
@@ -209,7 +207,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
209207 & fcx. inh . param_env . free_substs ,
210208 & type_scheme. ty ) ;
211209
212- bounds_checker. check_traits_in_ty ( item_ty) ;
210+ bounds_checker. check_traits_in_ty ( item_ty, item . span ) ;
213211 } ) ;
214212 }
215213
@@ -218,7 +216,6 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
218216 {
219217 self . with_fcx ( item, |this, fcx| {
220218 let mut bounds_checker = BoundsChecker :: new ( fcx,
221- item. span ,
222219 item. id ,
223220 Some ( & mut this. cache ) ) ;
224221 debug ! ( "check_impl at bounds_checker.scope: {:?}" , bounds_checker. scope) ;
@@ -231,7 +228,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
231228 & fcx. inh . param_env . free_substs ,
232229 & self_ty) ;
233230
234- bounds_checker. check_traits_in_ty ( self_ty) ;
231+ bounds_checker. check_traits_in_ty ( self_ty, item . span ) ;
235232
236233 // Similarly, obtain an "inside" reference to the trait
237234 // that the impl implements.
@@ -252,7 +249,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
252249 // trait reference. Instead, this is done at the impl site.
253250 // Arguably this is wrong and we should treat the trait-reference
254251 // the same way as we treat the self-type.
255- bounds_checker. check_trait_ref ( & trait_ref) ;
252+ bounds_checker. check_trait_ref ( & trait_ref, item . span ) ;
256253
257254 let cause =
258255 traits:: ObligationCause :: new (
@@ -483,11 +480,10 @@ pub struct BoundsChecker<'cx,'tcx:'cx> {
483480
484481impl < ' cx , ' tcx > BoundsChecker < ' cx , ' tcx > {
485482 pub fn new ( fcx : & ' cx FnCtxt < ' cx , ' tcx > ,
486- span : Span ,
487483 scope : ast:: NodeId ,
488484 cache : Option < & ' cx mut HashSet < Ty < ' tcx > > > )
489485 -> BoundsChecker < ' cx , ' tcx > {
490- BoundsChecker { fcx : fcx, span : span , scope : scope,
486+ BoundsChecker { fcx : fcx, span : DUMMY_SP , scope : scope,
491487 cache : cache, binding_count : 0 }
492488 }
493489
@@ -500,30 +496,32 @@ impl<'cx,'tcx> BoundsChecker<'cx,'tcx> {
500496 ///
501497 /// Note that it does not (currently, at least) check that `A : Copy` (that check is delegated
502498 /// to the point where impl `A : Trait<B>` is implemented).
503- pub fn check_trait_ref ( & mut self , trait_ref : & ty:: TraitRef < ' tcx > ) {
499+ pub fn check_trait_ref ( & mut self , trait_ref : & ty:: TraitRef < ' tcx > , span : Span ) {
504500 let trait_predicates = ty:: lookup_predicates ( self . fcx . tcx ( ) , trait_ref. def_id ) ;
505501
506- let bounds = self . fcx . instantiate_bounds ( self . span ,
502+ let bounds = self . fcx . instantiate_bounds ( span,
507503 trait_ref. substs ,
508504 & trait_predicates) ;
509505
510506 self . fcx . add_obligations_for_parameters (
511507 traits:: ObligationCause :: new (
512- self . span ,
508+ span,
513509 self . fcx . body_id ,
514510 traits:: ItemObligation ( trait_ref. def_id ) ) ,
515511 & bounds) ;
516512
517513 for & ty in & trait_ref. substs . types {
518- self . check_traits_in_ty ( ty) ;
514+ self . check_traits_in_ty ( ty, span ) ;
519515 }
520516 }
521517
522- pub fn check_ty ( & mut self , ty : Ty < ' tcx > ) {
518+ pub fn check_ty ( & mut self , ty : Ty < ' tcx > , span : Span ) {
519+ self . span = span;
523520 ty. fold_with ( self ) ;
524521 }
525522
526- fn check_traits_in_ty ( & mut self , ty : Ty < ' tcx > ) {
523+ fn check_traits_in_ty ( & mut self , ty : Ty < ' tcx > , span : Span ) {
524+ self . span = span;
527525 // When checking types outside of a type def'n, we ignore
528526 // region obligations. See discussion below in fold_ty().
529527 self . binding_count += 1 ;
0 commit comments