Skip to content

Remove @[] #11974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 49 commits into from
Feb 1, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
70c5a0f
libsyntax: Introduce an `InternedString` type to reduce `@str` in the
pcwalton Jan 8, 2014
8e52b85
libsyntax: De-`@str` literal strings in the AST
pcwalton Jan 10, 2014
a0646ae
libsyntax: De-`@str` `to_source`
pcwalton Jan 11, 2014
0327d8a
librustc: Fix merge fallout.
pcwalton Jan 13, 2014
f152be7
libsyntax: Remove the unnecessary `src` field from the lexer
pcwalton Jan 16, 2014
e68108b
librustc: Stop using `@str` for source.
pcwalton Jan 16, 2014
8d6ef2e
libsyntax: De-`@str` pathnames
pcwalton Jan 16, 2014
b496d7b
libsyntax: Make float literals not use `@str`
pcwalton Jan 16, 2014
f9af11d
libsyntax: Remove all `@str` from the AST
pcwalton Jan 16, 2014
cbf9f5f
libsyntax: De-`@str` `get_single_str_from_tts`
pcwalton Jan 16, 2014
3c9e9d3
libsyntax: Remove `ident_to_str` from the parser, which was returning
pcwalton Jan 16, 2014
a4dd3fe
librustc: Fix merge fallout.
pcwalton Jan 21, 2014
c5cbfe8
librustc: De-`@str` `NameAndSpan`
pcwalton Jan 30, 2014
52eeed2
libsyntax: De-`@str` `MacroDef`
pcwalton Jan 31, 2014
b890237
libsyntax: Fix tests.
pcwalton Jan 31, 2014
9869374
librustc: Remove a bunch of `@str` from the compiler around metadata
pcwalton Jan 31, 2014
daf5e6f
librustc: De-`@str` resolve
pcwalton Jan 31, 2014
1e0c07d
librustc: De-`@str` debuginfo
pcwalton Jan 31, 2014
b265dd4
librustc: De-`@str` symbol hashing
pcwalton Jan 31, 2014
e9ce855
librustc: De-`@str` liveness
pcwalton Jan 31, 2014
0f3a4e1
librustc: De-`@str` type short names
pcwalton Jan 31, 2014
19d4ea1
librustc: De-`@str` the LLVM symbol list
pcwalton Jan 31, 2014
21f8685
librustc: De-`@str` `ident()` and `str_of()`
pcwalton Jan 31, 2014
64a3a41
librustc: Get rid of calls to `token::ident_to_str` in debug info
pcwalton Jan 31, 2014
344040d
librustc: Get rid of `ident_to_str` calls in resolve
pcwalton Jan 31, 2014
e534b56
librustc: Remove uses of `token::ident_to_str()` from librustc
pcwalton Jan 31, 2014
875c9ce
libsyntax: Remove many uses of `token::ident_to_str`
pcwalton Jan 31, 2014
0d0a3da
libsyntax: Remove uses of `token::ident_to_str()`
pcwalton Jan 31, 2014
a695b62
librustc: Remove uses of `interner_get` in librustc
pcwalton Feb 1, 2014
e5dc347
libsyntax: Remove the `interner_get` function and all uses
pcwalton Feb 1, 2014
4018d77
libsyntax: Remove an `@str` in pretty printing
pcwalton Feb 1, 2014
17b0104
librustc: Remove one more `@str` from librustc
pcwalton Feb 1, 2014
7a80fa6
test: Remove `@str` from the test suite
pcwalton Feb 1, 2014
8b84192
libsyntax: Remove `@str` from the interner
pcwalton Feb 1, 2014
4dbcf80
doc: Remove references to `@str` from the documentation
pcwalton Feb 1, 2014
449a7a8
libextra: Remove `@str` from all the libraries
pcwalton Feb 1, 2014
c594e67
librustc: Remove `@str` from the language
pcwalton Feb 1, 2014
f502576
Fix `@str` removal tests.
huonw Feb 1, 2014
e0c1707
Changes from the review of the @str PR.
huonw Feb 1, 2014
2ed980f
std,extra: remove use of & support for @[].
huonw Feb 1, 2014
f63c3fb
arena: stop using @[].
huonw Feb 1, 2014
b972cad
Update/delete tests using @[].
huonw Feb 1, 2014
891ada9
syntax: convert LitBinary from @[u8] to Rc<~[u8]>.
huonw Feb 1, 2014
f8734df
rustc: remove use of @[].
huonw Feb 1, 2014
aadcf29
syntax: add an obsolete syntax warning for @[].
huonw Feb 1, 2014
e39cd20
syntax: remove the handling of @str and @[] from the parser completely.
huonw Feb 1, 2014
ec4b456
rustc: Remove the vstore handling of @str and @[].
huonw Feb 1, 2014
c8947c1
syntax: remove the unused Vstore enum.
huonw Feb 1, 2014
2125074
rustc: update docs & propagate @[]/@str removal more.
huonw Feb 1, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -3079,7 +3079,7 @@ A value of type `str` is a Unicode string,
represented as a vector of 8-bit unsigned bytes holding a sequence of UTF-8 codepoints.
Since `str` is of unknown size, it is not a _first class_ type,
but can only be instantiated through a pointer type,
such as `&str`, `@str` or `~str`.
such as `&str` or `~str`.

