diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2015-10-12 15:50:12 +1300 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2015-10-12 15:50:12 +1300 |
| commit | d399098fd82e0bf3ed61bbbbcdbb0b6adfa4c808 (patch) | |
| tree | 67a2d3f272930c0a466e59bcaf262e28eb9bfdcf /src/test | |
| parent | 81b3b27cf533e50424f749d1c1db23e5d8db952f (diff) | |
| download | rust-d399098fd82e0bf3ed61bbbbcdbb0b6adfa4c808.tar.gz rust-d399098fd82e0bf3ed61bbbbcdbb0b6adfa4c808.zip | |
Remove the push_unsafe! and pop_unsafe! macros.
This is a [breaking change].
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/feature-gate-pushpop-unsafe.rs | 14 | ||||
| -rw-r--r-- | src/test/compile-fail/pushpop-unsafe-rejects.rs | 74 | ||||
| -rw-r--r-- | src/test/run-pass/pushpop-unsafe-okay.rs | 56 |
3 files changed, 0 insertions, 144 deletions
diff --git a/src/test/compile-fail/feature-gate-pushpop-unsafe.rs b/src/test/compile-fail/feature-gate-pushpop-unsafe.rs deleted file mode 100644 index e317b4c7d4d..00000000000 --- a/src/test/compile-fail/feature-gate-pushpop-unsafe.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let c = push_unsafe!('c'); //~ ERROR push/pop_unsafe macros are experimental - let c = pop_unsafe!('c'); //~ ERROR push/pop_unsafe macros are experimental -} diff --git a/src/test/compile-fail/pushpop-unsafe-rejects.rs b/src/test/compile-fail/pushpop-unsafe-rejects.rs deleted file mode 100644 index 72c065ae714..00000000000 --- a/src/test/compile-fail/pushpop-unsafe-rejects.rs +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Basic sanity check for `push_unsafe!(EXPR)` and -// `pop_unsafe!(EXPR)`: we can call unsafe code when there are a -// positive number of pushes in the stack, or if we are within a -// normal `unsafe` block, but otherwise cannot. - -#![feature(pushpop_unsafe)] - -static mut X: i32 = 0; - -unsafe fn f() { X += 1; return; } -fn g() { unsafe { X += 1_000; } return; } - -fn main() { - push_unsafe!( { - f(); pop_unsafe!({ - f() //~ ERROR: call to unsafe function - }) - } ); - - push_unsafe!({ - f(); - pop_unsafe!({ - g(); - f(); //~ ERROR: call to unsafe function - }) - } ); - - push_unsafe!({ - g(); pop_unsafe!({ - unsafe { - f(); - } - f(); //~ ERROR: call to unsafe function - }) - }); - - - // Note: For implementation simplicity the compiler just - // ICE's if you underflow the push_unsafe stack. - // - // Thus all of the following cases cause an ICE. - // - // (The "ERROR" notes are from an earlier version - // that used saturated arithmetic rather than checked - // arithmetic.) - - // pop_unsafe!{ g() }; - // - // push_unsafe!({ - // pop_unsafe!(pop_unsafe!{ g() }) - // }); - // - // push_unsafe!({ - // g(); - // pop_unsafe!(pop_unsafe!({ - // f() // ERROR: call to unsafe function - // })) - // }); - // - // pop_unsafe!({ - // f(); // ERROR: call to unsafe function - // }) - -} diff --git a/src/test/run-pass/pushpop-unsafe-okay.rs b/src/test/run-pass/pushpop-unsafe-okay.rs deleted file mode 100644 index fc402d41368..00000000000 --- a/src/test/run-pass/pushpop-unsafe-okay.rs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Basic sanity check for `push_unsafe!(EXPR)` and -// `pop_unsafe!(EXPR)`: we can call unsafe code when there are a -// positive number of pushes in the stack, or if we are within a -// normal `unsafe` block, but otherwise cannot. - -// ignore-pretty because the `push_unsafe!` and `pop_unsafe!` macros -// are not integrated with the pretty-printer. - -#![feature(pushpop_unsafe)] - -static mut X: i32 = 0; - -unsafe fn f() { X += 1; return; } -fn g() { unsafe { X += 1_000; } return; } - -fn check_reset_x(x: i32) -> bool { - #![allow(unused_parens)] // dont you judge my style choices! - unsafe { - let ret = (x == X); - X = 0; - ret - } -} - -fn main() { - // double-check test infrastructure - assert!(check_reset_x(0)); - unsafe { f(); } - assert!(check_reset_x(1)); - assert!(check_reset_x(0)); - { g(); } - assert!(check_reset_x(1000)); - assert!(check_reset_x(0)); - unsafe { f(); g(); g(); } - assert!(check_reset_x(2001)); - - push_unsafe!( { f(); pop_unsafe!( g() ) } ); - assert!(check_reset_x(1_001)); - push_unsafe!( { g(); pop_unsafe!( unsafe { f(); f(); } ) } ); - assert!(check_reset_x(1_002)); - - unsafe { push_unsafe!( { f(); pop_unsafe!( { f(); f(); } ) } ); } - assert!(check_reset_x(3)); - push_unsafe!( { f(); push_unsafe!( { pop_unsafe!( { f(); f(); f(); } ) } ); } ); - assert!(check_reset_x(4)); -} |
