948172b93f
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.
18 lines
344 B
Rust
18 lines
344 B
Rust
import ptr::to_uint;
|
|
|
|
fn borrow(x: &int, f: fn(x: &int)) {
|
|
f(x)
|
|
}
|
|
|
|
fn test1(x: @~int) {
|
|
// Right now, at least, this induces a copy of the unique pointer:
|
|
do borrow({*x}) |p| {
|
|
let x_a = ptr::addr_of(**x);
|
|
assert (x_a as uint) != to_uint(p);
|
|
assert unsafe{*x_a} == *p;
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
test1(@~22);
|
|
} |