Remove all #[cfg(stage0)]-protected code

New snapshot means this can all go. Also removes places that have
comments that say they are workarounds for stage0 errors.
This commit is contained in:
James Miller 2013-06-20 17:15:50 +12:00 committed by James Miller
parent 6759ce4fd2
commit 3bc4d1a120
20 changed files with 15 additions and 369 deletions

View File

@ -80,7 +80,6 @@ impl<T: Clone + Num> Cmplx<T> {
}
}
#[cfg(not(stage0))] // Fixed by #4228
impl<T: Clone + Algebraic + Num> Cmplx<T> {
/// Calculate |self|
#[inline]
@ -89,7 +88,6 @@ impl<T: Clone + Algebraic + Num> Cmplx<T> {
}
}
#[cfg(not(stage0))] // Fixed by #4228
impl<T: Clone + Trigonometric + Algebraic + Num> Cmplx<T> {
/// Calculate the principal Arg of self.
#[inline]

View File

@ -32,16 +32,10 @@ Rust extras are part of the standard Rust distribution.
#[deny(non_camel_case_types)];
#[deny(missing_doc)];
// NOTE: remove these two attributes after the next snapshot
#[no_core]; // for stage0
#[allow(unrecognized_lint)]; // otherwise stage0 is seriously ugly
#[no_std];
extern mod core(name = "std", vers = "0.7-pre");
#[cfg(stage0)]
use core::{str, unstable};
use core::str::{StrSlice, OwnedStr};
pub use core::os;

View File

@ -275,7 +275,7 @@ priv fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
let mut i = 0u;
let len = strs.len();
while i < len {
match strs[i] { // can't use let due to stage0 bugs
match strs[i] { // can't use let due to let-pattern bugs
(ref needle, value) => {
if match_str(ss, pos, *needle) {
return Some((value, pos + needle.len()));

View File

@ -174,19 +174,6 @@ pub fn get_absolute_rpath(lib: &Path) -> Path {
os::make_absolute(lib).dir_path()
}
#[cfg(stage0)]
pub fn get_install_prefix_rpath(target_triple: &str) -> Path {
let install_prefix = env!("CFG_PREFIX");
if install_prefix.is_empty() {
fail!("rustc compiled without CFG_PREFIX environment variable");
}
let tlib = filesearch::relative_target_lib_path(target_triple);
os::make_absolute(&Path(install_prefix).push_rel(&tlib))
}
#[cfg(not(stage0))]
pub fn get_install_prefix_rpath(target_triple: &str) -> Path {
let install_prefix = env!("CFG_PREFIX");

View File

@ -521,25 +521,6 @@ pub fn build_target_config(sopts: @session::options,
return target_cfg;
}
#[cfg(stage0)]
pub fn host_triple() -> ~str {
// Get the host triple out of the build environment. This ensures that our
// idea of the host triple is the same as for the set of libraries we've
// actually built. We can't just take LLVM's host triple because they
// normalize all ix86 architectures to i386.
//
// Instead of grabbing the host triple (for the current host), we grab (at
// compile time) the target triple that this rustc is built with and
// calling that (at runtime) the host triple.
let ht = env!("CFG_COMPILER_TRIPLE");
return if ht != ~"" {
ht
} else {
fail!("rustc built without CFG_COMPILER_TRIPLE")
};
}
#[cfg(not(stage0))]
pub fn host_triple() -> ~str {
// Get the host triple out of the build environment. This ensures that our
// idea of the host triple is the same as for the set of libraries we've

View File

@ -749,11 +749,7 @@ impl Liveness {
None => {
// Vanilla 'break' or 'loop', so use the enclosing
// loop scope
let len = { // FIXME(#5074) stage0
let loop_scope = &mut *self.loop_scope;
loop_scope.len()
};
if len == 0 {
if self.loop_scope.len() == 0 {
self.tcx.sess.span_bug(sp, "break outside loop");
} else {
// FIXME(#5275): this shouldn't have to be a method...

View File

@ -1318,7 +1318,7 @@ pub fn cleanup_and_leave(bcx: block,
match cur.kind {
block_scope(inf) if !inf.empty_cleanups() => {
let (sub_cx, dest, inf_cleanups) = {
let inf = &mut *inf; // FIXME(#5074) workaround stage0
let inf = &mut *inf;
let mut skip = 0;
let mut dest = None;
{

View File

@ -248,16 +248,9 @@ fn lookup_vtable(vcx: &VtableContext,
// Nothing found. Continue.
}
Some(implementations) => {
let len = { // FIXME(#5074): stage0 requires it
let implementations: &mut ~[@Impl] = *implementations;
implementations.len()
};
// implementations is the list of all impls in scope for
// trait_ref. (Usually, there's just one.)
for uint::range(0, len) |i| {
let im = implementations[i];
for implementations.iter().advance |im| {
// im is one specific impl of trait_ref.
// First, ensure we haven't processed this impl yet.

View File

@ -520,12 +520,8 @@ impl CoherenceChecker {
match extension_methods.find(&trait_def_id) {
Some(impls) => {
let len = { // FIXME(#5074) stage0 requires this
let impls: &mut ~[@Impl] = *impls;
impls.len()
};
for uint::range(0, len) |i| {
f(impls[i]);
for impls.iter().advance |&im| {
f(im);
}
}
None => { /* no impls? */ }

View File

@ -28,16 +28,8 @@ extern mod core(name = "std");
extern mod extra(name = "extra");
extern mod syntax;
// For deriving(Encodable) purposes...
#[cfg(stage0)]
extern mod std(name = "extra", vers = "0.7-pre");
#[cfg(not(stage0))]
extern mod std(name = "std", vers = "0.7-pre");
// For bootstrapping purposes.
#[cfg(stage0)]
pub use core::unstable;
use core::prelude::*;
use driver::driver::{host_triple, optgroups, early_error};

View File

@ -14,21 +14,8 @@ use sys;
use unstable::intrinsics;
/// Casts the value at `src` to U. The two types must have the same length.
#[cfg(stage0)]
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
let mut dest: U = intrinsics::uninit();
{
let dest_ptr: *mut u8 = transmute(&mut dest);
let src_ptr: *u8 = transmute(src);
intrinsics::memmove64(dest_ptr,
src_ptr,
sys::size_of::<U>() as u64);
}
dest
}
/// Casts the value at `src` to U. The two types must have the same length.
#[cfg(target_word_size = "32", not(stage0))]
#[cfg(target_word_size = "32")]
#[inline]
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
let mut dest: U = intrinsics::uninit();
@ -39,7 +26,7 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
}
/// Casts the value at `src` to U. The two types must have the same length.
#[cfg(target_word_size = "64", not(stage0))]
#[cfg(target_word_size = "64")]
#[inline]
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
let mut dest: U = intrinsics::uninit();

View File

@ -57,10 +57,6 @@ they contained the following prologue:
#[license = "MIT/ASL2"];
#[crate_type = "lib"];
// NOTE: remove these two attributes after the next snapshot
#[no_core]; // for stage0
#[allow(unrecognized_lint)]; // otherwise stage0 is seriously ugly
// Don't link to std. We are std.
#[no_std];

View File

@ -1654,9 +1654,7 @@ impl Writer for BytesWriter {
vec::reserve(bytes, count);
unsafe {
// Silly stage0 borrow check workaround...
let casted: &mut ~[u8] = cast::transmute_copy(&bytes);
vec::raw::set_len(casted, count);
vec::raw::set_len(bytes, count);
let view = vec::mut_slice(*bytes, *self.pos, count);
vec::bytes::copy_memory(view, v, v_len);

View File

@ -75,21 +75,7 @@ pub fn is_not_null<T>(ptr: *const T) -> bool { !is_null(ptr) }
* and destination may overlap.
*/
#[inline]
#[cfg(target_word_size = "32", stage0)]
pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
use unstable::intrinsics::memmove32;
let n = count * sys::size_of::<T>();
memmove32(dst as *mut u8, src as *u8, n as u32);
}
/**
* Copies data from one location to another.
*
* Copies `count` elements (not bytes) from `src` to `dst`. The source
* and destination may overlap.
*/
#[inline]
#[cfg(target_word_size = "32", not(stage0))]
#[cfg(target_word_size = "32")]
pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
use unstable::intrinsics::memmove32;
memmove32(dst, src as *T, count as u32);
@ -102,21 +88,7 @@ pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
* and destination may overlap.
*/
#[inline]
#[cfg(target_word_size = "64", stage0)]
pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
use unstable::intrinsics::memmove64;
let n = count * sys::size_of::<T>();
memmove64(dst as *mut u8, src as *u8, n as u64);
}
/**
* Copies data from one location to another.
*
* Copies `count` elements (not bytes) from `src` to `dst`. The source
* and destination may overlap.
*/
#[inline]
#[cfg(target_word_size = "64", not(stage0))]
#[cfg(target_word_size = "64")]
pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
use unstable::intrinsics::memmove64;
memmove64(dst, src as *T, count as u64);
@ -129,21 +101,7 @@ pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
* and destination may *not* overlap.
*/
#[inline]
#[cfg(target_word_size = "32", stage0)]
pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: uint) {
use unstable::intrinsics::memmove32;
let n = count * sys::size_of::<T>();
memmove32(dst as *mut u8, src as *u8, n as u32);
}
/**
* Copies data from one location to another.
*
* Copies `count` elements (not bytes) from `src` to `dst`. The source
* and destination may *not* overlap.
*/
#[inline]
#[cfg(target_word_size = "32", not(stage0))]
#[cfg(target_word_size = "32")]
pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: uint) {
use unstable::intrinsics::memcpy32;
memcpy32(dst, src as *T, count as u32);
@ -156,21 +114,7 @@ pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: u
* and destination may *not* overlap.
*/
#[inline]
#[cfg(target_word_size = "64", stage0)]
pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: uint) {
use unstable::intrinsics::memmove64;
let n = count * sys::size_of::<T>();
memmove64(dst as *mut u8, src as *u8, n as u64);
}
/**
* Copies data from one location to another.
*
* Copies `count` elements (not bytes) from `src` to `dst`. The source
* and destination may *not* overlap.
*/
#[inline]
#[cfg(target_word_size = "64", not(stage0))]
#[cfg(target_word_size = "64")]
pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: uint) {
use unstable::intrinsics::memcpy64;
memcpy64(dst, src as *T, count as u64);
@ -181,7 +125,7 @@ pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: u
* bytes of memory starting at `dst` to `c`.
*/
#[inline]
#[cfg(target_word_size = "32", not(stage0))]
#[cfg(target_word_size = "32")]
pub unsafe fn set_memory<T>(dst: *mut T, c: u8, count: uint) {
use unstable::intrinsics::memset32;
memset32(dst, c, count as u32);
@ -192,7 +136,7 @@ pub unsafe fn set_memory<T>(dst: *mut T, c: u8, count: uint) {
* bytes of memory starting at `dst` to `c`.
*/
#[inline]
#[cfg(target_word_size = "64", not(stage0))]
#[cfg(target_word_size = "64")]
pub unsafe fn set_memory<T>(dst: *mut T, c: u8, count: uint) {
use unstable::intrinsics::memset64;
memset64(dst, c, count as u64);
@ -592,7 +536,6 @@ pub mod ptr_tests {
}
#[test]
#[cfg(not(stage0))]
fn test_set_memory() {
let mut xs = [0u8, ..20];
let ptr = vec::raw::to_mut_ptr(xs);

View File

@ -130,36 +130,23 @@ pub extern "rust-intrinsic" {
/// Equivalent to the `llvm.memcpy.p0i8.0i8.i32` intrinsic, with a size of
/// `count` * `size_of::<T>()` and an alignment of `min_align_of::<T>()`
#[cfg(not(stage0))]
pub fn memcpy32<T>(dst: *mut T, src: *T, count: u32);
/// Equivalent to the `llvm.memcpy.p0i8.0i8.i64` intrinsic, with a size of
/// `count` * `size_of::<T>()` and an alignment of `min_align_of::<T>()`
#[cfg(not(stage0))]
pub fn memcpy64<T>(dst: *mut T, src: *T, count: u64);
/// Equivalent to the `llvm.memmove.p0i8.0i8.i32` intrinsic.
#[cfg(stage0)]
pub fn memmove32(dst: *mut u8, src: *u8, size: u32);
/// Equivalent to the `llvm.memmove.p0i8.0i8.i64` intrinsic.
#[cfg(stage0)]
pub fn memmove64(dst: *mut u8, src: *u8, size: u64);
/// Equivalent to the `llvm.memmove.p0i8.0i8.i32` intrinsic, with a size of
/// `count` * `size_of::<T>()` and an alignment of `min_align_of::<T>()`
#[cfg(not(stage0))]
pub fn memmove32<T>(dst: *mut T, src: *T, count: u32);
/// Equivalent to the `llvm.memmove.p0i8.0i8.i64` intrinsic, with a size of
/// `count` * `size_of::<T>()` and an alignment of `min_align_of::<T>()`
#[cfg(not(stage0))]
pub fn memmove64<T>(dst: *mut T, src: *T, count: u64);
/// Equivalent to the `llvm.memset.p0i8.i32` intrinsic, with a size of
/// `count` * `size_of::<T>()` and an alignment of `min_align_of::<T>()`
#[cfg(not(stage0))]
pub fn memset32<T>(dst: *mut T, val: u8, count: u32);
/// Equivalent to the `llvm.memset.p0i8.i64` intrinsic, with a size of
/// `count` * `size_of::<T>()` and an alignment of `min_align_of::<T>()`
#[cfg(not(stage0))]
pub fn memset64<T>(dst: *mut T, val: u8, count: u64);
pub fn sqrtf32(x: f32) -> f32;

View File

@ -402,94 +402,6 @@ impl ident_interner {
// return a fresh interner, preloaded with special identifiers.
#[cfg(stage0)]
fn mk_fresh_ident_interner() -> @ident_interner {
// the indices here must correspond to the numbers in
// special_idents.
let init_vec = ~[
"_", // 0
"anon", // 1
"", // 2
"unary", // 3
"!", // 4
"[]", // 5
"unary-", // 6
"__extensions__", // 7
"self", // 8
"item", // 9
"block", // 10
"stmt", // 11
"pat", // 12
"expr", // 13
"ty", // 14
"ident", // 15
"path", // 16
"tt", // 17
"matchers", // 18
"str", // 19
"TyVisitor", // 20
"arg", // 21
"descrim", // 22
"__rust_abi", // 23
"__rust_stack_shim", // 24
"TyDesc", // 25
"main", // 26
"<opaque>", // 27
"blk", // 28
"static", // 29
"intrinsic", // 30
"__foreign_mod__", // 31
"__field__", // 32
"C", // 33
"Self", // 34
"as", // 35
"break", // 36
"const", // 37
"copy", // 38
"do", // 39
"drop", // 40
"else", // 41
"enum", // 42
"extern", // 43
"false", // 44
"fn", // 45
"for", // 46
"if", // 47
"impl", // 48
"let", // 49
"__log", // 50
"loop", // 51
"match", // 52
"mod", // 53
"mut", // 54
"once", // 55
"priv", // 56
"pub", // 57
"pure", // 58
"ref", // 59
"return", // 60
"static", // 29 -- also a special ident
"self", // 8 -- also a special ident
"struct", // 61
"super", // 62
"true", // 63
"trait", // 64
"type", // 65
"unsafe", // 66
"use", // 67
"while", // 68
"be", // 69
];
@ident_interner {
interner: interner::StrInterner::prefill(init_vec)
}
}
// return a fresh interner, preloaded with special identifiers.
#[cfg(not(stage0))]
fn mk_fresh_ident_interner() -> @ident_interner {
// the indices here must correspond to the numbers in
// special_idents.
@ -700,48 +612,6 @@ pub mod keywords {
}
impl Keyword {
#[cfg(stage0)]
pub fn to_ident(&self) -> ident {
match *self {
As => ident { name: 35, ctxt: 0 },
Break => ident { name: 36, ctxt: 0 },
Const => ident { name: 37, ctxt: 0 },
Copy => ident { name: 38, ctxt: 0 },
Do => ident { name: 39, ctxt: 0 },
Else => ident { name: 41, ctxt: 0 },
Enum => ident { name: 42, ctxt: 0 },
Extern => ident { name: 43, ctxt: 0 },
False => ident { name: 44, ctxt: 0 },
Fn => ident { name: 45, ctxt: 0 },
For => ident { name: 46, ctxt: 0 },
If => ident { name: 47, ctxt: 0 },
Impl => ident { name: 48, ctxt: 0 },
Let => ident { name: 49, ctxt: 0 },
__Log => ident { name: 50, ctxt: 0 },
Loop => ident { name: 51, ctxt: 0 },
Match => ident { name: 52, ctxt: 0 },
Mod => ident { name: 53, ctxt: 0 },
Mut => ident { name: 54, ctxt: 0 },
Once => ident { name: 55, ctxt: 0 },
Priv => ident { name: 56, ctxt: 0 },
Pub => ident { name: 57, ctxt: 0 },
Pure => ident { name: 58, ctxt: 0 },
Ref => ident { name: 59, ctxt: 0 },
Return => ident { name: 60, ctxt: 0 },
Static => ident { name: 29, ctxt: 0 },
Self => ident { name: 8, ctxt: 0 },
Struct => ident { name: 61, ctxt: 0 },
Super => ident { name: 62, ctxt: 0 },
True => ident { name: 63, ctxt: 0 },
Trait => ident { name: 64, ctxt: 0 },
Type => ident { name: 65, ctxt: 0 },
Unsafe => ident { name: 66, ctxt: 0 },
Use => ident { name: 67, ctxt: 0 },
While => ident { name: 68, ctxt: 0 },
Be => ident { name: 69, ctxt: 0 },
}
}
#[cfg(not(stage0))]
pub fn to_ident(&self) -> ident {
match *self {
As => ident { name: 35, ctxt: 0 },
@ -792,18 +662,6 @@ pub fn is_keyword(kw: keywords::Keyword, tok: &Token) -> bool {
}
}
#[cfg(stage0)]
pub fn is_any_keyword(tok: &Token) -> bool {
match *tok {
token::IDENT(sid, false) => match sid.name {
8 | 29 | 35 .. 69 => true,
_ => false,
},
_ => false
}
}
#[cfg(not(stage0))]
pub fn is_any_keyword(tok: &Token) -> bool {
match *tok {
token::IDENT(sid, false) => match sid.name {
@ -814,18 +672,6 @@ pub fn is_any_keyword(tok: &Token) -> bool {
}
}
#[cfg(stage0)]
pub fn is_strict_keyword(tok: &Token) -> bool {
match *tok {
token::IDENT(sid, false) => match sid.name {
8 | 29 | 35 .. 68 => true,
_ => false,
},
_ => false,
}
}
#[cfg(not(stage0))]
pub fn is_strict_keyword(tok: &Token) -> bool {
match *tok {
token::IDENT(sid, false) => match sid.name {
@ -836,18 +682,6 @@ pub fn is_strict_keyword(tok: &Token) -> bool {
}
}
#[cfg(stage0)]
pub fn is_reserved_keyword(tok: &Token) -> bool {
match *tok {
token::IDENT(sid, false) => match sid.name {
69 => true,
_ => false,
},
_ => false,
}
}
#[cfg(not(stage0))]
pub fn is_reserved_keyword(tok: &Token) -> bool {
match *tok {
token::IDENT(sid, false) => match sid.name {

View File

@ -30,17 +30,8 @@ extern mod core(name = "std");
extern mod extra(name = "extra");
// For deriving(Encodable) purposes...
#[cfg(stage0)]
extern mod std(name = "extra");
#[cfg(not(stage0))]
extern mod std(name = "std");
// For bootstrapping purposes.
#[cfg(stage0)]
pub use core::str;
#[cfg(stage0)]
pub use core::unstable;
use core::prelude::*;
pub mod util {

View File

@ -732,17 +732,10 @@ rust_task_deref(rust_task *task) {
// Must call on rust stack.
extern "C" CDECL void
rust_call_tydesc_glue(void *root, size_t *tydesc, size_t glue_index) {
#ifdef _RUST_STAGE0
void (*glue_fn)(void *, void *, void *, void *) =
(void (*)(void *, void *, void *, void *))tydesc[glue_index];
if (glue_fn)
glue_fn(0, 0, 0, root);
#else
void (*glue_fn)(void *, void *, void *) =
(void (*)(void *, void *, void *))tydesc[glue_index];
if (glue_fn)
glue_fn(0, 0, root);
#endif
}
// Don't run on the Rust stack!
@ -762,11 +755,7 @@ public:
virtual void run() {
record_sp_limit(0);
#ifdef _RUST_STAGE0
fn.f(NULL, fn.env, NULL);
#else
fn.f(fn.env, NULL);
#endif
}
};

View File

@ -162,11 +162,7 @@ void task_start_wrapper(spawn_args *a)
bool threw_exception = false;
try {
#ifdef _RUST_STAGE0
a->f(NULL, a->envptr, a->argptr);
#else
a->f(a->envptr, a->argptr);
#endif
} catch (rust_task *ex) {
assert(ex == task && "Expected this task to be thrown for unwinding");
threw_exception = true;
@ -187,11 +183,7 @@ void task_start_wrapper(spawn_args *a)
if(env) {
// free the environment (which should be a unique closure).
const type_desc *td = env->td;
#ifdef _RUST_STAGE0
td->drop_glue(NULL, NULL, NULL, box_body(env));
#else
td->drop_glue(NULL, NULL, box_body(env));
#endif
task->kernel->region()->free(env);
}

View File

@ -21,19 +21,11 @@ struct rust_opaque_box;
// - the main function: has a NULL environment, but uses the void* arg
// - unique closures of type fn~(): have a non-NULL environment, but
// no arguments (and hence the final void*) is harmless
#ifdef _RUST_STAGE0
typedef void (*CDECL spawn_fn)(void *, rust_opaque_box*, void *);
#else
typedef void (*CDECL spawn_fn)(rust_opaque_box*, void *);
#endif
struct type_desc;
#ifdef _RUST_STAGE0
typedef void CDECL (glue_fn)(void *, void *, const type_desc **, void *);
#else
typedef void CDECL (glue_fn)(void *, const type_desc **, void *);
#endif
// Corresponds to the boxed data in the @ region. The body follows the
// header; you can obtain a ptr via box_body() below.