Add builtin for PtrLen
diff --git a/gen/src/builtin.rs b/gen/src/builtin.rs
index a1393b5..8a65b5f 100644
--- a/gen/src/builtin.rs
+++ b/gen/src/builtin.rs
@@ -16,6 +16,7 @@
     pub manually_drop: bool,
     pub maybe_uninit: bool,
     pub trycatch: bool,
+    pub ptr_len: bool,
     pub rust_str_new_unchecked: bool,
     pub rust_str_repr: bool,
     pub content: Content,
@@ -90,11 +91,7 @@
 
     out.begin_block("namespace");
 
-    if builtin.trycatch
-        || builtin.rust_error
-        || builtin.rust_str_new_unchecked
-        || builtin.rust_str_repr
-    {
+    if builtin.ptr_len {
         out.begin_block("namespace repr");
         writeln!(out, "struct PtrLen final {{");
         writeln!(out, "  const void *ptr;");
diff --git a/gen/src/write.rs b/gen/src/write.rs
index c690995..8af2fe5 100644
--- a/gen/src/write.rs
+++ b/gen/src/write.rs
@@ -353,6 +353,7 @@
         write!(out, "{} ", annotation);
     }
     if efn.throws {
+        out.builtin.ptr_len = true;
         write!(out, "::rust::repr::PtrLen ");
     } else {
         write_extern_return_type_space(out, &efn.ret);
@@ -425,6 +426,7 @@
     writeln!(out, ";");
     write!(out, "  ");
     if efn.throws {
+        out.builtin.ptr_len = true;
         out.builtin.trycatch = true;
         writeln!(out, "::rust::repr::PtrLen throw$;");
         writeln!(out, "  ::rust::behavior::trycatch(");
@@ -551,6 +553,7 @@
     indirect_call: bool,
 ) {
     if sig.throws {
+        out.builtin.ptr_len = true;
         write!(out, "::rust::repr::PtrLen ");
     } else {
         write_extern_return_type_space(out, &sig.ret);
@@ -695,6 +698,7 @@
         }
     }
     if sig.throws {
+        out.builtin.ptr_len = true;
         write!(out, "::rust::repr::PtrLen error$ = ");
     }
     write!(out, "{}(", invoke);
@@ -811,7 +815,10 @@
             write_type(out, &ty.inner);
             write!(out, " *");
         }
-        Some(Type::Str(_)) => write!(out, "::rust::repr::PtrLen "),
+        Some(Type::Str(_)) => {
+            out.builtin.ptr_len = true;
+            write!(out, "::rust::repr::PtrLen ");
+        }
         Some(Type::SliceRefU8(_)) => write!(out, "::rust::Slice<uint8_t>::Repr "),
         Some(ty) if out.types.needs_indirect_abi(ty) => write!(out, "void "),
         _ => write_return_type(out, ty),
@@ -824,7 +831,10 @@
             write_type_space(out, &ty.inner);
             write!(out, "*");
         }
-        Type::Str(_) => write!(out, "::rust::repr::PtrLen "),
+        Type::Str(_) => {
+            out.builtin.ptr_len = true;
+            write!(out, "::rust::repr::PtrLen ");
+        }
         Type::SliceRefU8(_) => write!(out, "::rust::Slice<uint8_t>::Repr "),
         _ => write_type_space(out, &arg.ty),
     }