### Tuple types

Expand Down Expand Up @@ -3115,7 +3115,7 @@ Such a definite-sized vector type is a first-class type, since its size is known
A vector without such a size is said to be of _indefinite_ size,
and is therefore not a _first-class_ type.
An indefinite-size vector can only be instantiated through a pointer type,
such as `&[T]`, `@[T]` or `~[T]`.
such as `&[T]` or `~[T]`.
The kind of a vector type depends on the kind of its element type,
as with other simple structural types.

Expand Down
42 changes: 23 additions & 19 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,38 @@ extern mod extra;
use extra::list::{List, Cons, Nil};
use extra::list;

use std::at_vec;
use std::cast::{transmute, transmute_mut, transmute_mut_region};
use std::cast;
use std::cell::{Cell, RefCell};
use std::num;
use std::ptr;
use std::kinds::marker;
use std::mem;
use std::rc::Rc;
use std::rt::global_heap;
use std::unstable::intrinsics::{TyDesc, get_tydesc};
use std::unstable::intrinsics;
use std::util;
use std::vec;

// The way arena uses arrays is really deeply awful. The arrays are
// allocated, and have capacities reserved, but the fill for the array
// will always stay at 0.
#[deriving(Clone)]
struct Chunk {
data: RefCell<@[u8]>,
data: Rc<RefCell<~[u8]>>,
fill: Cell<uint>,
is_pod: Cell<bool>,
}
impl Chunk {
fn capacity(&self) -> uint {
self.data.borrow().borrow().get().capacity()
}

unsafe fn as_ptr(&self) -> *u8 {
self.data.borrow().borrow().get().as_ptr()
}
}

// Arenas are used to quickly allocate objects that share a
// lifetime. The arena uses ~[u8] vectors as a backing store to
Expand Down Expand Up @@ -97,10 +107,8 @@ impl Arena {
}

