]> git.lizzy.rs Git - rust.git/commit
auto merge of #12419 : huonw/rust/compiler-unsafe, r=alexcrichton
authorbors <bors@rust-lang.org>
Fri, 21 Feb 2014 15:06:51 +0000 (07:06 -0800)
committerbors <bors@rust-lang.org>
Fri, 21 Feb 2014 15:06:51 +0000 (07:06 -0800)
commitc6aaf2c7bd69af2a3fc9a109a8c3a6c3004616f2
treed5f71ef82ade3033bd3480e69ad9f7a3207171dd
parent2fa7d6b44fcc329e849f4dd43e11c6fdd43ebd76
parent5ec118383b39f00589dc72d01a0f510c1ed0511f
auto merge of #12419 : huonw/rust/compiler-unsafe, r=alexcrichton

Previously an `unsafe` block created by the compiler (like those in the
formatting macros) would be "ignored" if surrounded by `unsafe`, that
is, the internal unsafety would be being legitimised by the external
block:

    unsafe { println!("...") } =(expansion)=> unsafe { ... unsafe { ... } }

And the code in the inner block would be using the outer block, making
it considered used (and the inner one considered unused).

This patch forces the compiler to create a new unsafe context for
compiler generated blocks, so that their internal unsafety doesn't
escape to external blocks.

Fixes #12418.
src/librustc/middle/trans/base.rs
src/librustc/middle/typeck/check/mod.rs