auto merge of #13326 : alexcrichton/rust/rollup, r=alexcrichton

Closes #13313 (Fix typo in README.md)
Closes #13311 (Fix inner attribute syntax from `#[foo];` to `#![foo]`)
Closes #13309 (Add stdlib docs to the Linux binary tarball.)
Closes #13308 (syntax: remove obsolete mutability from ExprVec and ExprRepeat.)
Closes #13306 (TrieSet should impl Set/MutableSet; add with_capacity to PriorityQueue/SmallIntMap)
Closes #13303 (Register new snapshots)
Closes #13274 (Added grow_fn and retain to Vec)

*Issues Closed*

Closes #13249
This commit is contained in:
bors 2014-04-04 16:01:44 -07:00
commit 4cf8d8ce69
95 changed files with 266 additions and 203 deletions

View File

@ -5,7 +5,7 @@ documentation.
## Quick Start
1. Download a [binary insaller][installer] for your platform.
1. Download a [binary installer][installer] for your platform.
2. Read the [tutorial].
3. Enjoy!

View File

@ -215,7 +215,7 @@ dist-install-dir-$(1): PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD)
dist-install-dir-$(1): PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD)
dist-install-dir-$(1): PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD)
dist-install-dir-$(1): PREPARE_CLEAN=true
dist-install-dir-$(1): prepare-base-dir-$(1)
dist-install-dir-$(1): prepare-base-dir-$(1) docs compiler-docs
$$(Q)(cd $$(PREPARE_DEST_DIR)/ && find . -type f | sed 's/^\.\///') \
> tmp/dist/manifest-$(1).in
$$(Q)mv tmp/dist/manifest-$(1).in $$(PREPARE_DEST_DIR)/$$(CFG_LIBDIR_RELATIVE)/rustlib/manifest.in
@ -224,6 +224,7 @@ dist-install-dir-$(1): prepare-base-dir-$(1)
$$(Q)$$(PREPARE_MAN_CMD) $$(S)LICENSE-APACHE $$(PREPARE_DEST_DIR)
$$(Q)$$(PREPARE_MAN_CMD) $$(S)LICENSE-MIT $$(PREPARE_DEST_DIR)
$$(Q)$$(PREPARE_MAN_CMD) $$(S)README.md $$(PREPARE_DEST_DIR)
$$(Q)cp -r doc $$(PREPARE_DEST_DIR)
$$(Q)$$(PREPARE_BIN_CMD) $$(S)src/etc/install.sh $$(PREPARE_DEST_DIR)
dist/$$(PKG_NAME)-$(1).tar.gz: dist-install-dir-$(1)

View File

