> let h1 = @hashmap::mk();
> let h2 = id(h1);    // identity fn; compiler can't see through this
> hashmap::insert(*h1, "foo", "bar");
> hashmap::get(*h1, "foo", { |&val|
>    hashmap::delete(h2, "foo");
>    print val;      // crash
> });

The alias checker would yell at you for the hashmap::delete line,
since you're accessing the h2 value, which might alias h1, whereas the
val alias is still live (is used in the next line).

(It would, in its current state, even yell at you if h2 was created
through a new call to hasmap::mk, since it doesn't yet do proper alias
analysis, just type-based. This is something I hope to improve in the
future.)
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to