@@ -2416,13 +2416,13 @@ pub enum Representability {
24162416
24172417/// Check whether a type is representable. This means it cannot contain unboxed
24182418/// structural recursion. This check is needed for structs and enums.
2419- pub fn is_type_representable ( cx : & ctxt , ty : t ) -> Representability {
2419+ pub fn is_type_representable ( cx : & ctxt , sp : Span , ty : t ) -> Representability {
24202420
24212421 // Iterate until something non-representable is found
2422- fn find_nonrepresentable < It : Iterator < t > > ( cx : & ctxt , seen : & mut Vec < DefId > ,
2422+ fn find_nonrepresentable < It : Iterator < t > > ( cx : & ctxt , sp : Span , seen : & mut Vec < DefId > ,
24232423 mut iter : It ) -> Representability {
24242424 for ty in iter {
2425- let r = type_structurally_recursive ( cx, seen, ty) ;
2425+ let r = type_structurally_recursive ( cx, sp , seen, ty) ;
24262426 if r != Representable {
24272427 return r
24282428 }
@@ -2432,7 +2432,7 @@ pub fn is_type_representable(cx: &ctxt, ty: t) -> Representability {
24322432
24332433 // Does the type `ty` directly (without indirection through a pointer)
24342434 // contain any types on stack `seen`?
2435- fn type_structurally_recursive ( cx : & ctxt , seen : & mut Vec < DefId > ,
2435+ fn type_structurally_recursive ( cx : & ctxt , sp : Span , seen : & mut Vec < DefId > ,
24362436 ty : t ) -> Representability {
24372437 debug ! ( "type_structurally_recursive: {}" ,
24382438 :: util:: ppaux:: ty_to_str( cx, ty) ) ;
@@ -2455,19 +2455,19 @@ pub fn is_type_representable(cx: &ctxt, ty: t) -> Representability {
24552455 match get ( ty) . sty {
24562456 // Tuples
24572457 ty_tup( ref ts) => {
2458- find_nonrepresentable ( cx, seen, ts. iter ( ) . map ( |t| * t) )
2458+ find_nonrepresentable ( cx, sp , seen, ts. iter ( ) . map ( |t| * t) )
24592459 }
24602460 // Fixed-length vectors.
24612461 // FIXME(#11924) Behavior undecided for zero-length vectors.
24622462 ty_vec( ty, VstoreFixed ( _) ) => {
2463- type_structurally_recursive ( cx, seen, ty)
2463+ type_structurally_recursive ( cx, sp , seen, ty)
24642464 }
24652465
24662466 // Push struct and enum def-ids onto `seen` before recursing.
24672467 ty_struct( did, ref substs) => {
24682468 seen. push ( did) ;
24692469 let fields = struct_fields ( cx, did, substs) ;
2470- let r = find_nonrepresentable ( cx, seen,
2470+ let r = find_nonrepresentable ( cx, sp , seen,
24712471 fields. iter ( ) . map ( |f| f. mt . ty ) ) ;
24722472 seen. pop ( ) ;
24732473 r
@@ -2478,8 +2478,10 @@ pub fn is_type_representable(cx: &ctxt, ty: t) -> Representability {
24782478
24792479 let mut r = Representable ;
24802480 for variant in vs. iter ( ) {
2481- let iter = variant. args . iter ( ) . map ( |aty| subst ( cx, substs, * aty) ) ;
2482- r = find_nonrepresentable ( cx, seen, iter) ;
2481+ let iter = variant. args . iter ( ) . map ( |aty| {
2482+ aty. subst_spanned ( cx, substs, Some ( sp) )
2483+ } ) ;
2484+ r = find_nonrepresentable ( cx, sp, seen, iter) ;
24832485
24842486 if r != Representable { break }
24852487 }
@@ -2499,7 +2501,7 @@ pub fn is_type_representable(cx: &ctxt, ty: t) -> Representability {
24992501 // contains a different, structurally recursive type, maintain a stack
25002502 // of seen types and check recursion for each of them (issues #3008, #3779).
25012503 let mut seen: Vec < DefId > = Vec :: new ( ) ;
2502- type_structurally_recursive ( cx, & mut seen, ty)
2504+ type_structurally_recursive ( cx, sp , & mut seen, ty)
25032505}
25042506
25052507pub fn type_is_trait ( ty : t ) -> bool {
0 commit comments