fn chunk(size: uint, is_pod: bool) -> Chunk {
let mut v: @[u8] = @[];
unsafe { at_vec::raw::reserve(&mut v, size); }
Chunk {
data: RefCell::new(unsafe { cast::transmute(v) }),
data: Rc::new(RefCell::new(vec::with_capacity(size))),
fill: Cell::new(0u),
is_pod: Cell::new(is_pod),
}
Expand Down Expand Up @@ -131,10 +139,7 @@ fn round_up(base: uint, align: uint) -> uint {
// in it.
unsafe fn destroy_chunk(chunk: &Chunk) {
let mut idx = 0;
let buf = {
let data = chunk.data.borrow();
data.get().as_ptr()
};
let buf = chunk.as_ptr();
let fill = chunk.fill.get();

while idx < fill {
Expand Down Expand Up @@ -172,11 +177,13 @@ unsafe fn un_bitpack_tydesc_ptr(p: uint) -> (*TyDesc, bool) {
}

impl Arena {
fn chunk_size(&self) -> uint {
self.pod_head.capacity()
}
// Functions for the POD part of the arena
fn alloc_pod_grow(&mut self, n_bytes: uint, align: uint) -> *u8 {
// Allocate a new chunk.
let chunk_size = at_vec::capacity(self.pod_head.data.get());
let new_min_chunk_size = num::max(n_bytes, chunk_size);
let new_min_chunk_size = num::max(n_bytes, self.chunk_size());
self.chunks.set(@Cons(self.pod_head.clone(), self.chunks.get()));
self.pod_head =
chunk(num::next_power_of_two(new_min_chunk_size + 1u), true);
Expand All @@ -190,15 +197,15 @@ impl Arena {
let this = transmute_mut_region(self);
let start = round_up(this.pod_head.fill.get(), align);
let end = start + n_bytes;
if end > at_vec::capacity(this.pod_head.data.get()) {
if end > self.chunk_size() {
return this.alloc_pod_grow(n_bytes, align);
}
this.pod_head.fill.set(end);

//debug!("idx = {}, size = {}, align = {}, fill = {}",
// start, n_bytes, align, head.fill.get());

ptr::offset(this.pod_head.data.get().as_ptr(), start as int)
this.pod_head.as_ptr().offset(start as int)
}
}

Expand All @@ -217,8 +224,7 @@ impl Arena {
fn alloc_nonpod_grow(&mut self, n_bytes: uint, align: uint)
-> (*u8, *u8) {
// Allocate a new chunk.
let chunk_size = at_vec::capacity(self.head.data.get());
let new_min_chunk_size = num::max(n_bytes, chunk_size);
let new_min_chunk_size = num::max(n_bytes, self.chunk_size());
self.chunks.set(@Cons(self.head.clone(), self.chunks.get()));
self.head =
chunk(num::next_power_of_two(new_min_chunk_size + 1u), false);
Expand All @@ -244,7 +250,7 @@ impl Arena {
end = start + n_bytes;
}

if end > at_vec::capacity(self.head.data.get()) {
if end > self.head.capacity() {
return self.alloc_nonpod_grow(n_bytes, align);
}

Expand All @@ -254,7 +260,7 @@ impl Arena {
//debug!("idx = {}, size = {}, align = {}, fill = {}",
// start, n_bytes, align, head.fill);

let buf = self.head.data.get().as_ptr();
let buf = self.head.as_ptr();
return (ptr::offset(buf, tydesc_start as int), ptr::offset(buf, start as int));
}
}
Expand Down Expand Up @@ -606,5 +612,3 @@ mod test {
})
}
}


2 changes: 1 addition & 1 deletion src/libextra/num/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub mod BigDigit {
/**
A big unsigned integer type.

A `BigUint`-typed value `BigUint { data: @[a, b, c] }` represents a number
A `BigUint`-typed value `BigUint { data: ~[a, b, c] }` represents a number
`(a + b * BigDigit::base + c * BigDigit::base^2)`.
*/
#[deriving(Clone)]
Expand Down
33 changes: 0 additions & 33 deletions src/libextra/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Core encoding and decoding interfaces.
#[forbid(non_camel_case_types)];


use std::at_vec;
use std::hashmap::{HashMap, HashSet};
use std::rc::Rc;
use std::trie::{TrieMap, TrieSet};
Expand Down Expand Up @@ -310,18 +309,6 @@ impl<D:Decoder> Decodable<D> for ~str {
}
}

impl<S:Encoder> Encodable<S> for @str {
fn encode(&self, s: &mut S) {
s.emit_str(*self)
}
}

impl<D:Decoder> Decodable<D> for @str {
fn decode(d: &mut D) -> @str {
d.read_str().to_managed()
}
}

impl<S:Encoder> Encodable<S> for f32 {
fn encode(&self, s: &mut S) {
s.emit_f32(*self)
Expand Down Expand Up @@ -456,26 +443,6 @@ impl<D:Decoder,T:Decodable<D>> Decodable<D> for ~[T] {
}
}

impl<S:Encoder,T:Encodable<S>> Encodable<S> for @[T] {
fn encode(&self, s: &mut S) {
s.emit_seq(self.len(), |s| {
for (i, e) in self.iter().enumerate() {
s.emit_seq_elt(i, |s| e.encode(s))
}
})
}
}

impl<D:Decoder,T:Decodable<D>> Decodable<D> for @[T] {
fn decode(d: &mut D) -> @[T] {
d.read_seq(|d, len| {
at_vec::from_fn(len, |i| {
d.read_seq_elt(i, |d| Decodable::decode(d))
})
})
}
}

impl<S:Encoder,T:Encodable<S>> Encodable<S> for Option<T> {
fn encode(&self, s: &mut S) {
s.emit_option(|s| {
Expand Down
20 changes: 10 additions & 10 deletions src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,10 @@ pub fn build_link_meta(sess: Session,
symbol_hasher: &mut Sha256)
-> LinkMeta {
// This calculates CMH as defined above
fn crate_hash(symbol_hasher: &mut Sha256, crateid: &CrateId) -> @str {
fn crate_hash(symbol_hasher: &mut Sha256, crateid: &CrateId) -> ~str {
symbol_hasher.reset();
symbol_hasher.input_str(crateid.to_str());
truncated_hash_result(symbol_hasher).to_managed()
truncated_hash_result(symbol_hasher)
}

let crateid = match attr::find_crateid(attrs) {
Expand Down Expand Up @@ -510,7 +510,8 @@ fn truncated_hash_result(symbol_hasher: &mut Sha256) -> ~str {
pub fn symbol_hash(tcx: ty::ctxt,
symbol_hasher: &mut Sha256,
t: ty::t,
link_meta: &LinkMeta) -> @str {
link_meta: &LinkMeta)
-> ~str {
// NB: do *not* use abbrevs here as we want the symbol names
// to be independent of one another in the crate.

Expand All @@ -523,23 +524,22 @@ pub fn symbol_hash(tcx: ty::ctxt,
let mut hash = truncated_hash_result(symbol_hasher);
// Prefix with 'h' so that it never blends into adjacent digits
hash.unshift_char('h');
// tjc: allocation is unfortunate; need to change std::hash
hash.to_managed()
hash
}

pub fn get_symbol_hash(ccx: &CrateContext, t: ty::t) -> @str {
pub fn get_symbol_hash(ccx: &CrateContext, t: ty::t) -> ~str {
{
let type_hashcodes = ccx.type_hashcodes.borrow();
match type_hashcodes.get().find(&t) {
Some(&h) => return h,
Some(h) => return h.to_str(),
None => {}
}
}

let mut type_hashcodes = ccx.type_hashcodes.borrow_mut();
let mut symbol_hasher = ccx.symbol_hasher.borrow_mut();
let hash = symbol_hash(ccx.tcx, symbol_hasher.get(), t, &ccx.link_meta);
type_hashcodes.get().insert(t, hash);
type_hashcodes.get().insert(t, hash.clone());
hash
}

Expand Down Expand Up @@ -963,7 +963,7 @@ fn link_staticlib(sess: Session, obj_filename: &Path, out_filename: &Path) {

let crates = sess.cstore.get_used_crates(cstore::RequireStatic);
for &(cnum, ref path) in crates.iter() {
let name = sess.cstore.get_crate_data(cnum).name;
let name = sess.cstore.get_crate_data(cnum).name.clone();
let p = match *path {
Some(ref p) => p.clone(), None => {
sess.err(format!("could not find rlib for: `{}`", name));
Expand Down Expand Up @@ -1221,7 +1221,7 @@ fn add_upstream_rust_crates(args: &mut ~[~str], sess: Session,
// If we're not doing LTO, then our job is simply to just link
// against the archive.
if sess.lto() {
let name = sess.cstore.get_crate_data(cnum).name;
let name = sess.cstore.get_crate_data(cnum).name.clone();
time(sess.time_passes(), format!("altering {}.rlib", name),
(), |()| {
let dst = tmpdir.join(cratepath.filename().unwrap());
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub fn run(sess: session::Session, llmod: ModuleRef,
// module that we've got.
let crates = sess.cstore.get_used_crates(cstore::RequireStatic);
for (cnum, path) in crates.move_iter() {
let name = sess.cstore.get_crate_data(cnum).name;
let name = sess.cstore.get_crate_data(cnum).name.clone();
let path = match path {
Some(p) => p,
None => {
Expand Down
Loading