@@ -2416,13 +2416,13 @@ pub enum Representability {
2416
2416
2417
2417
/// Check whether a type is representable. This means it cannot contain unboxed
2418
2418
/// 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 {
2420
2420
2421
2421
// 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 > ,
2423
2423
mut iter : It ) -> Representability {
2424
2424
for ty in iter {
2425
- let r = type_structurally_recursive ( cx, seen, ty) ;
2425
+ let r = type_structurally_recursive ( cx, sp , seen, ty) ;
2426
2426
if r != Representable {
2427
2427
return r
2428
2428
}
@@ -2432,7 +2432,7 @@ pub fn is_type_representable(cx: &ctxt, ty: t) -> Representability {
2432
2432
2433
2433
// Does the type `ty` directly (without indirection through a pointer)
2434
2434
// 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 > ,
2436
2436
ty : t ) -> Representability {
2437
2437
debug ! ( "type_structurally_recursive: {}" ,
2438
2438
:: util:: ppaux:: ty_to_str( cx, ty) ) ;
@@ -2455,19 +2455,19 @@ pub fn is_type_representable(cx: &ctxt, ty: t) -> Representability {
2455
2455
match get ( ty) . sty {
2456
2456
// Tuples
2457
2457
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) )
2459
2459
}
2460
2460
// Fixed-length vectors.
2461
2461
// FIXME(#11924) Behavior undecided for zero-length vectors.
2462
2462
ty_vec( ty, VstoreFixed ( _) ) => {
2463
- type_structurally_recursive ( cx, seen, ty)
2463
+ type_structurally_recursive ( cx, sp , seen, ty)
2464
2464
}
2465
2465
2466
2466
// Push struct and enum def-ids onto `seen` before recursing.
2467
2467
ty_struct( did, ref substs) => {
2468
2468
seen. push ( did) ;
2469
2469
let fields = struct_fields ( cx, did, substs) ;
2470
- let r = find_nonrepresentable ( cx, seen,
2470
+ let r = find_nonrepresentable ( cx, sp , seen,
2471
2471
fields. iter ( ) . map ( |f| f. mt . ty ) ) ;
2472
2472
seen. pop ( ) ;
2473
2473
r
@@ -2478,8 +2478,10 @@ pub fn is_type_representable(cx: &ctxt, ty: t) -> Representability {
2478
2478
2479
2479
let mut r = Representable ;
2480
2480
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) ;
2483
2485
2484
2486
if r != Representable { break }
2485
2487
}
@@ -2499,7 +2501,7 @@ pub fn is_type_representable(cx: &ctxt, ty: t) -> Representability {
2499
2501
// contains a different, structurally recursive type, maintain a stack
2500
2502
// of seen types and check recursion for each of them (issues #3008, #3779).
2501
2503
let mut seen: Vec < DefId > = Vec :: new ( ) ;
2502
- type_structurally_recursive ( cx, & mut seen, ty)
2504
+ type_structurally_recursive ( cx, sp , & mut seen, ty)
2503
2505
}
2504
2506
2505
2507
pub fn type_is_trait ( ty : t ) -> bool {
0 commit comments