@@ -259,10 +259,9 @@ fn ast_ty_to_ty(tcx: ty::ctxt, mode: mode, &&ast_ty: @ast::ty) -> ty::t {
259
259
alt tcx. ast_ty_to_ty_cache . find ( ast_ty) {
260
260
some ( some ( ty) ) { ret ty; }
261
261
some ( none) {
262
- tcx. sess . span_fatal ( ast_ty. span ,
263
- "illegal recursive type \
264
- insert a enum in the cycle, \
265
- if this is desired)") ;
262
+ tcx. sess . span_fatal ( ast_ty. span , "illegal recursive type. \
263
+ insert a enum in the cycle, \
264
+ if this is desired)") ;
266
265
}
267
266
none { }
268
267
} /* go on */
@@ -2490,7 +2489,7 @@ fn check_const(ccx: @crate_ctxt, _sp: span, e: @ast::expr, id: ast::node_id) {
2490
2489
demand:: simple ( fcx, e. span , declty, cty) ;
2491
2490
}
2492
2491
2493
- fn check_enum_variants ( ccx : @crate_ctxt , _sp : span , vs : [ ast:: variant ] ,
2492
+ fn check_enum_variants ( ccx : @crate_ctxt , sp : span , vs : [ ast:: variant ] ,
2494
2493
id : ast:: node_id ) {
2495
2494
// FIXME: this is kinda a kludge; we manufacture a fake function context
2496
2495
// and statement context for checking the initializer expression.
@@ -2512,7 +2511,7 @@ fn check_enum_variants(ccx: @crate_ctxt, _sp: span, vs: [ast::variant],
2512
2511
some ( e) {
2513
2512
check_expr ( fcx, e) ;
2514
2513
let cty = expr_ty ( fcx. ccx . tcx , e) ;
2515
- let declty =ty:: mk_int ( fcx. ccx . tcx ) ;
2514
+ let declty = ty:: mk_int ( fcx. ccx . tcx ) ;
2516
2515
demand:: simple ( fcx, e. span , declty, cty) ;
2517
2516
// FIXME: issue #1417
2518
2517
// Also, check_expr (from check_const pass) doesn't guarantee that
@@ -2537,6 +2536,20 @@ fn check_enum_variants(ccx: @crate_ctxt, _sp: span, vs: [ast::variant],
2537
2536
disr_vals += [ disr_val] ;
2538
2537
disr_val += 1 ;
2539
2538
}
2539
+ let outer = true , did = local_def ( id) ;
2540
+ if ty:: type_structurally_contains ( ccx. tcx , rty, { |sty|
2541
+ alt sty {
2542
+ ty : : ty_enum ( id, _) if id == did {
2543
+ if outer { outer = false ; false }
2544
+ else { true }
2545
+ }
2546
+ _ { false }
2547
+ }
2548
+ } ) {
2549
+ ccx. tcx . sess . span_fatal ( sp, "illegal recursive enum type. \
2550
+ wrap the inner value in a box to \
2551
+ make it represenable") ;
2552
+ }
2540
2553
}
2541
2554
2542
2555
// A generic function for checking the pred in a check
0 commit comments