rustc: Obsolete the @ syntax entirely
This removes all remnants of `@` pointers from rustc. Additionally, this removes the `GC` structure from the prelude as it seems odd exporting an experimental type in the prelude by default. Closes #14193 [breaking-change]
This commit is contained in:
parent
f20b1293fc
commit
ade807c6dc
239 changed files with 922 additions and 561 deletions
|
|
@ -274,6 +274,7 @@ impl<T: 'static> Drop for Ref<T> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::prelude::*;
|
||||
use std::gc::{Gc, GC};
|
||||
use super::*;
|
||||
use std::task;
|
||||
|
||||
|
|
@ -329,11 +330,11 @@ mod tests {
|
|||
#[test]
|
||||
fn test_tls_multiple_types() {
|
||||
static str_key: Key<String> = &Key;
|
||||
static box_key: Key<@()> = &Key;
|
||||
static box_key: Key<Gc<()>> = &Key;
|
||||
static int_key: Key<int> = &Key;
|
||||
task::spawn(proc() {
|
||||
str_key.replace(Some("string data".to_string()));
|
||||
box_key.replace(Some(@()));
|
||||
box_key.replace(Some(box(GC) ()));
|
||||
int_key.replace(Some(42));
|
||||
});
|
||||
}
|
||||
|
|
@ -341,13 +342,13 @@ mod tests {
|
|||
#[test]
|
||||
fn test_tls_overwrite_multiple_types() {
|
||||
static str_key: Key<String> = &Key;
|
||||
static box_key: Key<@()> = &Key;
|
||||
static box_key: Key<Gc<()>> = &Key;
|
||||
static int_key: Key<int> = &Key;
|
||||
task::spawn(proc() {
|
||||
str_key.replace(Some("string data".to_string()));
|
||||
str_key.replace(Some("string data 2".to_string()));
|
||||
box_key.replace(Some(@()));
|
||||
box_key.replace(Some(@()));
|
||||
box_key.replace(Some(box(GC) ()));
|
||||
box_key.replace(Some(box(GC) ()));
|
||||
int_key.replace(Some(42));
|
||||
// This could cause a segfault if overwriting-destruction is done
|
||||
// with the crazy polymorphic transmute rather than the provided
|
||||
|
|
@ -360,13 +361,13 @@ mod tests {
|
|||
#[should_fail]
|
||||
fn test_tls_cleanup_on_failure() {
|
||||
static str_key: Key<String> = &Key;
|
||||
static box_key: Key<@()> = &Key;
|
||||
static box_key: Key<Gc<()>> = &Key;
|
||||
static int_key: Key<int> = &Key;
|
||||
str_key.replace(Some("parent data".to_string()));
|
||||
box_key.replace(Some(@()));
|
||||
box_key.replace(Some(box(GC) ()));
|
||||
task::spawn(proc() {
|
||||
str_key.replace(Some("string data".to_string()));
|
||||
box_key.replace(Some(@()));
|
||||
box_key.replace(Some(box(GC) ()));
|
||||
int_key.replace(Some(42));
|
||||
fail!();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -317,14 +317,15 @@ pub unsafe fn local_free(ptr: *u8) {
|
|||
mod bench {
|
||||
extern crate test;
|
||||
use self::test::Bencher;
|
||||
use std::gc::GC;
|
||||
|
||||
#[bench]
|
||||
fn alloc_managed_small(b: &mut Bencher) {
|
||||
b.iter(|| { @10; });
|
||||
b.iter(|| { box(GC) 10 });
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn alloc_managed_big(b: &mut Bencher) {
|
||||
b.iter(|| { @([10, ..1000]); });
|
||||
b.iter(|| { box(GC) ([10, ..1000]) });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -397,10 +397,11 @@ mod test {
|
|||
use super::*;
|
||||
use std::prelude::*;
|
||||
use std::task;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
#[test]
|
||||
fn local_heap() {
|
||||
let a = @5;
|
||||
let a = box(GC) 5;
|
||||
let b = a;
|
||||
assert!(*a == 5);
|
||||
assert!(*b == 5);
|
||||
|
|
@ -408,11 +409,11 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn tls() {
|
||||
local_data_key!(key: @String)
|
||||
key.replace(Some(@"data".to_string()));
|
||||
local_data_key!(key: Gc<String>)
|
||||
key.replace(Some(box(GC) "data".to_string()));
|
||||
assert_eq!(key.get().unwrap().as_slice(), "data");
|
||||
local_data_key!(key2: @String)
|
||||
key2.replace(Some(@"data".to_string()));
|
||||
local_data_key!(key2: Gc<String>)
|
||||
key2.replace(Some(box(GC) "data".to_string()));
|
||||
assert_eq!(key2.get().unwrap().as_slice(), "data");
|
||||
}
|
||||
|
||||
|
|
@ -452,11 +453,11 @@ mod test {
|
|||
use std::cell::RefCell;
|
||||
|
||||
struct List {
|
||||
next: Option<@RefCell<List>>,
|
||||
next: Option<Gc<RefCell<List>>>,
|
||||
}
|
||||
|
||||
let a = @RefCell::new(List { next: None });
|
||||
let b = @RefCell::new(List { next: Some(a) });
|
||||
let a = box(GC) RefCell::new(List { next: None });
|
||||
let b = box(GC) RefCell::new(List { next: Some(a) });
|
||||
|
||||
{
|
||||
let mut a = a.borrow_mut();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue