]> git.lizzy.rs Git - rust.git/commit
Hack for "unsafety hygiene" -- `push_unsafe!` and `pop_unsafe!`.
authorFelix S. Klock II <pnkfelix@pnkfx.org>
Fri, 5 Jun 2015 06:31:27 +0000 (08:31 +0200)
committerFelix S. Klock II <pnkfelix@pnkfx.org>
Wed, 22 Jul 2015 13:33:59 +0000 (15:33 +0200)
commit1829fa5199bae5a192c771807c532badce14be37
tree83580d10f443b4af71c5722756e68ff1ac7526e9
parent25281b121ff809f35a6abd7d2d115995436c3319
Hack for "unsafety hygiene" -- `push_unsafe!` and `pop_unsafe!`.

Even after expansion, the generated expressions still track depth of
such pushes (i.e. how often you have "pushed" without a corresponding
"pop"), and we add a rule that in a context with a positive
`push_unsafe!` depth, it is effectively an `unsafe` block context.

(This way, we can inject code that uses `unsafe` features, but still
contains within it a sub-expression that should inherit the outer
safety checking setting, outside of the injected code.)

This is a total hack; it not only needs a feature-gate, but probably
should be feature-gated forever (if possible).

ignore-pretty in test/run-pass/pushpop-unsafe-okay.rs
12 files changed:
src/librustc/middle/effect.rs
src/librustc_typeck/check/mod.rs
src/libsyntax/ast.rs
src/libsyntax/ext/base.rs
src/libsyntax/ext/expand.rs
src/libsyntax/ext/pushpop_safe.rs [new file with mode: 0644]
src/libsyntax/feature_gate.rs
src/libsyntax/lib.rs
src/libsyntax/print/pprust.rs
src/test/compile-fail/feature-gate-pushpop-unsafe.rs [new file with mode: 0644]
src/test/compile-fail/pushpop-unsafe-rejects.rs [new file with mode: 0644]
src/test/run-pass/pushpop-unsafe-okay.rs [new file with mode: 0644]