const
expression can borrow static items by dingxiangfei2009 · Pull Request #1610 · rust-lang/reference (original) (raw)
Hm, I'm trying to unpack what you are saying here and align that with the current rules.
Reads from and writes to
static mut
…
Isn't this implied by the fact that you are not allowed to refer to static mut
at all by the rule that says paths only to immutable statics are allowed?
Reads from and writes to [..]
static
with interior mutability are also not allowed.
Thanks, I have added that.
And then there are restrictions on references that escape into the final value of the const/static.
Isn't this specified in the later rule that limits borrows of UnsafeCell
that are transient? (That was my reading of it, and why I didn't say it explicitly.)
And finally, specifically for
const
there also can't be any references to anything mutable in the final value.
Thanks, I have added that to the constant-items chapter.