about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2012-08-02 14:23:04 -0700
committerTim Chevalier <chevalier@alum.wellesley.edu>2012-08-02 23:53:45 -0700
commit948172b93fc5d31b7234ad98ff6bac466401a86a (patch)
tree1460fdb5dc1d5126a985f2bca9bbd5dc525f32ac /src/libstd
parent31c5cec55bd8b43e6082f79dff888f52b585621d (diff)
Make comparisons between region pointers work
Region pointers were considered a scalar type, so compare_scalar_type would
get called to compare region pointers in trans. This would fail, since
compare_scalar_type has no case for region pointers.

Changed type_is_scalar to return false for region pointers. This had the side
effect of breaking casts to types of the form &T. To ameliorate that, I added
library functions ptr::assimilate (taking a &T to a *T) and ptr::to_uint
(taking a &T to a uint), both of which use reinterpret_cast.

While I was at it, I removed ty::type_has_resources, which is dead code.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/uv_ll.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs
index 7b4033d0ff3..108abace1c9 100644
--- a/src/libstd/uv_ll.rs
+++ b/src/libstd/uv_ll.rs
@@ -21,6 +21,7 @@
  */
 
 import libc::size_t;
+import ptr::assimilate;
 
 // libuv struct mappings
 type uv_ip4_addr = {
@@ -822,7 +823,7 @@ unsafe fn ip4_name(src: &sockaddr_in) -> ~str {
     let dst: ~[u8] = ~[0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8,
                      0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8];
     do vec::as_buf(dst) |dst_buf, size| {
-        rustrt::rust_uv_ip4_name(src as *sockaddr_in,
+        rustrt::rust_uv_ip4_name(assimilate(src),
                                  dst_buf, size as libc::size_t);
         // seems that checking the result of uv_ip4_name
         // doesn't work too well..
@@ -842,7 +843,7 @@ unsafe fn ip6_name(src: &sockaddr_in6) -> ~str {
                        0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8,
                        0u8,0u8,0u8,0u8,0u8,0u8];
     do vec::as_buf(dst) |dst_buf, size| {
-        let src_unsafe_ptr = src as *sockaddr_in6;
+        let src_unsafe_ptr = assimilate(src);
         log(debug, fmt!{"val of src *sockaddr_in6: %? sockaddr_in6: %?",
                         src_unsafe_ptr, src});
         let result = rustrt::rust_uv_ip6_name(src_unsafe_ptr,