@ -294,7 +294,7 @@ asm!(assembly template
);
```
Any use of `asm` is feature gated (requires `#[feature(asm)];` on the
Any use of `asm` is feature gated (requires `#![feature(asm)]` on the
crate to allow) and of course requires an `unsafe` block.
> **Note**: the examples here are given in x86/x86-64 assembly, but all
@ -306,7 +306,7 @@ The `assembly template` is the only required parameter and must be a
literal string (i.e `""`)
```
#[feature(asm)];
#![feature(asm)]
#[cfg(target_arch = "x86")]
#[cfg(target_arch = "x86_64")]
@ -334,7 +334,7 @@ Output operands, input operands, clobbers and options are all optional
but you must add the right number of `:` if you skip them:
```
# #[feature(asm)];
# #![feature(asm)]
# #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")]
# fn main() { unsafe {
asm!("xor %eax, %eax"
@ -348,7 +348,7 @@ asm!("xor %eax, %eax"
Whitespace also doesn't matter:
```
# #[feature(asm)];
# #![feature(asm)]
# #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")]
# fn main() { unsafe {
asm!("xor %eax, %eax" ::: "eax");
@ -362,7 +362,7 @@ Input and output operands follow the same format: `:
expressions must be mutable lvalues:
```
# #[feature(asm)];
# #![feature(asm)]
# #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")]
fn add(a: int, b: int) -> int {
let mut c = 0;
@ -390,7 +390,7 @@ compiler not to assume any values loaded into those registers will
stay valid.
```
# #[feature(asm)];
# #![feature(asm)]
# #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")]
# fn main() { unsafe {
// Put the value 0x200 in eax

View File

@ -1,5 +1,5 @@
# Japanese translations for Rust package
# Copyright (C) 2013 The Rust Project Developers
# Copyright (C) 2013-2014 The Rust Project Developers
# This file is distributed under the same license as the Rust package.
# Automatically generated, 2013.
#
@ -886,7 +886,7 @@ msgstr ""
#: src/doc/rust.md:2008
#, fuzzy
#| msgid "~~~~ use std::task::spawn;"
msgid "~~~~ {.ignore} #[warn(unstable)];"
msgid "~~~~ {.ignore} #![warn(unstable)]"
msgstr ""
"~~~~\n"
"use std::task::spawn;"

View File

@ -54,7 +54,7 @@ c.write(
#[crate_id=\"run_pass_stage2#0.1\"];
#[crate_id=\"run_pass_stage2#0.1\"];
#[feature(globs, macro_rules, struct_variant, managed_boxes)];
#[allow(warnings)];
#![allow(warnings)]
extern crate collections;
"""
)

View File

@ -23,7 +23,6 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://static.rust-lang.org/doc/master")]
#![allow(missing_doc)]
#![allow(visible_private_types)] // NOTE: remove after a stage0 snap
extern crate collections;

View File

@ -22,8 +22,6 @@
#![feature(macro_rules, managed_boxes, default_type_params, phase)]
#![allow(visible_private_types)] // NOTE: remove after a stage0 snap
extern crate rand;
#[cfg(test)] extern crate test;

View File

@ -117,6 +117,11 @@ impl<T:Ord> PriorityQueue<T> {
/// Create an empty PriorityQueue
pub fn new() -> PriorityQueue<T> { PriorityQueue{data: ~[],} }
/// Create an empty PriorityQueue with capacity `capacity`
pub fn with_capacity(capacity: uint) -> PriorityQueue<T> {
PriorityQueue { data: slice::with_capacity(capacity) }
}
/// Create a PriorityQueue from a vector (heapify)
pub fn from_vec(xs: ~[T]) -> PriorityQueue<T> {
let mut q = PriorityQueue{data: xs,};

View File

@ -112,6 +112,11 @@ impl<V> SmallIntMap<V> {
/// Create an empty SmallIntMap
pub fn new() -> SmallIntMap<V> { SmallIntMap{v: ~[]} }
/// Create an empty SmallIntMap with capacity `capacity`
pub fn with_capacity(capacity: uint) -> SmallIntMap<V> {
SmallIntMap { v: slice::with_capacity(capacity) }
}
pub fn get<'a>(&'a self, key: &uint) -> &'a V {
self.find(key).expect("key not present")
}

View File

@ -293,6 +293,40 @@ impl Mutable for TrieSet {
fn clear(&mut self) { self.map.clear() }
}
impl Set<uint> for TrieSet {
#[inline]
fn contains(&self, value: &uint) -> bool {
self.map.contains_key(value)
}
#[inline]
fn is_disjoint(&self, other: &TrieSet) -> bool {
self.iter().all(|v| !other.contains(&v))
}
#[inline]
fn is_subset(&self, other: &TrieSet) -> bool {
self.iter().all(|v| other.contains(&v))
}
#[inline]
fn is_superset(&self, other: &TrieSet) -> bool {
other.is_subset(self)
}
}
impl MutableSet<uint> for TrieSet {
#[inline]
fn insert(&mut self, value: uint) -> bool {
self.map.insert(value, ())
}
#[inline]
fn remove(&mut self, value: &uint) -> bool {
self.map.remove(value)
}
}
impl TrieSet {
/// Create an empty TrieSet
#[inline]
@ -300,26 +334,6 @@ impl TrieSet {
TrieSet{map: TrieMap::new()}
}
/// Return true if the set contains a value
#[inline]
pub fn contains(&self, value: &uint) -> bool {
self.map.contains_key(value)
}
/// Add a value to the set. Return true if the value was not already
/// present in the set.
#[inline]
pub fn insert(&mut self, value: uint) -> bool {
self.map.insert(value, ())
}
/// Remove a value from the set. Return true if the value was
/// present in the set.
#[inline]
pub fn remove(&mut self, value: &uint) -> bool {
self.map.remove(value)
}
/// Visit all values in reverse order
#[inline]
pub fn each_reverse(&self, f: |&uint| -> bool) -> bool {

View File

@ -87,8 +87,6 @@
#![deny(missing_doc)]
#![deny(deprecated_owned_vector)]
#![allow(visible_private_types)] // NOTE: remove after a stage0 snap
#[cfg(test)] #[phase(syntax, link)] extern crate log;
use std::cmp::Eq;

View File

@ -1,4 +1,4 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -15,7 +15,7 @@ Utilities for program-wide and customizable logging
## Example
```
#[feature(phase)];
#![feature(phase)]
#[phase(syntax, link)] extern crate log;
fn main() {

View File

@ -21,7 +21,7 @@
/// # Example
///
/// ```
/// #[feature(phase)];
/// #![feature(phase)]
/// #[phase(syntax, link)] extern crate log;
///
/// # fn main() {
@ -45,7 +45,7 @@ macro_rules! log(
/// # Example
///
/// ```
/// #[feature(phase)];
/// #![feature(phase)]
/// #[phase(syntax, link)] extern crate log;
///
/// # fn main() {
@ -63,7 +63,7 @@ macro_rules! error(
/// # Example
///
/// ```
/// #[feature(phase)];
/// #![feature(phase)]
/// #[phase(syntax, link)] extern crate log;
///
/// # fn main() {
@ -81,7 +81,7 @@ macro_rules! warn(
/// # Example
///
/// ```
/// #[feature(phase)];
/// #![feature(phase)]
/// #[phase(syntax, link)] extern crate log;
///
/// # fn main() {
@ -101,7 +101,7 @@ macro_rules! info(
/// # Example
///
/// ```
/// #[feature(phase)];
/// #![feature(phase)]
/// #[phase(syntax, link)] extern crate log;
///
/// # fn main() {
@ -118,7 +118,7 @@ macro_rules! debug(
/// # Example
///
/// ```
/// #[feature(phase)];
/// #![feature(phase)]
/// #[phase(syntax, link)] extern crate log;
///
/// # fn main() {

View File

@ -51,8 +51,6 @@
#![deny(unused_result, unused_must_use)]
#![allow(non_camel_case_types)]
#![allow(visible_private_types)] // NOTE: remove after a stage0 snap
// NB this crate explicitly does *not* allow glob imports, please seriously
// consider whether they're needed before adding that feature here (the
// answer is that you don't need them)

View File

@ -71,8 +71,6 @@ println!("{:?}", tuple_ptr)
html_root_url = "http://static.rust-lang.org/doc/master")]
#![feature(macro_rules, managed_boxes, phase)]
#![allow(visible_private_types)] // NOTE: remove after a stage0 snap
#![deny(deprecated_owned_vector)]
#[cfg(test)]

View File

@ -404,21 +404,17 @@ fn is_test_crate(krate: &ast::Crate) -> bool {
}
fn mk_test_descs(cx: &TestCtxt) -> @ast::Expr {
let mut descs = Vec::new();
debug!("building test vector from {} tests", cx.testfns.borrow().len());
for test in cx.testfns.borrow().iter() {
descs.push(mk_test_desc_and_fn_rec(cx, test));
}
let inner_expr = @ast::Expr {
id: ast::DUMMY_NODE_ID,
node: ast::ExprVec(descs, ast::MutImmutable),
span: DUMMY_SP,
};
@ast::Expr {
id: ast::DUMMY_NODE_ID,
node: ast::ExprVstore(inner_expr, ast::ExprVstoreSlice),
node: ast::ExprVstore(@ast::Expr {
id: ast::DUMMY_NODE_ID,
node: ast::ExprVec(cx.testfns.borrow().iter().map(|test| {
mk_test_desc_and_fn_rec(cx, test)
}).collect()),
span: DUMMY_SP,
}, ast::ExprVstoreSlice),
span: DUMMY_SP,
}
}

View File

@ -31,9 +31,6 @@ This API is completely unstable and subject to change.
#![feature(macro_rules, globs, struct_variant, managed_boxes, quote,
default_type_params, phase)]
#![allow(visible_private_types)] // NOTE: remove after a stage0 snap
#![allow(unrecognized_lint)] // NOTE: remove after a stage0 snap
extern crate flate;
extern crate arena;
extern crate syntax;

View File

@ -347,7 +347,7 @@ impl<'a> CFGBuilder<'a> {
self.add_node(expr.id, [])
}
ast::ExprVec(ref elems, _) => {
ast::ExprVec(ref elems) => {
self.straightline(expr, pred, elems.as_slice())
}
@ -379,7 +379,7 @@ impl<'a> CFGBuilder<'a> {
self.straightline(expr, base_exit, field_exprs.as_slice())
}
ast::ExprRepeat(elem, count, _) => {
ast::ExprRepeat(elem, count) => {
self.straightline(expr, pred, [elem, count])
}

View File

@ -157,7 +157,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr, is_const: bool) {
}
ExprVstore(_, ExprVstoreMutSlice) |
ExprVstore(_, ExprVstoreSlice) |
ExprVec(_, MutImmutable) |
ExprVec(_) |
ExprAddrOf(MutImmutable, _) |
ExprParen(..) |
ExprField(..) |

View File

@ -213,7 +213,7 @@ impl<'a> ConstEvalVisitor<'a> {
join(self.classify(a), self.classify(b)),
ast::ExprTup(ref es) |
ast::ExprVec(ref es, ast::MutImmutable) =>
ast::ExprVec(ref es) =>
join_all(es.iter().map(|e| self.classify(*e))),
ast::ExprVstore(e, vstore) => {

View File

@ -538,11 +538,11 @@ impl<'a, 'b, O:DataFlowOperator> PropagationContext<'a, 'b, O> {
self.walk_expr(l, in_out, loop_scopes);
}
ast::ExprVec(ref exprs, _) => {
ast::ExprVec(ref exprs) => {
self.walk_exprs(exprs.as_slice(), in_out, loop_scopes)
}
ast::ExprRepeat(l, r, _) => {
ast::ExprRepeat(l, r) => {
self.walk_expr(l, in_out, loop_scopes);
self.walk_expr(r, in_out, loop_scopes);
}

View File

@ -309,7 +309,7 @@ pub fn check_expr(cx: &mut Context, e: &Expr) {
let target_ty = ty::expr_ty(cx.tcx, e);
check_trait_cast(cx, source_ty, target_ty, source.span);
}
ExprRepeat(element, count_expr, _) => {
ExprRepeat(element, count_expr) => {
let count = ty::eval_repeat_count(cx.tcx, count_expr);
if count > 1 {
let element_ty = ty::expr_ty(cx.tcx, element);

View File

@ -1109,11 +1109,11 @@ impl<'a> Liveness<'a> {
self.propagate_through_expr(expr, succ)
}
ExprVec(ref exprs, _) => {
ExprVec(ref exprs) => {
self.propagate_through_exprs(exprs.as_slice(), succ)
}
ExprRepeat(element, count, _) => {
ExprRepeat(element, count) => {
let succ = self.propagate_through_expr(count, succ);
self.propagate_through_expr(element, succ)
}

View File

@ -473,7 +473,7 @@ impl<'a> VisitContext<'a> {
self.use_expr(base, expr_mode);
}
ExprVec(ref exprs, _) => {
ExprVec(ref exprs) => {
self.consume_exprs(exprs.as_slice());
}
@ -539,7 +539,7 @@ impl<'a> VisitContext<'a> {
// }
}
ExprRepeat(base, count, _) => {
ExprRepeat(base, count) => {
self.consume_expr(base);
self.consume_expr(count);
}

View File

@ -724,7 +724,7 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor,
visitor.region_maps.record_rvalue_scope(subexpr.id, blk_id);
record_rvalue_scope_if_borrow_expr(visitor, subexpr, blk_id);
}
ast::ExprVec(ref subexprs, _) |
ast::ExprVec(ref subexprs) |
ast::ExprTup(ref subexprs) => {
for &subexpr in subexprs.iter() {
record_rvalue_scope_if_borrow_expr(

View File

@ -557,7 +557,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
inlineable.iter().fold(true, |a, &b| a && b))
})
}
ast::ExprVec(ref es, ast::MutImmutable) => {
ast::ExprVec(ref es) => {
let (v, _, inlineable) = const_vec(cx,
e,
es.as_slice(),
@ -573,7 +573,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
_ => { cx.sess().span_bug(e.span, "bad const-slice lit") }
}
}
ast::ExprVec(ref es, ast::MutImmutable) => {
ast::ExprVec(ref es) => {
let (cv, llunitty, _) = const_vec(cx,
e,
es.as_slice(),
@ -592,7 +592,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
_ => cx.sess().span_bug(e.span, "bad const-slice expr")
}
}
ast::ExprRepeat(elem, count, _) => {
ast::ExprRepeat(elem, count) => {
let vec_ty = ty::expr_ty(cx.tcx(), e);
let unit_ty = ty::sequence_element_type(cx.tcx(), vec_ty);
let llunitty = type_of::type_of(cx, unit_ty);

View File

@ -2619,15 +2619,15 @@ fn populate_scope_map(cx: &CrateContext,
walk_expr(cx, rhs, scope_stack, scope_map);
}
ast::ExprVec(ref init_expressions, _) |
ast::ExprTup(ref init_expressions) => {
ast::ExprVec(ref init_expressions) |
ast::ExprTup(ref init_expressions) => {
for ie in init_expressions.iter() {
walk_expr(cx, *ie, scope_stack, scope_map);
}
}
ast::ExprAssign(sub_exp1, sub_exp2) |
ast::ExprRepeat(sub_exp1, sub_exp2, _) => {
ast::ExprAssign(sub_exp1, sub_exp2) |
ast::ExprRepeat(sub_exp1, sub_exp2) => {
walk_expr(cx, sub_exp1, scope_stack, scope_map);
walk_expr(cx, sub_exp2, scope_stack, scope_map);
}

View File

@ -392,7 +392,7 @@ pub fn write_content<'a>(
}
}
}
ast::ExprVec(ref elements, _) => {
ast::ExprVec(ref elements) => {
match dest {
Ignore => {
for element in elements.iter() {
@ -418,7 +418,7 @@ pub fn write_content<'a>(
}
return bcx;
}
ast::ExprRepeat(element, count_expr, _) => {
ast::ExprRepeat(element, count_expr) => {
match dest {
Ignore => {
return expr::trans_into(bcx, element, Ignore);
@ -486,8 +486,8 @@ pub fn elements_required(bcx: &Block, content_expr: &ast::Expr) -> uint {
}
}
},
ast::ExprVec(ref es, _) => es.len(),
ast::ExprRepeat(_, count_expr, _) => {
ast::ExprVec(ref es) => es.len(),
ast::ExprRepeat(_, count_expr) => {
ty::eval_repeat_count(bcx.tcx(), count_expr)
}
_ => bcx.tcx().sess.span_bug(content_expr.span,

View File

@ -2482,13 +2482,13 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
ty::mk_str(tcx, tt)
}
ast::ExprVec(ref args, mutbl) => {
ast::ExprVec(ref args) => {
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
let mut any_error = false;
let mut any_bot = false;
let mutability = match vst {
ast::ExprVstoreMutSlice => ast::MutMutable,
_ => mutbl,
_ => ast::MutImmutable,
};
let t: ty::t = fcx.infcx().next_ty_var();
for e in args.iter() {
@ -2509,13 +2509,13 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
ty::mk_vec(tcx, ty::mt {ty: t, mutbl: mutability}, tt)
}
}
ast::ExprRepeat(element, count_expr, mutbl) => {
ast::ExprRepeat(element, count_expr) => {
check_expr_with_hint(fcx, count_expr, ty::mk_uint());
let _ = ty::eval_repeat_count(fcx, count_expr);
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
let mutability = match vst {
ast::ExprVstoreMutSlice => ast::MutMutable,
_ => mutbl,
_ => ast::MutImmutable,
};
let t: ty::t = fcx.infcx().next_ty_var();
check_expr_has_type(fcx, element, t);
@ -3017,16 +3017,16 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
fcx.write_ty(id, t_1);
}
}
ast::ExprVec(ref args, mutbl) => {
ast::ExprVec(ref args) => {
let t: ty::t = fcx.infcx().next_ty_var();
for e in args.iter() {
check_expr_has_type(fcx, *e, t);
}
let typ = ty::mk_vec(tcx, ty::mt {ty: t, mutbl: mutbl},
let typ = ty::mk_vec(tcx, ty::mt {ty: t, mutbl: ast::MutImmutable},
ty::vstore_fixed(args.len()));
fcx.write_ty(id, typ);
}
ast::ExprRepeat(element, count_expr, mutbl) => {
ast::ExprRepeat(element, count_expr) => {
check_expr_with_hint(fcx, count_expr, ty::mk_uint());
let count = ty::eval_repeat_count(fcx, count_expr);
let t: ty::t = fcx.infcx().next_ty_var();
@ -3039,7 +3039,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
fcx.write_bot(id);
}
else {
let t = ty::mk_vec(tcx, ty::mt {ty: t, mutbl: mutbl},
let t = ty::mk_vec(tcx, ty::mt {ty: t, mutbl: ast::MutImmutable},
ty::vstore_fixed(count));
fcx.write_ty(id, t);
}
@ -3864,7 +3864,7 @@ pub fn ast_expr_vstore_to_vstore(fcx: &FnCtxt,
// string literals and *empty slices* live in static memory
ty::vstore_slice(ty::ReStatic)
}
ast::ExprVec(ref elements, _) if elements.len() == 0 => {
ast::ExprVec(ref elements) if elements.len() == 0 => {
// string literals and *empty slices* live in static memory
ty::vstore_slice(ty::ReStatic)
}

View File

@ -57,9 +57,7 @@
// Don't link to std. We are std.
#![no_std]
// #![deny(missing_doc)] // NOTE: uncomment after a stage0 snap
#![allow(missing_doc)] // NOTE: remove after a stage0 snap
#![allow(visible_private_types)] // NOTE: remove after a stage0 snap
#![deny(missing_doc)]
#![allow(unknown_features)] // NOTE: remove after a stage0 snap
// When testing libstd, bring in libuv as the I/O backend so tests can print

View File

@ -15,7 +15,7 @@ use cmp::{Ord, Eq, Ordering, TotalEq, TotalOrd};
use container::{Container, Mutable};
use default::Default;
use fmt;
use iter::{DoubleEndedIterator, FromIterator, Extendable, Iterator};
use iter::{DoubleEndedIterator, FromIterator, Extendable, Iterator, range};
use libc::{free, c_void};
use mem::{size_of, move_val_init};
use mem;
@ -1135,6 +1135,56 @@ impl<T> Vec<T> {
pub fn as_mut_ptr(&mut self) -> *mut T {
self.as_mut_slice().as_mut_ptr()
}
/// Retains only the elements specified by the predicate.
///
/// In other words, remove all elements `e` such that `f(&e)` returns false.
/// This method operates in place and preserves the order the retained elements.
///
/// # Example
///
/// ```rust
/// let mut vec = vec!(1i, 2, 3, 4);
/// vec.retain(|x| x%2 == 0);
/// assert_eq!(vec, vec!(2, 4));
/// ```
pub fn retain(&mut self, f: |&T| -> bool) {
let len = self.len();
let mut del = 0u;
{
let v = self.as_mut_slice();
for i in range(0u, len) {
if !f(&v[i]) {
del += 1;
} else if del > 0 {
v.swap(i-del, i);
}
}
}
if del > 0 {
self.truncate(len - del);
}
}
/// Expands a vector in place, initializing the new elements to the result of a function.
///
/// The vector is grown by `n` elements. The i-th new element are initialized to the value
/// returned by `f(i)` where `i` is in the range [0, n).
///
/// # Example
///
/// ```rust
/// let mut vec = vec!(0u, 1);
/// vec.grow_fn(3, |i| i);
/// assert_eq!(vec, vec!(0, 1, 0, 1, 2));
/// ```
pub fn grow_fn(&mut self, n: uint, f: |uint| -> T) {
self.reserve_additional(n);
for i in range(0u, n) {
self.push(f(i));
}
}
}
impl<T:TotalOrd> Vec<T> {
@ -1523,4 +1573,17 @@ mod tests {
v.clone_from(&three);
assert_eq!(v, three)
}
fn test_grow_fn() {
let mut v = Vec::from_slice([0u, 1]);
v.grow_fn(3, |i| i);
assert!(v == Vec::from_slice([0u, 1, 0, 1, 2]));
}
#[test]
fn test_retain() {
let mut vec = Vec::from_slice([1u, 2, 3, 4]);
vec.retain(|x| x%2 == 0);
assert!(vec == Vec::from_slice([2u, 4]));
}
}

View File

@ -22,9 +22,7 @@
#![feature(phase)]
#![deny(deprecated_owned_vector)]
// #![deny(missing_doc)] // NOTE: uncomment after a stage0 snap
#![allow(missing_doc)] // NOTE: remove after a stage0 snap
#![allow(visible_private_types)] // NOTE: remove after a stage0 snap
#![deny(missing_doc)]
#[cfg(test)]
#[phase(syntax, link)] extern crate log;

View File

@ -493,7 +493,7 @@ pub enum Expr_ {
ExprVstore(@Expr, ExprVstore),
// First expr is the place; second expr is the value.
ExprBox(@Expr, @Expr),
ExprVec(Vec<@Expr>, Mutability),
ExprVec(Vec<@Expr>),
ExprCall(@Expr, Vec<@Expr>),
ExprMethodCall(Ident, Vec<P<Ty>>, Vec<@Expr>),
ExprTup(Vec<@Expr>),
@ -536,7 +536,7 @@ pub enum Expr_ {
ExprStruct(Path, Vec<Field> , Option<@Expr> /* base */),
// A vector literal constructed from one repeated element.
ExprRepeat(@Expr /* element */, @Expr /* count */, Mutability),
ExprRepeat(@Expr /* element */, @Expr /* count */),
// No-op: used solely so we can pretty-print faithfully
ExprParen(@Expr)

View File

@ -579,7 +579,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
self.expr(sp, ast::ExprVstore(expr, vst))
}
fn expr_vec(&self, sp: Span, exprs: Vec<@ast::Expr> ) -> @ast::Expr {
self.expr(sp, ast::ExprVec(exprs, ast::MutImmutable))
self.expr(sp, ast::ExprVec(exprs))
}
fn expr_vec_ng(&self, sp: Span) -> @ast::Expr {
self.expr_call_global(sp,

View File

@ -740,11 +740,11 @@ pub fn noop_fold_expr<T: Folder>(e: @Expr, folder: &mut T) -> @Expr {
ExprBox(p, e) => {
ExprBox(folder.fold_expr(p), folder.fold_expr(e))
}
ExprVec(ref exprs, mutt) => {
ExprVec(exprs.iter().map(|&x| folder.fold_expr(x)).collect(), mutt)
ExprVec(ref exprs) => {
ExprVec(exprs.iter().map(|&x| folder.fold_expr(x)).collect())
}
ExprRepeat(expr, count, mutt) => {
ExprRepeat(folder.fold_expr(expr), folder.fold_expr(count), mutt)
ExprRepeat(expr, count) => {
ExprRepeat(folder.fold_expr(expr), folder.fold_expr(count))
}
ExprTup(ref elts) => ExprTup(elts.iter().map(|x| folder.fold_expr(*x)).collect()),
ExprCall(f, ref args) => {

View File

@ -30,8 +30,6 @@ This API is completely unstable and subject to change.
quote)]
#![allow(deprecated)]
#![allow(visible_private_types)] // NOTE: remove after a stage0 snap
extern crate serialize;
extern crate term;
extern crate collections;

View File

@ -1819,12 +1819,11 @@ impl<'a> Parser<'a> {
return self.parse_block_expr(lo, UnsafeBlock(ast::UserProvided));
} else if self.token == token::LBRACKET {
self.bump();
let mutbl = MutImmutable;
if self.token == token::RBRACKET {
// Empty vector.
self.bump();
ex = ExprVec(Vec::new(), mutbl);
ex = ExprVec(Vec::new());
} else {
// Nonempty vector.
let first_expr = self.parse_expr();
@ -1835,7 +1834,7 @@ impl<'a> Parser<'a> {
self.bump();
let count = self.parse_expr();
self.expect(&token::RBRACKET);
ex = ExprRepeat(first_expr, count, mutbl);
ex = ExprRepeat(first_expr, count);
} else if self.token == token::COMMA {
// Vector with two or more elements.
self.bump();
@ -1846,11 +1845,11 @@ impl<'a> Parser<'a> {
);
let mut exprs = vec!(first_expr);
exprs.push_all_move(remaining_exprs);
ex = ExprVec(exprs, mutbl);
ex = ExprVec(exprs);
} else {
// Vector with one element.
self.expect(&token::RBRACKET);
ex = ExprVec(vec!(first_expr), mutbl);
ex = ExprVec(vec!(first_expr));
}
}
hi = self.last_span.hi;

View File

@ -915,9 +915,6 @@ impl<'a> State<'a> {
match attr.node.style {
ast::AttrInner => {
try!(self.print_attribute(attr));
if !attr.node.is_sugared_doc {
try!(word(&mut self.s, ";"));
}
count += 1;
}
_ => {/* fallthrough */ }
@ -935,7 +932,10 @@ impl<'a> State<'a> {
if attr.node.is_sugared_doc {
word(&mut self.s, attr.value_str().unwrap().get())
} else {
try!(word(&mut self.s, "#["));
match attr.node.style {
ast::AttrInner => try!(word(&mut self.s, "#![")),
ast::AttrOuter => try!(word(&mut self.s, "#[")),
}
try!(self.print_meta_item(attr.meta()));
word(&mut self.s, "]")
}
@ -1110,25 +1110,17 @@ impl<'a> State<'a> {
try!(self.word_space(")"));
try!(self.print_expr(e));
}
ast::ExprVec(ref exprs, mutbl) => {
ast::ExprVec(ref exprs) => {
try!(self.ibox(indent_unit));
try!(word(&mut self.s, "["));
if mutbl == ast::MutMutable {
try!(word(&mut self.s, "mut"));
if exprs.len() > 0u { try!(self.nbsp()); }
}
try!(self.commasep_exprs(Inconsistent, exprs.as_slice()));
try!(word(&mut self.s, "]"));
try!(self.end());
}
ast::ExprRepeat(element, count, mutbl) => {
ast::ExprRepeat(element, count) => {
try!(self.ibox(indent_unit));
try!(word(&mut self.s, "["));
if mutbl == ast::MutMutable {
try!(word(&mut self.s, "mut"));
try!(self.nbsp());
}
try!(self.print_expr(element));
try!(word(&mut self.s, ","));
try!(word(&mut self.s, ".."));

View File

@ -635,10 +635,10 @@ pub fn walk_expr<E: Clone, V: Visitor<E>>(visitor: &mut V, expression: &Expr, en
visitor.visit_expr(place, env.clone());
visitor.visit_expr(subexpression, env.clone())
}
ExprVec(ref subexpressions, _) => {
ExprVec(ref subexpressions) => {
walk_exprs(visitor, subexpressions.as_slice(), env.clone())
}
ExprRepeat(element, count, _) => {
ExprRepeat(element, count) => {
visitor.visit_expr(element, env.clone());
visitor.visit_expr(count, env.clone())
}

View File

@ -21,9 +21,7 @@
#![feature(macro_rules)]
// #![deny(missing_doc)] // NOTE: uncomment after a stage0 snap
#![allow(missing_doc)] // NOTE: remove after a stage0 snap
#![allow(visible_private_types)] // NOTE: remove after a stage0 snap
#![deny(missing_doc)]
extern crate collections;

View File

@ -1,3 +1,11 @@
S 2014-04-03 e7fe207
freebsd-x86_64 6d40f547d13896ab9d9dd4a4fdf2e72be553b01b
linux-i386 875a8f6956f7d703f7206db91ca2a9b67c244cf8
linux-x86_64 4d90df12231d1c9f51b5ae6e75546ccddcf0534b
macos-i386 e5486efa1356abca8f8d5cac9aa6135c9626ab51
macos-x86_64 8341419e4295d780f72950cfe2187195d0d03e83
winnt-i386 60c2fb349ac8a7ad30c9ba2518a61e669debb7bf
S 2014-03-28 b8601a3
freebsd-x86_64 c6b0651b2a90697754920ad381c13f9b7942ab47
linux-i386 3bef5684fd0582fbd4ddebd4514182d4f72924f7

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[crate_type = "lib"];
#![crate_type = "lib"]
pub struct Fish {
pub x: int

View File

@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -9,7 +9,7 @@
// except according to those terms.
#[allow(unused_imports)];
#[feature(globs)];
#![feature(globs)]
extern crate issue_2316_a;

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(phase)];
#![feature(phase)]
#[phase(syntax, link)] extern crate log;
pub fn foo<T>() {

View File

@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,7 +10,7 @@
// error-pattern: unresolved name
#[feature(globs)];
#![feature(globs)]
use module_of_many_things::*;

View File

@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,7 +10,7 @@
// error-pattern: unresolved
#[feature(globs)];
#![feature(globs)]
mod circ1 {
pub use circ2::f2;

View File

@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(globs)];
#![feature(globs)]
// error-pattern:declaration of `None` shadows
use std::option::*;

View File

@ -10,7 +10,7 @@
// ignore-test Can't use syntax crate here
#[feature(quote)];
#![feature(quote)]
extern crate syntax;

View File

@ -10,7 +10,7 @@
// ignore-test Can't use syntax crate here
#[feature(quote)];
#![feature(quote)]
extern crate syntax;

View File

@ -40,7 +40,7 @@
// debugger:continue
#[allow(experimental)];
#![allow(experimental)]
#[allow(unused_variable)];
use std::unstable::simd::{i8x16, i16x8,i32x4,i64x2,u8x16,u16x8,u32x4,u64x2,f32x4,f64x2};

View File

@ -14,7 +14,7 @@
// accidentally carried over to each inner function
fn main() {
#[inner_attr];
#![inner_attr]
#[outer_attr]
fn f() { }

View File

@ -57,5 +57,5 @@ fn f() { }
fn g() { }
fn h() {
#[doc = "as do inner ones"];
#![doc = "as do inner ones"]
}

View File

@ -11,7 +11,7 @@
// ignore-fast #[feature] doesn't work with check-fast
// pp-exact
#[feature(asm)];
#![feature(asm)]
#[cfg = r#"just parse this"#]
extern crate blah = r##"blah"##;

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -11,7 +11,7 @@
// Issue #7580
// error-pattern:fail works
#[feature(globs)];
#![feature(globs)]
use std::*;

View File

@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,7 +10,7 @@
// error-pattern:whatever
#[feature(phase)];
#![feature(phase)]
#[phase(syntax, link)] extern crate log;
use std::os;

View File

@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,7 +10,7 @@
// error-pattern:whatever
#[feature(phase)];
#![feature(phase)]
#[phase(syntax, link)] extern crate log;
use std::os;
use std::task;

View File

@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,7 +10,7 @@
// error-pattern:whatever
#[feature(phase)];
#![feature(phase)]
#[phase(syntax, link)] extern crate log;
use std::os;

View File

@ -14,7 +14,7 @@
// ignore-android
// ignore-cross-compile #12102
#[feature(phase)];
#![feature(phase)]
#[phase(syntax)]
extern crate macro_crate_outlive_expansion_phase;

View File

@ -14,7 +14,7 @@
// ignore-android
// ignore-cross-compile #12102
#[feature(phase)];
#![feature(phase)]
#[phase(syntax)]
extern crate macro_crate_test;

View File

@ -24,7 +24,7 @@
// can't run host binaries, and force-host to make this test build as the host
// arch.
#[feature(phase)];
#![feature(phase)]
#[phase(syntax, link)]
extern crate macro_crate_test;

View File

@ -11,7 +11,7 @@
// ignore-pretty
// ignore-test
#[feature(quote)];
#![feature(quote)]
extern crate syntax;

View File

@ -10,7 +10,7 @@
// ignore-test
#[feature(quote)];
#![feature(quote)]
#[feature(managed_boxes)];
extern crate syntax;

View File

@ -10,7 +10,7 @@
// ignore-fast
// ignore-android
#[feature(quote)];
#![feature(quote)]
#[deny(unused_variable)];
extern crate syntax;

View File

@ -13,7 +13,7 @@
// ignore-pretty
// ignore-cross-compile
#[feature(phase)];
#![feature(phase)]
#[phase(syntax)]
extern crate fourcc;

View File

@ -13,7 +13,7 @@
// ignore-cross-compile #12102
// ignore-fast
#[feature(phase)];
#![feature(phase)]
#[phase(syntax)]
extern crate hexfloat;

View File

@ -9,7 +9,7 @@
// except according to those terms.
// ignore-fast #[feature] doesn't work with check-fast
#[feature(asm)];
#![feature(asm)]
pub fn main() {
unsafe { asm!(concat!("", "")) };

View File

@ -9,7 +9,7 @@
// except according to those terms.
// ignore-fast #[feature] doesn't work with check-fast
#[feature(asm)];
#![feature(asm)]
#[cfg(target_arch = "x86")]
#[cfg(target_arch = "x86_64")]

View File

@ -9,7 +9,7 @@
// except according to those terms.
// ignore-fast #[feature] doesn't work with check-fast
#[feature(asm)];
#![feature(asm)]
#[cfg(target_arch = "x86")]
#[cfg(target_arch = "x86_64")]

View File

@ -12,7 +12,7 @@
// ignore-android (FIXME #11419)
// exec-env:RUST_LOG=info
#[feature(phase)];
#![feature(phase)]
#[phase(syntax, link)]
extern crate log;

View File

@ -12,7 +12,7 @@
// compile-flags: --cfg ndebug
// exec-env:RUST_LOG=conditional-debug-macro-off=4
#[feature(phase)];
#![feature(phase)]
#[phase(syntax, link)]
extern crate log;

View File

@ -15,7 +15,7 @@
// Modified to not use export since it's going away. --pcw
#[feature(globs)];
#![feature(globs)]
mod foo {
use foo::bar::*;

View File

@ -11,7 +11,7 @@
// ignore-fast: check-fast screws up repr paths
#[feature(macro_rules)];
#[deny(warnings)];
#![deny(warnings)]
#[allow(unused_must_use)];
#[allow(deprecated_owned_vector)];

View File

@ -10,7 +10,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(globs)];
#![feature(globs)]
use module_of_many_things::*;
use dug::too::greedily::and::too::deep::*;

View File

@ -10,7 +10,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(globs)];
#![feature(globs)]
#[allow(dead_assignment)];
use std::mem::*;

View File

@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(globs)];
#![feature(globs)]
pub fn main() {
use std::mem::replace;

View File

@ -10,7 +10,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(globs)];
#![feature(globs)]
mod rusti {
extern "rust-intrinsic" {

View File

@ -11,7 +11,7 @@
// ignore-fast
// aux-build:issue-2526.rs
#[feature(globs)];
#![feature(globs)]
#[allow(unused_imports)];
extern crate issue_2526;

View File

@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -160,7 +160,7 @@ mod test_foreign_items {
use std::libc;
extern {
#[attr];
#![attr]
#[attr]
fn rust_get_test_int() -> libc::intptr_t;

View File

@ -14,7 +14,7 @@
// ignore-macos
// aux-build:linkage1.rs
#[feature(linkage)];
#![feature(linkage)]
extern crate other = "linkage1";

View File

@ -12,7 +12,7 @@
// compile-flags:--cfg ndebug
// exec-env:RUST_LOG=logging-enabled-debug=debug
#[feature(phase)];
#![feature(phase)]
#[phase(syntax, link)]
extern crate log;

View File

@ -11,7 +11,7 @@
// ignore-fast
// exec-env:RUST_LOG=logging-enabled=info
#[feature(phase)];
#![feature(phase)]
#[phase(syntax, link)]
extern crate log;

View File

@ -11,7 +11,7 @@
// aux-build:macro_crate_def_only.rs
// ignore-fast
#[feature(phase)];
#![feature(phase)]
#[phase(syntax)]
extern crate macro_crate_def_only;

View File

@ -12,7 +12,7 @@
//ignore-stage1
//ignore-fast
#[feature(phase)];
#![feature(phase)]
#[phase(syntax)]
extern crate macro_export_inner_module;

View File

@ -22,12 +22,12 @@ trait frobable {
impl frobable for int {
#[frob_attr1]
fn frob(&self) {
#[frob_attr2];
#![frob_attr2]
}
#[defrob_attr1]
fn defrob(&self) {
#[defrob_attr2];
#![defrob_attr2]
}
}

View File

@ -10,7 +10,7 @@
// ignore-fast
#[feature(asm)];
#![feature(asm)]
use std::io::Process;
use std::os;

View File

@ -10,7 +10,7 @@
// ignore-fast
#[feature(phase)];
#![feature(phase)]
#[phase(syntax)]
use std::mem;

View File

@ -13,7 +13,7 @@
// Check we do the correct privacy checks when we import a name and there is an
// item with that name in both the value and type namespaces.
#[feature(globs)];
#![feature(globs)]
#[allow(dead_code)];
#[allow(unused_imports)];

View File

@ -10,7 +10,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(globs)];
#![feature(globs)]
// FIXME #3654

View File

@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[allow(experimental)];
#![allow(experimental)]
use std::unstable::simd::{i32x4, f32x4, u32x4};

View File

@ -10,7 +10,7 @@
// ignore-fast
#[feature(simd)];
#![feature(simd)]
use std::ops;

View File

@ -10,8 +10,8 @@
// ignore-fast
#[allow(experimental)];
#[feature(simd)];
#![allow(experimental)]
#![feature(simd)]
pub fn main() {
let _o = None::<std::unstable::simd::i32x4>;

View File

@ -10,7 +10,7 @@
// ignore-fast feature doesn't work
#[feature(simd)];
#![feature(simd)]
#[simd]
struct RGBA {

View File

@ -10,7 +10,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(globs)];
#![feature(globs)]
use alder::*;

View File

@ -13,7 +13,7 @@
// ignore-android needs extra network permissions
// exec-env:RUST_LOG=debug
#[feature(phase)];
#![feature(phase)]
#[phase(syntax, link)]
extern crate log;

View File

@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,7 +10,7 @@
// compile-flags:-D ctypes
#[allow(ctypes)];
#![allow(ctypes)]
mod libc {
extern {