]> git.lizzy.rs Git - rust.git/commitdiff
Merge pull request #447 from paulstansifer/quick_error_message_fix
authorPatrick Walton <pcwalton@mimiga.net>
Fri, 10 Jun 2011 17:53:42 +0000 (10:53 -0700)
committerPatrick Walton <pcwalton@mimiga.net>
Fri, 10 Jun 2011 17:53:42 +0000 (10:53 -0700)
Error message, instead of segfault, when recursive types are used.

1  2 
src/comp/front/ast.rs
src/comp/middle/ty.rs
src/comp/middle/typeck.rs

Simple merge
Simple merge
index 289691444b0b5c7baa6928986a07642a10d35482,0c21090d6e48acfe8cb7b4d168db3ca01a885f40..cf99f1ab4b18360689d49596ef9739b8574e3833
@@@ -219,12 -227,22 +219,22 @@@ fn type_is_scalar(&@fn_ctxt fcx, &span 
  // notion of a type. `getter` is a function that returns the type
  // corresponding to a definition ID:
  fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
+     alt (tcx.ast_ty_to_ty_cache.find(ast_ty)) {
+         case (some[option::t[ty::t]](some[ty::t](?ty))) { ret ty; } 
+         case (some[option::t[ty::t]](none)) {
+             tcx.sess.span_err(ast_ty.span, "illegal recursive type "
+                 + "(insert a tag in the cycle, if this is desired)");
+         }
+         case (none[option::t[ty::t]]) { } /* go on */
+     }
+     tcx.ast_ty_to_ty_cache.insert(ast_ty, none[ty::t]);
+     
      fn ast_arg_to_arg(&ty::ctxt tcx,
                        &ty_getter getter,
 -                      &rec(ast::mode mode, @ast::ty ty) arg)
 +                      &ast::ty_arg arg)
              -> rec(ty::mode mode, ty::t ty) {
 -        auto ty_mode = ast_mode_to_mode(arg.mode);
 -        ret rec(mode=ty_mode, ty=ast_ty_to_ty(tcx, getter, arg.ty));
 +        auto ty_mode = ast_mode_to_mode(arg.node.mode);
 +        ret rec(mode=ty_mode, ty=ast_ty_to_ty(tcx, getter, arg.node.ty));
      }
  
      fn ast_mt_to_mt(&ty::ctxt tcx,