Closed
Description
In trans::reachable
, there is the following code:
fn traverse_public_item(cx: &ctx, item: @item) {
let rmap: &mut HashSet<node_id> = cx.rmap;
if cx.rmap.contains(&item.id) { return; }
rmap.insert(item.id);
//...
}
A comment says that naming rmap
and giving it an explicit type should not be necessary, but with incoming, it still is. The error if I inline rmap
is:
/Users/tjc/rust2/src/librustc/middle/trans/reachable.rs:98:7: 98:14 error: illegal borrow unless pure: creating immutable alias to dereference of mutable & pointer
/Users/tjc/rust2/src/librustc/middle/trans/reachable.rs:98 if cx.rmap.contains(&item.id) { return; }
^~~~~~~
/Users/tjc/rust2/src/librustc/middle/trans/reachable.rs:98:7: 98:35 note: impure due to access to impure function
/Users/tjc/rust2/src/librustc/middle/trans/reachable.rs:98 if cx.rmap.contains(&item.id) { return; }
This confuses me since I thought we removed purity. Anyway, this was an XXX and I figured I would make it into a proper issue. (@nikomatsakis may know more.)