about summary refs log tree commit diff
path: root/src/rustc/metadata
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2012-11-04 20:41:00 -0800
committerNiko Matsakis <niko@alum.mit.edu>2012-11-06 08:56:29 -0800
commitb0ed151539cddb1c191f67f9f9597942919d44eb (patch)
tree976ed7cab726c0cdae81e0a18e28a27cbd5e4664 /src/rustc/metadata
parent53ec6c3f9b495dd930cd061784251534bef58d74 (diff)
downloadrust-b0ed151539cddb1c191f67f9f9597942919d44eb.tar.gz
rust-b0ed151539cddb1c191f67f9f9597942919d44eb.zip
Cleanup how we handle proto in types, remove unsound subtyping
Fixes #1896 which was never truly fixed, just masked.
The given tests would have failed had they used `~fn()` and
not `@fn()`.  They now result in compilation errors.

Fixes #2978.

Necessary first step for #2202, #2263.
Diffstat (limited to 'src/rustc/metadata')
-rw-r--r--src/rustc/metadata/tydecode.rs21
-rw-r--r--src/rustc/metadata/tyencode.rs21
2 files changed, 21 insertions, 21 deletions
diff --git a/src/rustc/metadata/tydecode.rs b/src/rustc/metadata/tydecode.rs
index f15c254e71c..51c56cb8a64 100644
--- a/src/rustc/metadata/tydecode.rs
+++ b/src/rustc/metadata/tydecode.rs
@@ -103,11 +103,13 @@ fn parse_ty_rust_fn(st: @pstate, conv: conv_did) -> ty::t {
     return ty::mk_fn(st.tcx, parse_ty_fn(st, conv));
 }
 
-fn parse_proto(st: @pstate) -> ty::fn_proto {
+fn parse_proto(st: @pstate) -> ast::Proto {
     match next(st) {
-        'n' => ty::proto_bare,
-        'v' => ty::proto_vstore(parse_vstore(st)),
-        c => fail ~"illegal proto type kind " + str::from_char(c)
+        '_' => ast::ProtoBare,
+        '@' => ast::ProtoBox,
+        '~' => ast::ProtoUniq,
+        '&' => ast::ProtoBorrowed,
+        _ => fail ~"parse_proto(): bad input"
     }
 }
 
@@ -293,13 +295,8 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
       }
       'Y' => return ty::mk_type(st.tcx),
       'C' => {
-        let ck = match next(st) {
-          '&' => ty::ck_block,
-          '@' => ty::ck_box,
-          '~' => ty::ck_uniq,
-          _ => fail ~"parse_ty: bad closure kind"
-        };
-        return ty::mk_opaque_closure_ptr(st.tcx, ck);
+        let proto = parse_proto(st);
+        return ty::mk_opaque_closure_ptr(st.tcx, proto);
       }
       '#' => {
         let pos = parse_hex(st);
@@ -415,6 +412,7 @@ fn parse_ty_fn(st: @pstate, conv: conv_did) -> ty::FnTy {
     let proto = parse_proto(st);
     let purity = parse_purity(next(st));
     let onceness = parse_onceness(next(st));
+    let region = parse_region(st);
     let bounds = parse_bounds(st, conv);
     assert (next(st) == '[');
     let mut inputs: ~[ty::arg] = ~[];
@@ -429,6 +427,7 @@ fn parse_ty_fn(st: @pstate, conv: conv_did) -> ty::FnTy {
                       proto: proto,
                       onceness: onceness,
                       bounds: bounds,
+                      region: region,
                       ret_style: ret_style},
         sig: FnSig {inputs: inputs,
                     output: ret_ty}
diff --git a/src/rustc/metadata/tyencode.rs b/src/rustc/metadata/tyencode.rs
index 725b8c41f5c..4129066ff28 100644
--- a/src/rustc/metadata/tyencode.rs
+++ b/src/rustc/metadata/tyencode.rs
@@ -296,9 +296,10 @@ fn enc_sty(w: io::Writer, cx: @ctxt, st: ty::sty) {
         w.write_char('s');
       }
       ty::ty_type => w.write_char('Y'),
-      ty::ty_opaque_closure_ptr(ty::ck_block) => w.write_str(&"C&"),
-      ty::ty_opaque_closure_ptr(ty::ck_box) => w.write_str(&"C@"),
-      ty::ty_opaque_closure_ptr(ty::ck_uniq) => w.write_str(&"C~"),
+      ty::ty_opaque_closure_ptr(p) => {
+          w.write_str(&"C&");
+          enc_proto(w, p);
+      }
       ty::ty_opaque_box => w.write_char('B'),
       ty::ty_class(def, substs) => {
           debug!("~~~~ %s", ~"a[");
@@ -315,14 +316,13 @@ fn enc_sty(w: io::Writer, cx: @ctxt, st: ty::sty) {
     }
 }
 
-fn enc_proto(w: io::Writer, cx: @ctxt, proto: ty::fn_proto) {
+fn enc_proto(w: io::Writer, proto: Proto) {
     w.write_str(&"f");
     match proto {
-        ty::proto_bare => w.write_str(&"n"),
-        ty::proto_vstore(vstore) => {
-            w.write_str(&"v");
-            enc_vstore(w, cx, vstore);
-        }
+        ProtoBare => w.write_str(&"_"),
+        ProtoBox => w.write_str(&"@"),
+        ProtoUniq => w.write_str(&"~"),
+        ProtoBorrowed => w.write_str(&"&"),
     }
 }
 
@@ -357,9 +357,10 @@ fn enc_onceness(w: io::Writer, o: Onceness) {
 }
 
 fn enc_ty_fn(w: io::Writer, cx: @ctxt, ft: ty::FnTy) {
-    enc_proto(w, cx, ft.meta.proto);
+    enc_proto(w, ft.meta.proto);
     enc_purity(w, ft.meta.purity);
     enc_onceness(w, ft.meta.onceness);
+    enc_region(w, cx, ft.meta.region);
     enc_bounds(w, cx, ft.meta.bounds);
     w.write_char('[');
     for ft.sig.inputs.each |arg| {