Skip to content

libsyntax: Stop parsing [const T]. #5508

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

Closed
wants to merge 10 commits into from
24 changes: 12 additions & 12 deletions src/libcore/at_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub mod rustrt {

/// Returns the number of elements the vector can hold without reallocating
#[inline(always)]
pub fn capacity<T>(v: @[const T]) -> uint {
pub fn capacity<T>(v: @[T]) -> uint {
unsafe {
let repr: **raw::VecRepr =
::cast::reinterpret_cast(&addr_of(&v));
Expand All @@ -60,7 +60,7 @@ pub fn capacity<T>(v: @[const T]) -> uint {
*/
#[inline(always)]
pub fn build_sized<A>(size: uint, builder: &fn(push: &fn(v: A))) -> @[A] {
let mut vec: @[const A] = @[];
let mut vec: @[A] = @[];
unsafe { raw::reserve(&mut vec, size); }
builder(|+x| unsafe { raw::push(&mut vec, x) });
return unsafe { transmute(vec) };
Expand Down Expand Up @@ -102,7 +102,7 @@ pub fn build_sized_opt<A>(size: Option<uint>,

// Appending
#[inline(always)]
pub fn append<T:Copy>(lhs: @[T], rhs: &[const T]) -> @[T] {
pub fn append<T:Copy>(lhs: @[T], rhs: &const [T]) -> @[T] {
do build_sized(lhs.len() + rhs.len()) |push| {
for vec::each(lhs) |x| { push(*x); }
for uint::range(0, rhs.len()) |i| { push(rhs[i]); }
Expand Down Expand Up @@ -174,9 +174,9 @@ pub mod traits {
use kinds::Copy;
use ops::Add;

impl<T:Copy> Add<&'self [const T],@[T]> for @[T] {
impl<T:Copy> Add<&'self const [T],@[T]> for @[T] {
#[inline(always)]
fn add(&self, rhs: & &'self [const T]) -> @[T] {
fn add(&self, rhs: & &'self const [T]) -> @[T] {
append(*self, (*rhs))
}
}
Expand Down Expand Up @@ -207,13 +207,13 @@ pub mod raw {
* the vector is actually the specified size.
*/
#[inline(always)]
pub unsafe fn set_len<T>(v: @[const T], new_len: uint) {
pub unsafe fn set_len<T>(v: @[T], new_len: uint) {
let repr: **VecRepr = ::cast::reinterpret_cast(&addr_of(&v));
(**repr).unboxed.fill = new_len * sys::size_of::<T>();
}

#[inline(always)]
pub unsafe fn push<T>(v: &mut @[const T], initval: T) {
pub unsafe fn push<T>(v: &mut @[T], initval: T) {
let repr: **VecRepr = ::cast::reinterpret_cast(&v);
let fill = (**repr).unboxed.fill;
if (**repr).unboxed.alloc > fill {
Expand All @@ -225,7 +225,7 @@ pub mod raw {
}

#[inline(always)] // really pretty please
pub unsafe fn push_fast<T>(v: &mut @[const T], initval: T) {
pub unsafe fn push_fast<T>(v: &mut @[T], initval: T) {
let repr: **VecRepr = ::cast::reinterpret_cast(&v);
let fill = (**repr).unboxed.fill;
(**repr).unboxed.fill += sys::size_of::<T>();
Expand All @@ -234,7 +234,7 @@ pub mod raw {
move_val_init(&mut(*p), initval);
}

pub unsafe fn push_slow<T>(v: &mut @[const T], initval: T) {
pub unsafe fn push_slow<T>(v: &mut @[T], initval: T) {
reserve_at_least(&mut *v, v.len() + 1u);
push_fast(v, initval);
}
Expand All @@ -250,7 +250,7 @@ pub mod raw {
* * v - A vector
* * n - The number of elements to reserve space for
*/
pub unsafe fn reserve<T>(v: &mut @[const T], n: uint) {
pub unsafe fn reserve<T>(v: &mut @[T], n: uint) {
// Only make the (slow) call into the runtime if we have to
if capacity(*v) < n {
let ptr: **VecRepr = transmute(v);
Expand All @@ -274,7 +274,7 @@ pub mod raw {
* * v - A vector
* * n - The number of elements to reserve space for
*/
pub unsafe fn reserve_at_least<T>(v: &mut @[const T], n: uint) {
pub unsafe fn reserve_at_least<T>(v: &mut @[T], n: uint) {
reserve(v, uint::next_power_of_two(n));
}

Expand All @@ -291,7 +291,7 @@ pub fn test() {
}
}

fail_unless!(seq_range(10, 15) == @[10, 11, 12, 13, 14]);
assert_eq!(seq_range(10, 15), @[10, 11, 12, 13, 14]);
fail_unless!(from_fn(5, |x| x+1) == @[1, 2, 3, 4, 5]);
fail_unless!(from_elem(5, 3.14) == @[3.14, 3.14, 3.14, 3.14, 3.14]);
}
Expand Down
14 changes: 7 additions & 7 deletions src/libcore/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ pub struct Handler<T, U> {

pub struct Condition<T, U> {
name: &'static str,
key: task::local_data::LocalDataKey/&self<Handler<T, U>>
key: task::local_data::LocalDataKey<'self, Handler<T, U>>
}

pub impl<T, U> Condition/&self<T, U> {
fn trap(&self, h: &'self fn(T) -> U) -> Trap/&self<T, U> {
pub impl<T, U> Condition<'self, T, U> {
fn trap(&self, h: &'self fn(T) -> U) -> Trap<'self, T, U> {
unsafe {
let p : *RustClosure = ::cast::transmute(&h);
let prev = task::local_data::local_data_get(self.key);
Expand Down Expand Up @@ -65,11 +65,11 @@ pub impl<T, U> Condition/&self<T, U> {
}

struct Trap<T, U> {
cond: &'self Condition/&self<T, U>,
cond: &'self Condition<'self, T, U>,
handler: @Handler<T, U>
}

pub impl<T, U> Trap/&self<T, U> {
pub impl<T, U> Trap<'self, T, U> {
fn in<V>(&self, inner: &'self fn() -> V) -> V {
unsafe {
let _g = Guard { cond: self.cond };
Expand All @@ -81,11 +81,11 @@ pub impl<T, U> Trap/&self<T, U> {
}

struct Guard<T, U> {
cond: &'self Condition/&self<T, U>
cond: &'self Condition<'self, T, U>
}

#[unsafe_destructor]
impl<T, U> Drop for Guard/&self<T, U> {
impl<T, U> Drop for Guard<'self, T, U> {
fn finalize(&self) {
unsafe {
debug!("Guard: popping handler from TLS");
Expand Down
12 changes: 6 additions & 6 deletions src/libcore/flate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ pub mod rustrt {
}
}

const lz_none : c_int = 0x0; // Huffman-coding only.
const lz_fast : c_int = 0x1; // LZ with only one probe
const lz_norm : c_int = 0x80; // LZ with 128 probes, "normal"
const lz_best : c_int = 0xfff; // LZ with 4095 probes, "best"
static lz_none : c_int = 0x0; // Huffman-coding only.
static lz_fast : c_int = 0x1; // LZ with only one probe
static lz_norm : c_int = 0x80; // LZ with 128 probes, "normal"
static lz_best : c_int = 0xfff; // LZ with 4095 probes, "best"

pub fn deflate_bytes(bytes: &[const u8]) -> ~[u8] {
pub fn deflate_bytes(bytes: &const [u8]) -> ~[u8] {
do vec::as_const_buf(bytes) |b, len| {
unsafe {
let mut outsz : size_t = 0;
Expand All @@ -64,7 +64,7 @@ pub fn deflate_bytes(bytes: &[const u8]) -> ~[u8] {
}
}

pub fn inflate_bytes(bytes: &[const u8]) -> ~[u8] {
pub fn inflate_bytes(bytes: &const [u8]) -> ~[u8] {
do vec::as_const_buf(bytes) |b, len| {
unsafe {
let mut outsz : size_t = 0;
Expand Down
8 changes: 4 additions & 4 deletions src/libcore/gc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ unsafe fn find_segment_for_frame(fp: *Word, segment: *StackSegment)

type Memory = uint;

const task_local_heap: Memory = 1;
const exchange_heap: Memory = 2;
const stack: Memory = 4;
static task_local_heap: Memory = 1;
static exchange_heap: Memory = 2;
static stack: Memory = 4;

const need_cleanup: Memory = exchange_heap | stack;
static need_cleanup: Memory = exchange_heap | stack;

// Walks stack, searching for roots of the requested type, and passes
// each root to the visitor.
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<A:Hash> HashUtil for A {

/// Streaming hash-functions should implement this.
pub trait Streaming {
fn input(&self, (&[const u8]));
fn input(&self, (&const [u8]));
// These can be refactored some when we have default methods.
fn result_bytes(&self) -> ~[u8];
fn result_str(&self) -> ~str;
Expand Down Expand Up @@ -221,7 +221,7 @@ impl io::Writer for SipState {

// Methods for io::writer
#[inline(always)]
fn write(&self, msg: &[const u8]) {
fn write(&self, msg: &const [u8]) {

let length = msg.len();
self.length += length;
Expand Down Expand Up @@ -299,7 +299,7 @@ impl io::Writer for SipState {
impl Streaming for SipState {

#[inline(always)]
fn input(&self, buf: &[const u8]) {
fn input(&self, buf: &const [u8]) {
self.write(buf);
}

Expand Down
2 changes: 1 addition & 1 deletion src/libcore/hashmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub mod linear {
use uint;
use vec;

const INITIAL_CAPACITY: uint = 32u; // 2^5
static INITIAL_CAPACITY: uint = 32u; // 2^5

struct Bucket<K,V> {
hash: uint,
Expand Down
18 changes: 10 additions & 8 deletions src/libcore/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ pub enum WriterType { Screen, File }
pub trait Writer {

/// Write all of the given bytes.
fn write(&self, v: &[const u8]);
fn write(&self, v: &const [u8]);

/// Move the current position within the stream. The second parameter
/// determines the position that the first parameter is relative to.
Expand All @@ -684,23 +684,23 @@ pub trait Writer {
}

impl Writer for @Writer {
fn write(&self, v: &[const u8]) { self.write(v) }
fn write(&self, v: &const [u8]) { self.write(v) }
fn seek(&self, a: int, b: SeekStyle) { self.seek(a, b) }
fn tell(&self) -> uint { self.tell() }
fn flush(&self) -> int { self.flush() }
fn get_type(&self) -> WriterType { self.get_type() }
}

impl<W:Writer,C> Writer for Wrapper<W, C> {
fn write(&self, bs: &[const u8]) { self.base.write(bs); }
fn write(&self, bs: &const [u8]) { self.base.write(bs); }
fn seek(&self, off: int, style: SeekStyle) { self.base.seek(off, style); }
fn tell(&self) -> uint { self.base.tell() }
fn flush(&self) -> int { self.base.flush() }
fn get_type(&self) -> WriterType { File }
}

impl Writer for *libc::FILE {
fn write(&self, v: &[const u8]) {
fn write(&self, v: &const [u8]) {
unsafe {
do vec::as_const_buf(v) |vbuf, len| {
let nout = libc::fwrite(vbuf as *c_void,
Expand Down Expand Up @@ -750,7 +750,7 @@ pub fn FILE_writer(f: *libc::FILE, cleanup: bool) -> @Writer {
}

impl Writer for fd_t {
fn write(&self, v: &[const u8]) {
fn write(&self, v: &const [u8]) {
unsafe {
let mut count = 0u;
do vec::as_const_buf(v) |vbuf, len| {
Expand Down Expand Up @@ -907,8 +907,10 @@ pub fn u64_to_be_bytes<T>(n: u64, size: uint,
}
}

pub fn u64_from_be_bytes(data: &[const u8],
start: uint, size: uint) -> u64 {
pub fn u64_from_be_bytes(data: &const [u8],
start: uint,
size: uint)
-> u64 {
let mut sz = size;
fail_unless!((sz <= 8u));
let mut val = 0_u64;
Expand Down Expand Up @@ -1140,7 +1142,7 @@ pub struct BytesWriter {
}

impl Writer for BytesWriter {
fn write(&self, v: &[const u8]) {
fn write(&self, v: &const [u8]) {
let v_len = v.len();
let bytes_len = vec::uniq_len(&const self.bytes);

Expand Down
Loading