about summary refs log tree commit diff
path: root/src/test/compile-fail/unsafe-alias.rs
AgeCommit message (Collapse)AuthorLines
2011-10-20Make fn denote a bare function. Convert fn to fn@ as neededBrian Anderson-1/+1
2011-09-12Reformat for new mode syntax, step 1Marijn Haverbeke-4/+2
Long lines were fixed in a very crude way, as I'll be following up with another reformat in a bit.
2011-09-12Fix tests for new argument-passing conventionMarijn Haverbeke-3/+8
2011-08-20ReformatBrian Anderson-2/+2
This changes the indexing syntax from .() to [], the vector syntax from ~[] to [] and the extension syntax from #fmt() to #fmt[]
2011-07-27Reformat for new syntaxMarijn Haverbeke-10/+3
2011-06-09A revised, improved alias-checkerMarijn Haverbeke-3/+7
The old system tried to ensure that the location an alias pointed at would retain its type. That turned out to not be strong enough in the face of aliases to the inside of tags. The new system instead proves that values pointed to by aliases are not replaced (or invalidated in some other way) at all. It knows of two sufficient conditions for this, and tries to prove at least of them: A) The alias is 'immutably rooted' in a local, and this local is not reassigned for the lifetime of the alias. Immutably rooted means the alias refers to the local itself, or to something reachable from the local through immutable dereferencing. B) No value whose type might include the type of the 'inner mutable element' of the thing the alias refers to (for example, the box in rec(mutable x = @mutable int)) is from the outer scope is accessed for the lifetime of the alias. This means for functions, no other argument types may include the alias's inner mutable type. For alt, for each, and for, it means the body does not refer to any locals originating from outside their scope that include this type. The lifetime of an alias in an alt, for each, or for body is defined as the range from its definition to its last use, not to the point where it goes out of scope. This makes working around these restrictions somewhat less annoying. For example, you can assign to your alt-ed value you don't refer to any bindings afterwards.
2011-06-06First take on an alias-safety checkerMarijn Haverbeke-0/+10
The alias checker works by ensuring that any value to which an alias is created is rooted in some way that ensures it outlives the alias. It is now disallowed to create an alias to the content of a mutable box, or to a box hanging off a mutable field. There is also machinery in place to prevent assignment to local variables whenever they are the root of a live alias.