Test fixes and rebase conflicts

This commit is contained in:
Alex Crichton 2015-01-07 18:53:58 -08:00
parent 11e265c2e0
commit 0dc48b47a8
194 changed files with 386 additions and 309 deletions

View file

@ -147,10 +147,10 @@ for all but the most trivial of situations.
Here's an example of using `Result`:
```rust
#[deriving(Show)]
#[derive(Show)]
enum Version { Version1, Version2 }
#[deriving(Show)]
#[derive(Show)]
enum ParseError { InvalidHeaderLength, InvalidVersion }
fn parse_version(header: &[u8]) -> Result<Version, ParseError> {

View file

@ -262,6 +262,7 @@ referenced Rust object.
Rust code:
~~~~no_run
# use std::boxed::Box;
#[repr(C)]
struct RustObject {
@ -286,7 +287,7 @@ extern {
fn main() {
// Create the object that will be referenced in the callback
let mut rust_object = box RustObject { a: 5 };
let mut rust_object = Box::new(RustObject { a: 5 });
unsafe {
register_callback(&mut *rust_object, callback);

View file

@ -81,27 +81,29 @@ therefore deallocates the memory for you. Here's the equivalent example in
Rust:
```rust
# use std::boxed::Box;
{
let x = box 5i;
let x = Box::new(5i);
}
```
The `box` keyword creates a `Box<T>` (specifically `Box<int>` in this case) by
allocating a small segment of memory on the heap with enough space to fit an
`int`. But where in the code is the box deallocated? We said before that we
must have a deallocation for each allocation. Rust handles this for you. It
The `Box::new` function creates a `Box<T>` (specifically `Box<int>` in this
case) by allocating a small segment of memory on the heap with enough space to
fit an `int`. But where in the code is the box deallocated? We said before that
we must have a deallocation for each allocation. Rust handles this for you. It
knows that our handle, `x`, is the owning reference to our box. Rust knows that
`x` will go out of scope at the end of the block, and so it inserts a call to
deallocate the memory at the end of the scope. Because the compiler does this
for us, it's impossible to forget. We always have exactly one deallocation paired
with each of our allocations.
for us, it's impossible to forget. We always have exactly one deallocation
paired with each of our allocations.
This is pretty straightforward, but what happens when we want to pass our box
to a function? Let's look at some code:
```rust
# use std::boxed::Box;
fn main() {
let x = box 5i;
let x = Box::new(5i);
add_one(x);
}
@ -115,8 +117,9 @@ This code works, but it's not ideal. For example, let's add one more line of
code, where we print out the value of `x`:
```{rust,ignore}
# use std::boxed::Box;
fn main() {
let x = box 5i;
let x = Box::new(5i);
add_one(x);
@ -148,8 +151,9 @@ To fix this, we can have `add_one` give ownership back when it's done with the
box:
```rust
# use std::boxed::Box;
fn main() {
let x = box 5i;
let x = Box::new(5i);
let y = add_one(x);

View file

@ -455,12 +455,13 @@ fn rc_succ(x: Rc<int>) -> int { *x + 1 }
Note that the caller of your function will have to modify their calls slightly:
```{rust}
# use std::boxed::Box;
use std::rc::Rc;
fn succ(x: &int) -> int { *x + 1 }
let ref_x = &5i;
let box_x = box 5i;
let box_x = Box::new(5i);
let rc_x = Rc::new(5i);
succ(ref_x);
@ -477,24 +478,17 @@ those contents.
heap allocation in Rust. Creating a box looks like this:
```{rust}
let x = box(std::boxed::HEAP) 5i;
# use std::boxed::Box;
let x = Box::new(5i);
```
`box` is a keyword that does 'placement new,' which we'll talk about in a bit.
`box` will be useful for creating a number of heap-allocated types, but is not
quite finished yet. In the meantime, `box`'s type defaults to
`std::boxed::HEAP`, and so you can leave it off:
```{rust}
let x = box 5i;
```
As you might assume from the `HEAP`, boxes are heap allocated. They are
deallocated automatically by Rust when they go out of scope:
Boxes are heap allocated and they are deallocated automatically by Rust when
they go out of scope:
```{rust}
# use std::boxed::Box;
{
let x = box 5i;
let x = Box::new(5i);
// stuff happens
@ -513,8 +507,9 @@ You don't need to fully grok the theory of affine types or regions to grok
boxes, though. As a rough approximation, you can treat this Rust code:
```{rust}
# use std::boxed::Box;
{
let x = box 5i;
let x = Box::new(5i);
// stuff happens
}
@ -553,12 +548,13 @@ for more detail on how lifetimes work.
Using boxes and references together is very common. For example:
```{rust}
# use std::boxed::Box;
fn add_one(x: &int) -> int {
*x + 1
}
fn main() {
let x = box 5i;
let x = Box::new(5i);
println!("{}", add_one(&*x));
}
@ -570,12 +566,13 @@ function, and since it's only reading the value, allows it.
We can borrow `x` multiple times, as long as it's not simultaneous:
```{rust}
# use std::boxed::Box;
fn add_one(x: &int) -> int {
*x + 1
}
fn main() {
let x = box 5i;
let x = Box::new(5i);
println!("{}", add_one(&*x));
println!("{}", add_one(&*x));
@ -586,12 +583,13 @@ fn main() {
Or as long as it's not a mutable borrow. This will error:
```{rust,ignore}
# use std::boxed::Box;
fn add_one(x: &mut int) -> int {
*x + 1
}
fn main() {
let x = box 5i;
let x = Box::new(5i);
println!("{}", add_one(&*x)); // error: cannot borrow immutable dereference
// of `&`-pointer as mutable
@ -612,14 +610,15 @@ Sometimes, you need a recursive data structure. The simplest is known as a
```{rust}
#[deriving(Show)]
# use std::boxed::Box;
#[derive(Show)]
enum List<T> {
Cons(T, Box<List<T>>),
Nil,
}
fn main() {
let list: List<int> = List::Cons(1, box List::Cons(2, box List::Cons(3, box List::Nil)));
let list: List<int> = List::Cons(1, Box::new(List::Cons(2, Box::new(List::Cons(3, Box::new(List::Nil))))));
println!("{:?}", list);
}
```
@ -627,7 +626,7 @@ fn main() {
This prints:
```text
Cons(1, box Cons(2, box Cons(3, box Nil)))
Cons(1, Box(Cons(2, Box(Cons(3, Box(Nil))))))
```
The reference to another `List` inside of the `Cons` enum variant must be a box,
@ -667,6 +666,7 @@ In many languages with pointers, you'd return a pointer from a function
so as to avoid copying a large data structure. For example:
```{rust}
# use std::boxed::Box;
struct BigStruct {
one: int,
two: int,
@ -675,15 +675,15 @@ struct BigStruct {
}
fn foo(x: Box<BigStruct>) -> Box<BigStruct> {
return box *x;
return Box::new(*x);
}
fn main() {
let x = box BigStruct {
let x = Box::new(BigStruct {
one: 1,
two: 2,
one_hundred: 100,
};
});
let y = foo(x);
}
@ -695,6 +695,7 @@ than the hundred `int`s that make up the `BigStruct`.
This is an antipattern in Rust. Instead, write this:
```{rust}
# use std::boxed::Box;
struct BigStruct {
one: int,
two: int,
@ -707,13 +708,13 @@ fn foo(x: Box<BigStruct>) -> BigStruct {
}
fn main() {
let x = box BigStruct {
let x = Box::new(BigStruct {
one: 1,
two: 2,
one_hundred: 100,
};
});
let y = box foo(x);
let y = Box::new(foo(x));
}
```

View file

@ -197,6 +197,7 @@ extern crate libc;
use libc::{c_void, size_t, malloc, free};
use std::mem;
use std::ptr;
# use std::boxed::Box;
// Define a wrapper around the handle returned by the foreign code.
// Unique<T> has the same semantics as Box<T>
@ -265,7 +266,7 @@ impl<T: Send> Drop for Unique<T> {
// A comparison between the built-in `Box` and this reimplementation
fn main() {
{
let mut x = box 5i;
let mut x = Box::new(5i);
*x = 10;
} // `x` is freed here
@ -653,7 +654,7 @@ sugar for dynamic allocations via `malloc` and `free`:
```
#![no_std]
#![feature(lang_items)]
#![feature(lang_items, box_syntax)]
extern crate libc;

View file

@ -3802,18 +3802,19 @@ enum List { // error: illegal recursive enum type
But the compiler complains that the type is recursive, that is, it could be
arbitrarily large. To remedy this, Rust provides a fixed-size container called
a **box** that can hold any type. You can box up any value with the `box`
keyword. Our boxed List gets the type `Box<List>` (more on the notation when we
a **Box** that can hold any type. You can box up any value with the `Box::new`
function. Our boxed List gets the type `Box<List>` (more on the notation when we
get to generics):
```{rust}
# use std::boxed::Box;
enum List {
Node(u32, Box<List>),
Nil
}
fn main() {
let list = List::Node(0, box List::Node(1, box List::Nil));
let list = List::Node(0, Box::new(List::Node(1, Box::new(List::Nil))));
}
```
@ -3826,8 +3827,9 @@ just like regular references. This (rather silly) example dynamically allocates
an integer `5` and makes `x` a pointer to it:
```{rust}
# use std::boxed::Box;
{
let x = box 5;
let x = Box::new(5);
println!("{}", *x); // Prints 5
}
```
@ -3858,7 +3860,8 @@ Boxes are the sole owner of their contents, so you cannot take a mutable
reference to them and then use the original box:
```{rust,ignore}
let mut x = box 5;
# use std::boxed::Box;
let mut x = Box::new(5);
let y = &mut x;
*x; // you might expect 5, but this is actually an error
@ -3879,7 +3882,8 @@ As long as `y` is borrowing the contents, we cannot use `x`. After `y` is
done borrowing the value, we can use it again. This works fine:
```{rust}
let mut x = box 5;
# use std::boxed::Box;
let mut x = Box::new(5);
{
let y = &mut x;

View file

@ -1588,10 +1588,11 @@ pointer values (pointing to a type for which an implementation of the given
trait is in scope) to pointers to the trait name, used as a type.
```
# use std::boxed::Box;
# trait Shape { }
# impl Shape for int { }
# let mycircle = 0i;
let myshape: Box<Shape> = box mycircle as Box<Shape>;
let myshape: Box<Shape> = Box::new(mycircle) as Box<Shape>;
```
The resulting value is a box containing the value that was cast, along with
@ -1646,12 +1647,13 @@ fn radius_times_area<T: Circle>(c: T) -> f64 {
Likewise, supertrait methods may also be called on trait objects.
```{.ignore}
# use std::boxed::Box;
# trait Shape { fn area(&self) -> f64; }
# trait Circle : Shape { fn radius(&self) -> f64; }
# impl Shape for int { fn area(&self) -> f64 { 0.0 } }
# impl Circle for int { fn radius(&self) -> f64 { 0.0 } }
# let mycircle = 0;
let mycircle = box mycircle as Box<Circle>;
let mycircle = Box::new(mycircle) as Box<Circle>;
let nonsense = mycircle.radius() * mycircle.area();
```
@ -3376,14 +3378,17 @@ stands for a *single* data field, whereas a wildcard `..` stands for *all* the
fields of a particular variant. For example:
```
#![feature(box_syntax)]
enum List<X> { Nil, Cons(X, Box<List<X>>) }
let x: List<int> = List::Cons(10, box List::Cons(11, box List::Nil));
fn main() {
let x: List<int> = List::Cons(10, box List::Cons(11, box List::Nil));
match x {
List::Cons(_, box List::Nil) => panic!("singleton list"),
List::Cons(..) => return,
List::Nil => panic!("empty list")
match x {
List::Cons(_, box List::Nil) => panic!("singleton list"),
List::Cons(..) => return,
List::Nil => panic!("empty list")
}
}
```
@ -3436,25 +3441,28 @@ the inside of the match.
An example of a `match` expression:
```
#![feature(box_syntax)]
# fn process_pair(a: int, b: int) { }
# fn process_ten() { }
enum List<X> { Nil, Cons(X, Box<List<X>>) }
let x: List<int> = List::Cons(10, box List::Cons(11, box List::Nil));
fn main() {
let x: List<int> = List::Cons(10, box List::Cons(11, box List::Nil));
match x {
List::Cons(a, box List::Cons(b, _)) => {
process_pair(a, b);
}
List::Cons(10, _) => {
process_ten();
}
List::Nil => {
return;
}
_ => {
panic!();
match x {
List::Cons(a, box List::Cons(b, _)) => {
process_pair(a, b);
}
List::Cons(10, _) => {
process_ten();
}
List::Nil => {
return;
}
_ => {
panic!();
}
}
}
```
@ -3468,6 +3476,8 @@ Subpatterns can also be bound to variables by the use of the syntax `variable @
subpattern`. For example:
```
#![feature(box_syntax)]
enum List { Nil, Cons(uint, Box<List>) }
fn is_sorted(list: &List) -> bool {
@ -3781,12 +3791,13 @@ enclosing `enum` or `struct` type itself. Such recursion has restrictions:
An example of a *recursive* type and its use:
```
# use std::boxed::Box;
enum List<T> {
Nil,
Cons(T, Box<List<T>>)
Nil,
Cons(T, Box<List<T>>)
}
let a: List<int> = List::Cons(7, box List::Cons(13, box List::Nil));
let a: List<int> = List::Cons(7, Box::new(List::Cons(13, Box::new(List::Nil))));
```
### Pointer types
@ -3893,6 +3904,7 @@ implementation of `R`, and the pointer value of `E`.
An example of an object type:
```
# use std::boxed::Box;
trait Printable {
fn stringify(&self) -> String;
}
@ -3906,7 +3918,7 @@ fn print(a: Box<Printable>) {
}
fn main() {
print(box 10i as Box<Printable>);
print(Box::new(10i) as Box<Printable>);
}
```
@ -4100,7 +4112,8 @@ the type of a box is `std::owned::Box<T>`.
An example of a box type and value:
```
let x: Box<int> = box 10;
# use std::boxed::Box;
let x: Box<int> = Box::new(10);
```
Box values exist in 1:1 correspondence with their heap allocation, copying a
@ -4109,7 +4122,8 @@ copy of a box to move ownership of the value. After a value has been moved,
the source location cannot be used unless it is reinitialized.
```
let x: Box<int> = box 10;
# use std::boxed::Box;
let x: Box<int> = Box::new(10);
let y = x;
// attempting to use `x` will result in an error here
```

View file

@ -33,12 +33,15 @@ use core::ops::{Deref, DerefMut};
/// The following two examples are equivalent:
///
/// ```rust
/// #![feature(box_syntax)]
/// use std::boxed::HEAP;
///
/// fn main() {
/// # struct Bar;
/// # impl Bar { fn new(_a: int) { } }
/// let foo = box(HEAP) Bar::new(2);
/// let foo = box Bar::new(2);
/// let foo = box(HEAP) Bar::new(2);
/// let foo = box Bar::new(2);
/// }
/// ```
#[lang = "exchange_heap"]
#[experimental = "may be renamed; uncertain about custom allocator design"]
@ -49,10 +52,9 @@ pub static HEAP: () = ();
#[stable]
pub struct Box<T>(Unique<T>);
#[unstable]
impl<T> Box<T> {
/// Moves `x` into a freshly allocated box on the global exchange heap.
#[unstable]
#[stable]
pub fn new(x: T) -> Box<T> {
box x
}

View file

@ -125,7 +125,7 @@ const MIN_ALIGN: uint = 8;
not(feature = "external_crate"),
any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "aarch64"))]
target_arch = "aarch64")))]
const MIN_ALIGN: uint = 16;
#[cfg(feature = "external_funcs")]

View file

@ -28,8 +28,10 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
#![allow(unknown_features)]
#![feature(unsafe_destructor)]
#![feature(unboxed_closures)]
#![feature(box_syntax)]
#![allow(missing_docs)]
extern crate alloc;

View file

@ -13,7 +13,7 @@
#[stable]
macro_rules! vec {
($($x:expr),*) => ({
let xs: $crate::boxed::Box<[_]> = box [$($x),*];
let xs: $crate::boxed::Box<[_]> = $crate::boxed::Box::new([$($x),*]);
$crate::slice::SliceExt::into_vec(xs)
});
($($x:expr,)*) => (vec![$($x),*])

View file

@ -245,7 +245,7 @@ pub trait SliceExt {
/// ```rust
/// let v = &[1i, 2, 3, 4];
/// for win in v.windows(2) {
/// println!("{}", win);
/// println!("{:?}", win);
/// }
/// ```
#[stable]
@ -268,7 +268,7 @@ pub trait SliceExt {
/// ```rust
/// let v = &[1i, 2, 3, 4, 5];
/// for win in v.chunks(2) {
/// println!("{}", win);
/// println!("{:?}", win);
/// }
/// ```
#[stable]
@ -554,7 +554,7 @@ pub trait SliceExt {
/// let mut perms = v.permutations();
///
/// for p in perms {
/// println!("{}", p);
/// println!("{:?}", p);
/// }
/// ```
///

View file

@ -42,6 +42,7 @@
#![experimental]
#![allow(missing_docs)]
#[cfg(not(stage0))]
use marker::Sized;
pub type GlueFn = extern "Rust" fn(*const i8);

View file

@ -2804,7 +2804,7 @@ pub fn iterate<T, F>(seed: T, f: F) -> Iterate<T, F> where
T: Clone,
F: FnMut(T) -> T,
{
let &(ref mut f, ref mut val, ref mut first) = st;
let &mut (ref mut f, ref mut val, ref mut first) = st;
if *first {
*first = false;
} else {

View file

@ -58,6 +58,7 @@
#![no_std]
#![allow(unknown_features, raw_pointer_derive)]
#![cfg_attr(stage0, allow(unused_attributes))]
#![feature(intrinsics, lang_items)]
#![feature(simd, unsafe_destructor, slicing_syntax)]
#![feature(unboxed_closures)]

View file

@ -17,5 +17,9 @@
#![stable]
#![doc(primitive = "isize")]
#[cfg(target_word_size = "32")] int_module! { isize, 32 }
#[cfg(target_word_size = "64")] int_module! { isize, 64 }
#[cfg(any(all(stage0, target_word_size = "32"),
all(not(stage0), target_pointer_width = "32")))]
int_module! { isize, 32 }
#[cfg(any(all(stage0, target_word_size = "64"),
all(not(stage0), target_pointer_width = "64")))]
int_module! { isize, 64 }

View file

@ -66,10 +66,11 @@
//! not (`None`).
//!
//! ```
//! # use std::boxed::Box;
//! let optional: Option<Box<int>> = None;
//! check_optional(&optional);
//!
//! let optional: Option<Box<int>> = Some(box 9000);
//! let optional: Option<Box<int>> = Some(Box::new(9000));
//! check_optional(&optional);
//!
//! fn check_optional(optional: &Option<Box<int>>) {
@ -148,7 +149,6 @@ use self::Option::*;
use clone::Clone;
use cmp::{Eq, Ord};
use default::Default;
use fmt;
use iter::{ExactSizeIterator};
use iter::{Iterator, IteratorExt, DoubleEndedIterator, FromIterator};
use mem;

View file

@ -46,12 +46,13 @@
//! though unsafely, transformed from one type to the other.
//!
//! ```
//! # use std::boxed::Box;
//! use std::mem;
//!
//! unsafe {
//! let my_num: Box<int> = box 10;
//! let my_num: Box<int> = Box::new(10);
//! let my_num: *const int = mem::transmute(my_num);
//! let my_speed: Box<int> = box 88;
//! let my_speed: Box<int> = Box::new(88);
//! let my_speed: *mut int = mem::transmute(my_speed);
//!
//! // By taking ownership of the original `Box<T>` though

View file

@ -113,6 +113,5 @@ fn test_custom_state() {
::std::hash::hash::<_, CustomHasher>(t)
}
let custom = Custom { hash: 5 };
assert_eq!(hash(&Custom { hash: 5 }), 5);
}

View file

@ -7,8 +7,10 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(globs, unsafe_destructor, slicing_syntax, default_type_params)]
#![feature(unsafe_destructor, slicing_syntax)]
#![feature(unboxed_closures)]
#![feature(box_syntax)]
extern crate core;
extern crate test;

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use core::iter::range;
pub fn op1() -> Result<int, &'static str> { Ok(666) }
pub fn op2() -> Result<int, &'static str> { Err("sadface") }

View file

@ -194,7 +194,7 @@ pub trait Rng : Sized {
///
/// let mut rng = thread_rng();
/// let x = rng.gen_iter::<uint>().take(10).collect::<Vec<uint>>();
/// println!("{}", x);
/// println!("{:?}", x);
/// println!("{:?}", rng.gen_iter::<(f64, bool)>().take(5)
/// .collect::<Vec<(f64, bool)>>());
/// ```
@ -291,9 +291,9 @@ pub trait Rng : Sized {
/// let mut rng = thread_rng();
/// let mut y = [1i, 2, 3];
/// rng.shuffle(&mut y);
/// println!("{}", y.as_slice());
/// println!("{:?}", y.as_slice());
/// rng.shuffle(&mut y);
/// println!("{}", y.as_slice());
/// println!("{:?}", y.as_slice());
/// ```
fn shuffle<T>(&mut self, values: &mut [T]) {
let mut i = values.len();

View file

@ -1918,7 +1918,7 @@ impl LintPass for HardwiredLints {
}
/// Forbids using the `#[feature(...)]` attribute
#[deriving(Copy)]
#[derive(Copy)]
pub struct UnstableFeatures;
declare_lint!(UNSTABLE_FEATURES, Allow,

View file

@ -443,7 +443,7 @@ pub fn raw_emit_lint(sess: &Session, lint: &'static Lint,
}
for note in note.into_iter() {
sess.note(note.index(&FullRange));
sess.note(&note[]);
}
for span in def.into_iter() {

View file

@ -116,7 +116,7 @@ pub struct Options {
pub unstable_features: UnstableFeatures
}
#[deriving(Clone, Copy)]
#[derive(Clone, Copy)]
pub enum UnstableFeatures {
/// Hard errors for unstable features are active, as on
/// beta/stable channels.

View file

@ -29,7 +29,8 @@
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(slicing_syntax)]
#![allow(unknown_features)]
#![feature(slicing_syntax, box_syntax)]
extern crate syntax;
extern crate serialize;

View file

@ -61,7 +61,7 @@ fn remove_message(e: &mut ExpectErrorEmitter, msg: &str, lvl: Level) {
e.messages.remove(i);
}
None => {
panic!("Unexpected error: {} Expected: {}",
panic!("Unexpected error: {} Expected: {:?}",
msg, e.messages);
}
}

View file

@ -51,7 +51,7 @@ use std::rc::Rc;
use llvm::{ValueRef, True, IntEQ, IntNE};
use back::abi::FAT_PTR_ADDR;
use middle::subst;
use middle::ty::{mod, Ty, UnboxedClosureTyper};
use middle::ty::{self, Ty, UnboxedClosureTyper};
use middle::ty::Disr;
use syntax::ast;
use syntax::attr;

View file

@ -1345,7 +1345,7 @@ pub fn with_field_tys<'tcx, R, F>(tcx: &ty::ctxt<'tcx>,
tcx, enum_id, variant_id);
let fields = struct_fields(tcx, variant_id, substs);
let fields = monomorphize::normalize_associated_type(tcx, &fields);
op(variant_info.disr_val, &fields.index[])
op(variant_info.disr_val, &fields[])
}
_ => {
tcx.sess.bug("resolve didn't map this expr to a \

View file

@ -68,9 +68,13 @@ fn get_base_type_def_id<'a, 'tcx>(inference_context: &InferCtxt<'a, 'tcx>,
Some(t.principal_def_id())
}
ty_uniq(_) => {
inference_context.tcx.lang_items.owned_box()
}
ty_bool | ty_char | ty_int(..) | ty_uint(..) | ty_float(..) |
ty_str(..) | ty_vec(..) | ty_bare_fn(..) | ty_tup(..) |
ty_param(..) | ty_err | ty_open(..) | ty_uniq(_) |
ty_param(..) | ty_err | ty_open(..) |
ty_ptr(_) | ty_rptr(_, _) | ty_projection(..) => {
None
}

View file

@ -2454,7 +2454,7 @@ fn lang_struct(cx: &DocContext, did: Option<ast::DefId>,
}
/// An equality constraint on an associated type, e.g. `A=Bar` in `Foo<A=Bar>`
#[derive(Clone, PartialEq, RustcDecodable, RustcEncodable)]
#[derive(Clone, PartialEq, RustcDecodable, RustcEncodable, Show)]
pub struct TypeBinding {
pub name: String,
pub ty: Type

View file

@ -163,7 +163,7 @@ impl<K, V, S> Encodable for HashMap<K, V, S>
S: HashState,
<S as HashState>::Hasher: Hasher<Output=u64>
{
fn encode<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> {
fn encode<E: Encoder>(&self, e: &mut E) -> Result<(), E::Error> {
e.emit_map(self.len(), |e| {
let mut i = 0;
for (key, val) in self.iter() {
@ -201,7 +201,7 @@ impl<T, S> Encodable for HashSet<T, S>
S: HashState,
<S as HashState>::Hasher: Hasher<Output=u64>
{
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
fn encode<E: Encoder>(&self, s: &mut E) -> Result<(), E::Error> {
s.emit_seq(self.len(), |s| {
let mut i = 0;
for e in self.iter() {

View file

@ -175,7 +175,7 @@
//! use std::f64;
//! use std::num::Float;
//!
//! #[deriving(Show)]
//! #[derive(Show)]
//! struct Vector2D {
//! x: int,
//! y: int,

View file

@ -1284,7 +1284,7 @@ impl<'a> Writer for &'a mut (Writer+'a) {
/// process_input(tee);
/// }
///
/// println!("input processed: {}", output);
/// println!("input processed: {:?}", output);
/// # }
/// ```
pub struct RefWriter<'a, W:'a> {

View file

@ -403,7 +403,7 @@ pub fn random<T: Rand>() -> T {
///
/// let mut rng = thread_rng();
/// let sample = sample(&mut rng, range(1i, 100), 5);
/// println!("{}", sample);
/// println!("{:?}", sample);
/// ```
pub fn sample<T, I: Iterator<Item=T>, R: Rng>(rng: &mut R,
mut iter: I,

View file

@ -270,7 +270,7 @@ pub fn readdir(p: &Path) -> IoResult<Vec<Path>> {
return Err(IoError {
kind: io::InvalidInput,
desc: "path was not valid UTF-16",
detail: Some(format!("path was not valid UTF-16: {}", filename)),
detail: Some(format!("path was not valid UTF-16: {:?}", filename)),
})
}, // FIXME #12056: Convert the UCS-2 to invalid utf-8 instead of erroring
}

View file

@ -1730,11 +1730,8 @@ pub struct MacroDef {
#[cfg(test)]
mod test {
use serialize::json;
use serialize;
use codemap::*;
use super::*;
use std::fmt;
// are ASTs encodable?
#[test]

View file

@ -1295,7 +1295,7 @@ impl<'a, 'v> Visitor<'v> for MacroExterminator<'a> {
#[cfg(test)]
mod test {
use super::{pattern_bindings, expand_crate, contains_macro_use};
use super::{pattern_bindings, expand_crate};
use super::{PatIdentFinder, IdentRenamer, PatIdentRenamer, ExpansionConfig};
use ast;
use ast::{Attribute_, AttrOuter, MetaWord, Name};
@ -1404,22 +1404,6 @@ mod test {
expand_crate(&sess, test_ecfg(), vec!(), vec!(), crate_ast);
}
// make a MetaWord outer attribute with the given name
fn make_dummy_attr(s: &str) -> ast::Attribute {
Spanned {
span:codemap::DUMMY_SP,
node: Attribute_ {
id: attr::mk_attr_id(),
style: AttrOuter,
value: P(Spanned {
node: MetaWord(token::intern_and_get_ident(s)),
span: codemap::DUMMY_SP,
}),
is_sugared_doc: false,
}
}
}
fn expand_crate_str(crate_str: String) -> ast::Crate {
let ps = parse::new_parse_sess();
let crate_ast = string_to_parser(&ps, crate_str).parse_crate_mod();
@ -1655,7 +1639,7 @@ mod test {
let varref_idents : Vec<ast::Ident>
= varref.segments.iter().map(|s| s.identifier)
.collect();
println!("varref #{}: {}, resolves to {}",idx, varref_idents, varref_name);
println!("varref #{}: {:?}, resolves to {}",idx, varref_idents, varref_name);
let string = token::get_ident(final_varref_ident);
println!("varref's first segment's string: \"{}\"", string.get());
println!("binding #{}: {}, resolves to {}",

View file

@ -107,19 +107,6 @@ impl<'a> fold::Folder for PreludeInjector<'a> {
// `#![no_implicit_prelude]` at the crate level.
// fold_mod() will insert glob path.
if !no_prelude(&krate.attrs[]) {
// only add `use std::prelude::*;` if there wasn't a
// `#![no_implicit_prelude]` at the crate level.
// fold_mod() will insert glob path.
let globs_attr = attr::mk_attr_inner(attr::mk_attr_id(),
attr::mk_list_item(
InternedString::new("feature"),
vec!(
attr::mk_word_item(InternedString::new("globs")),
)));
// std_inject runs after feature checking so manually mark this attr
attr::mark_used(&globs_attr);
krate.attrs.push(globs_attr);
krate.module = self.fold_mod(krate.module);
}
krate

View file

@ -11,6 +11,7 @@
// force-host
#![feature(plugin_registrar)]
#![feature(box_syntax)]
extern crate syntax;

View file

@ -11,6 +11,7 @@
// force-host
#![feature(plugin_registrar)]
#![feature(box_syntax)]
extern crate syntax;

View file

@ -11,6 +11,7 @@
// force-host
#![feature(plugin_registrar, quote)]
#![feature(box_syntax)]
extern crate syntax;
extern crate rustc;

View file

@ -11,6 +11,7 @@
// force-host
#![feature(plugin_registrar)]
#![feature(box_syntax)]
extern crate syntax;
extern crate rustc;

View file

@ -11,6 +11,7 @@
// force-host
#![feature(plugin_registrar)]
#![feature(box_syntax)]
extern crate rustc;

View file

@ -103,6 +103,6 @@ fn main() {
args.into_iter().map(|x| x.to_string()).collect()
};
println!("{}", args);
println!("{:?}", args);
run(args.as_slice());
}

View file

@ -112,6 +112,6 @@ fn main() {
args.clone().into_iter().map(|x| x.to_string()).collect()
};
println!("{}", args);
println!("{:?}", args);
run(args.as_slice());
}

View file

@ -13,6 +13,8 @@
// multi tasking k-nucleotide
#![feature(box_syntax)]
use std::ascii::{AsciiExt, OwnedAsciiExt};
use std::cmp::Ordering::{self, Less, Greater, Equal};
use std::collections::HashMap;
@ -62,7 +64,7 @@ fn sort_and_fmt(mm: &HashMap<Vec<u8> , uint>, total: uint) -> String {
let mut buffer = String::new();
for &(ref k, v) in pairs_sorted.iter() {
buffer.push_str(format!("{} {:0.3}\n",
buffer.push_str(format!("{:?} {:0.3}\n",
k.to_ascii_uppercase(),
v).as_slice());
}
@ -191,8 +193,8 @@ fn main() {
// start processing if this is the one
('>', false) => {
match line.as_slice().slice_from(1).find_str("THREE") {
option::Option::Some(_) => { proc_mode = true; }
option::Option::None => { }
Some(_) => { proc_mode = true; }
None => { }
}
}
@ -221,6 +223,6 @@ fn main() {
// now fetch and print result messages
for (ii, _sz) in sizes.iter().enumerate() {
println!("{}", from_child[ii].recv().unwrap());
println!("{:?}", from_child[ii].recv().unwrap());
}
}

View file

@ -40,6 +40,8 @@
// ignore-android see #10393 #13206
#![feature(box_syntax)]
use std::ascii::OwnedAsciiExt;
use std::iter::repeat;
use std::slice;

View file

@ -41,6 +41,8 @@
// ignore-stage1
// ignore-cross-compile #12102
#![feature(box_syntax)]
extern crate regex;
use std::io;

View file

@ -10,6 +10,7 @@
// ignore-pretty very bad with line comments
#![feature(box_syntax)]
#![allow(non_snake_case)]
use std::io::BufferedReader;

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(unsafe_destructor)]
#![feature(unsafe_destructor, box_syntax)]
use std::os;
use std::thread::Thread;

View file

@ -11,6 +11,7 @@
// Test that we detect nested calls that could free pointers evaluated
// for earlier arguments.
#![feature(box_syntax)]
fn rewrite(v: &mut Box<uint>) -> uint {
*v = box 22;

View file

@ -11,6 +11,7 @@
// Test that we detect nested calls that could free pointers evaluated
// for earlier arguments.
#![feature(box_syntax)]
fn rewrite(v: &mut Box<uint>) -> uint {
*v = box 22;

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
struct A;
impl A {

View file

@ -10,6 +10,8 @@
//buggy.rs
#![feature(box_syntax)]
extern crate collections;
use std::collections::HashMap;

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
struct A {
x: Box<int>,
y: int,

View file

@ -11,6 +11,7 @@
// Ensure that invoking a closure counts as a unique immutable borrow
#![feature(unboxed_closures)]
#![feature(box_syntax)]
type Fn<'a> = Box<FnMut() + 'a>;

View file

@ -11,6 +11,7 @@
// Tests that two closures cannot simultaneously have mutable
// and immutable access to the variable. Issue #6801.
#![feature(box_syntax)]
fn get(x: &int) -> int {
*x

View file

@ -12,6 +12,7 @@
// access to the variable, whether that mutable access be used
// for direct assignment or for taking mutable ref. Issue #6801.
#![feature(box_syntax)]
fn a() {
let mut x = 3i;

View file

@ -12,6 +12,7 @@
// cannot also be supplied a borrowed version of that
// variable's contents. Issue #11192.
#![feature(box_syntax)]
struct Foo {
x: int

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
struct A { a: int, b: Box<int> }
fn deref_after_move() {

View file

@ -10,6 +10,8 @@
// Issue #16205.
#![feature(box_syntax)]
struct Foo {
a: [Box<int>; 3],
}

View file

@ -11,6 +11,8 @@
// This tests that we can't modify Box<&mut T> contents while they
// are borrowed.
#![feature(box_syntax)]
struct A { a: int }
struct B<'a> { a: Box<&'a mut int> }

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
fn main() {
let x = Some(box 1i);
match x {

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
fn main() {
let x = Some(box 1i);
match x {

View file

@ -14,6 +14,7 @@
// either genuine or would require more advanced changes. The latter
// cases are noted.
#![feature(box_syntax)]
fn borrow(_v: &int) {}
fn borrow_mut(_v: &mut int) {}

View file

@ -14,6 +14,7 @@
// either genuine or would require more advanced changes. The latter
// cases are noted.
#![feature(box_syntax)]
fn borrow(_v: &int) {}
fn borrow_mut(_v: &mut int) {}

View file

@ -14,6 +14,7 @@
// either genuine or would require more advanced changes. The latter
// cases are noted.
#![feature(box_syntax)]
fn borrow(_v: &int) {}
fn borrow_mut(_v: &mut int) {}

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
use std::thread::Thread;
fn borrow<F>(v: &int, f: F) where F: FnOnce(&int) {

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
fn take(_v: Box<int>) {
}

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
fn borrow<F>(v: &int, f: F) where F: FnOnce(&int) {
f(v);
}

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
pub fn main() {
let bar = box 3;
let _g = |&mut:| {

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
enum Foo {
Foo1(Box<u32>, Box<u32>),

View file

@ -11,6 +11,8 @@
// verify that an error is raised when trying to move out of a
// borrowed path.
#![feature(box_syntax)]
fn main() {
let a = box box 2i;
let b = &a;

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
fn call_f<F:FnOnce() -> int>(f: F) -> int {
f()
}

View file

@ -11,6 +11,7 @@
// Tests that the borrow checker checks all components of a path when moving
// out.
#![feature(box_syntax)]
struct S {
x : Box<int>

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
use std::thread::Thread;
fn borrow<T>(_: &T) { }

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
struct node_ {
a: Box<cycle>

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
use std::ops::Index;
struct MyVec<T> {

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
fn borrow(_v: &int) {}

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
struct A { a: int, b: int }
impl Copy for A {}

View file

@ -10,6 +10,8 @@
// Verifies all possible restrictions for statics values.
#![feature(box_syntax)]
use std::marker;
struct WithDtor;

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
trait noisy {
fn speak(&self);

View file

@ -11,6 +11,8 @@
// Test that cross-borrowing (implicitly converting from `Box<T>` to `&T`) is
// forbidden when `T` is a trait.
#![feature(box_syntax)]
struct Foo;
trait Trait {}
impl Trait for Foo {}

View file

@ -10,6 +10,8 @@
// Forbid assignment into a dynamically sized type.
#![feature(box_syntax)]
struct Fat<T: ?Sized> {
f1: int,
f2: &'static str,

View file

@ -10,6 +10,8 @@
// Forbid assignment into a dynamically sized type.
#![feature(box_syntax)]
struct Fat<T: ?Sized> {
f1: int,
f2: &'static str,

View file

@ -10,6 +10,8 @@
// Check that dynamically sized rvalues are forbidden
#![feature(box_syntax)]
pub fn main() {
let _x: Box<str> = box *"hello world";
//~^ ERROR E0161

View file

@ -9,6 +9,7 @@
// except according to those terms.
#![feature(unboxed_closures)]
#![feature(box_syntax)]
fn needs_fn<F>(x: F) where F: Fn(isize) -> isize {}

View file

@ -10,6 +10,8 @@
// error-pattern: reached the recursion limit while auto-dereferencing
#![feature(box_syntax)]
use std::ops::Deref;
struct Foo;

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
fn test<'x>(x: &'x int) {
drop::<Box<for<'z> FnMut(&'z int) -> &'z int>>(box |z| {
x

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
fn main() {
let x = box 1i;
let f = move|:| {

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
struct Foo {
x: int
}

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
struct Test<'s> {
func: Box<FnMut()+'static>
}

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
fn main() {
let a = Some(box 1);
match a {

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
fn main() {
let r = {
let x = box 42i;

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
fn do_it(x: &int) { }
fn main() {

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
trait X {
fn get_i(&self) -> int;
}

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
fn main() {
let x: Box<isize> = box 0;

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
struct Foo { a: int, b: int }
fn main() {

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_syntax)]
fn main() {
let _foo = &[1u, 2] as [usize];
//~^ ERROR cast to unsized type: `&[usize; 2]` as `[usize]`

Some files were not shown because too many files have changed in this diff Show more