You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
View escape through a mut fn: self.v.push(&x) and self.r = &x store a local's view into the receiver unchecked (wider class of #1778) #1783
Found fixing #1778 (which covered Mutex.set/RwLock.write/guard write-back). The same escape through an ordinary mut fn still compiles:
type Holder = ephemeral { v: Vec[&i32], r: Option[&i32] }
extend Holder:
mut fn keep(x: &i32):
self.v.push(x) // stores a view of the caller's local into self
self.r = Some(x)
fn main:
var h = Holder { v: Vec.new(), r: None }
let n = 5
h.keep(&n)
// h outlives n's scope in other shapes; nothing checks
Expected (§21.1 / D22): a store of a view into a place owned by the receiver requires the view's origin to outlive the receiver; the checker must treat a mut fn's stores into self like #1778 treats Mutex.set. Second gap in the same class: Rule 7 (an implicit drop is a use) is not enforced here — a Drop holder given a view of a local declared after it compiles.
Activity
Views: a store records origins only when the stored value can hold a …
Views: a store into a place is a store into its root's storage, and a…
Closures: a callable parameter is a view in the callee, so storing or…
Views: a store records origins only when the stored value can hold a …
A Copy read through a reference owns what it holds: `*r` is ephemeral…
A Copy read through a reference owns what it holds: `*r` is ephemeral…
A Copy read through a reference owns what it holds: `*r` is ephemeral…
D70 namespaced types reachable when shadowed (#1757); generator stage…