nikomatsakis / borrowck

Modeling NLL and the Rust borrowck
Apache License 2.0
75 stars 12 forks source link

extend borrow checker to support unions #2

Open nikomatsakis opened 7 years ago

nikomatsakis commented 7 years ago

It may take some experimentation to find the best way to express this: at present, we can just use simple stuff like foo.contains(...) to search for overlap, but with unions this doesn't quite work. Well, we could make it work by mapping all union field to a single "meta-field" (or by creating loans of all fields when one field is borrowed, as in the current implementation) -- but I'd prefer to avoid that, because if/when we scale to fields in traits, that approach doesn't work. It also doesn't help us deal with indices. To deal properly, we want to have the ability to have paths like a.b.c and a.b.d that are considered to alias, even though c != d.