More test fixes!

This commit is contained in:
Alex Crichton 2015-01-05 19:13:38 -08:00
parent ee9921aaed
commit 4b359e3aee
42 changed files with 50 additions and 328 deletions

View File

@ -1066,6 +1066,7 @@ mod tests {
}
#[allow(deprecated)]
#[test]
fn test_append() {
{
let mut m = DList::new();

View File

@ -1171,134 +1171,6 @@ impl_multiplicative! { uint, 1 }
impl_multiplicative! { f32, 1.0 }
impl_multiplicative! { f64, 1.0 }
<<<<<<< HEAD
=======
/// A trait for iterators over elements which can be compared to one another.
#[unstable = "recently renamed for new extension trait conventions"]
pub trait IteratorOrdExt<A> {
/// Consumes the entire iterator to return the maximum element.
///
/// # Example
///
/// ```rust
/// let a = [1i, 2, 3, 4, 5];
/// assert!(a.iter().max().unwrap() == &5);
/// ```
fn max(self) -> Option<A>;
/// Consumes the entire iterator to return the minimum element.
///
/// # Example
///
/// ```rust
/// let a = [1i, 2, 3, 4, 5];
/// assert!(a.iter().min().unwrap() == &1);
/// ```
fn min(self) -> Option<A>;
/// `min_max` finds the minimum and maximum elements in the iterator.
///
/// The return type `MinMaxResult` is an enum of three variants:
///
/// - `NoElements` if the iterator is empty.
/// - `OneElement(x)` if the iterator has exactly one element.
/// - `MinMax(x, y)` is returned otherwise, where `x <= y`. Two
/// values are equal if and only if there is more than one
/// element in the iterator and all elements are equal.
///
/// On an iterator of length `n`, `min_max` does `1.5 * n` comparisons,
/// and so is faster than calling `min` and `max` separately which does `2 * n` comparisons.
///
/// # Example
///
/// ```rust
/// use std::iter::MinMaxResult::{NoElements, OneElement, MinMax};
///
/// let v: [int; 0] = [];
/// assert_eq!(v.iter().min_max(), NoElements);
///
/// let v = [1i];
/// assert!(v.iter().min_max() == OneElement(&1));
///
/// let v = [1i, 2, 3, 4, 5];
/// assert!(v.iter().min_max() == MinMax(&1, &5));
///
/// let v = [1i, 2, 3, 4, 5, 6];
/// assert!(v.iter().min_max() == MinMax(&1, &6));
///
/// let v = [1i, 1, 1, 1];
/// assert!(v.iter().min_max() == MinMax(&1, &1));
/// ```
fn min_max(self) -> MinMaxResult<A>;
}
#[unstable = "trait is unstable"]
impl<T, I> IteratorOrdExt<T> for I where I: Iterator<Item=T>, T: Ord {
#[inline]
fn max(self) -> Option<T> {
self.fold(None, |max, x| {
match max {
None => Some(x),
Some(y) => Some(cmp::max(x, y))
}
})
}
#[inline]
fn min(self) -> Option<T> {
self.fold(None, |min, x| {
match min {
None => Some(x),
Some(y) => Some(cmp::min(x, y))
}
})
}
fn min_max(mut self) -> MinMaxResult<T> {
let (mut min, mut max) = match self.next() {
None => return NoElements,
Some(x) => {
match self.next() {
None => return OneElement(x),
Some(y) => if x < y {(x, y)} else {(y,x)}
}
}
};
loop {
// `first` and `second` are the two next elements we want to look at.
// We first compare `first` and `second` (#1). The smaller one is then compared to
// current minimum (#2). The larger one is compared to current maximum (#3). This
// way we do 3 comparisons for 2 elements.
let first = match self.next() {
None => break,
Some(x) => x
};
let second = match self.next() {
None => {
if first < min {
min = first;
} else if first > max {
max = first;
}
break;
}
Some(x) => x
};
if first < second {
if first < min {min = first;}
if max < second {max = second;}
} else {
if second < min {min = second;}
if max < first {max = first;}
}
}
MinMax(min, max)
}
}
>>>>>>> parent of f031671... Remove i suffix in docs
/// `MinMaxResult` is an enum returned by `min_max`. See `IteratorOrdExt::min_max` for more detail.
#[derive(Clone, PartialEq, Show)]
#[unstable = "unclear whether such a fine-grained result is widely useful"]
@ -1386,35 +1258,6 @@ impl<T, D, I> ExactSizeIterator for Cloned<I> where
I: ExactSizeIterator + Iterator<Item=D>,
{}
<<<<<<< HEAD
=======
#[unstable = "recently renamed for extension trait conventions"]
/// An extension trait for cloneable iterators.
pub trait CloneIteratorExt {
/// Repeats an iterator endlessly
///
/// # Example
///
/// ```rust
/// use std::iter::{CloneIteratorExt, count};
///
/// let a = count(1i,1i).take(1);
/// let mut cy = a.cycle();
/// assert_eq!(cy.next(), Some(1));
/// assert_eq!(cy.next(), Some(1));
/// ```
#[stable]
fn cycle(self) -> Cycle<Self>;
}
impl<I> CloneIteratorExt for I where I: Iterator + Clone {
#[inline]
fn cycle(self) -> Cycle<I> {
Cycle{orig: self.clone(), iter: self}
}
}
>>>>>>> parent of f031671... Remove i suffix in docs
/// An iterator that repeats endlessly
#[derive(Clone, Copy)]
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]

View File

@ -769,7 +769,7 @@ fn test_range_step_inclusive() {
#[test]
fn test_reverse() {
let mut ys = [1i, 2, 3, 4, 5];
ys.iter_mut().reverse_();
ys.iter_mut().reverse_in_place();
assert!(ys == [5, 4, 3, 2, 1]);
}

View File

@ -587,7 +587,7 @@ pub fn render_opts<'a, N:Clone+'a, E:Clone+'a, G:Labeller<'a,N,E>+GraphWalk<'a,N
mod tests {
use self::NodeLabels::*;
use super::{Id, Labeller, Nodes, Edges, GraphWalk, render};
use super::LabelText::{mod, LabelStr, EscStr};
use super::LabelText::{self, LabelStr, EscStr};
use std::io::IoResult;
use std::borrow::IntoCow;
use std::iter::repeat;

View File

@ -27,7 +27,7 @@ const CHACHA_ROUNDS: uint = 20; // Cryptographically secure from 8 upwards as of
///
/// [1]: D. J. Bernstein, [*ChaCha, a variant of
/// Salsa20*](http://cr.yp.to/chacha.html)
#[deriving(Copy, Clone)]
#[derive(Copy, Clone)]
pub struct ChaChaRng {
buffer: [u32; STATE_WORDS], // Internal buffer of output
state: [u32; STATE_WORDS], // Initial state
@ -284,7 +284,7 @@ mod test {
#[test]
fn test_rng_clone() {
let seed : &[_] = &[0u32, ..8];
let seed : &[_] = &[0u32; 8];
let mut rng: ChaChaRng = SeedableRng::from_seed(seed);
let mut clone = rng.clone();
for _ in range(0u, 16) {

View File

@ -403,7 +403,7 @@ pub trait SeedableRng<Seed>: Rng {
/// RNGs"](http://www.jstatsoft.org/v08/i14/paper). *Journal of
/// Statistical Software*. Vol. 8 (Issue 14).
#[allow(missing_copy_implementations)]
#[deriving(Clone)]
#[derive(Clone)]
pub struct XorShiftRng {
x: u32,
y: u32,

View File

@ -22,7 +22,7 @@ use super::cres;
use super::{RegionVariableOrigin, SubregionOrigin, TypeTrace, MiscVariable};
use middle::region;
use middle::ty::{mod, Ty};
use middle::ty::{self, Ty};
use middle::ty::{BoundRegion, FreeRegion, Region, RegionVid};
use middle::ty::{ReEmpty, ReStatic, ReInfer, ReFree, ReEarlyBound};
use middle::ty::{ReLateBound, ReScope, ReVar, ReSkolemized, BrFresh};
@ -69,7 +69,7 @@ pub enum Verify<'tcx> {
VerifyGenericBound(GenericKind<'tcx>, SubregionOrigin<'tcx>, Region, Vec<Region>),
}
#[deriving(Clone, Show, PartialEq, Eq)]
#[derive(Clone, Show, PartialEq, Eq)]
pub enum GenericKind<'tcx> {
Param(ty::ParamTy),
Projection(ty::ProjectionTy<'tcx>),

View File

@ -22,7 +22,7 @@ use syntax::codemap;
use syntax::diagnostic;
use syntax::diagnostic::{Emitter, Handler, Level, mk_handler};
use std::ffi::{mod, CString};
use std::ffi::{self, CString};
use std::io::Command;
use std::io::fs;
use std::iter::Unfold;
@ -32,7 +32,7 @@ use std::mem;
use std::sync::{Arc, Mutex};
use std::sync::mpsc::channel;
use std::thread;
use libc::{mod, c_uint, c_int, c_void};
use libc::{self, c_uint, c_int, c_void};
#[derive(Clone, Copy, PartialEq, PartialOrd, Ord, Eq)]
pub enum OutputType {

View File

@ -88,7 +88,7 @@ use util::nodemap::NodeMap;
use arena::TypedArena;
use libc::{c_uint, uint64_t};
use std::ffi::{mod, CString};
use std::ffi::{self, CString};
use std::cell::{Cell, RefCell};
use std::collections::HashSet;
use std::mem;

View File

@ -195,10 +195,10 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
ast::PatRegion(ref inner, mutbl) => {
let inner_ty = fcx.infcx().next_ty_var();
// SNAP c894171 remove this `if`-`else` entirely after next snapshot
// SNAP b2085d9 remove this `if`-`else` entirely after next snapshot
let mutbl = if mutbl == ast::MutImmutable {
ty::deref(fcx.infcx().shallow_resolve(expected), true)
.map(|mt| mt.mutbl).unwrap_or(ast::MutImmutable);
.map(|mt| mt.mutbl).unwrap_or(ast::MutImmutable)
} else {
mutbl
};

View File

@ -92,7 +92,7 @@ use middle::region::CodeExtent;
use middle::traits;
use middle::ty::{ReScope};
use middle::ty::{self, Ty, MethodCall};
use middle::infer::{mod, GenericKind};
use middle::infer::{self, GenericKind};
use middle::pat_util;
use util::ppaux::{ty_to_string, Repr};

View File

@ -2298,7 +2298,7 @@ impl ::Decoder<DecoderError> for Decoder {
}
/// A trait for converting values to JSON
pub trait ToJson for Sized? {
pub trait ToJson {
/// Converts the value of `self` to an instance of JSON
fn to_json(&self) -> Json;
}

View File

@ -172,7 +172,7 @@ pub trait Decoder<E> {
fn error(&mut self, err: &str) -> E;
}
pub trait Encodable<S:Encoder<E>, E> for Sized? {
pub trait Encodable<S:Encoder<E>, E> {
fn encode(&self, s: &mut S) -> Result<(), E>;
}

View File

@ -128,8 +128,8 @@ impl DynamicLibrary {
// This function should have a lifetime constraint of 'a on
// T but that feature is still unimplemented
let raw_string = CString::from_slice(symbol.as_bytes());
let maybe_symbol_value = dl::check_for_errors_in(|| {
let raw_string = CString::from_slice(symbol.as_bytes());
dl::symbol(self.handle, raw_string.as_ptr())
});

View File

@ -253,8 +253,6 @@ pub mod num;
/* Runtime and platform support */
pub mod thread_local; // first for macros
#[cfg_attr(stage0, macro_escape)]
#[cfg_attr(not(stage0), macro_use)]
pub mod thread_local;

View File

@ -245,7 +245,7 @@ pub mod reader;
/// The standard RNG. This is designed to be efficient on the current
/// platform.
#[deriving(Copy, Clone)]
#[derive(Copy, Clone)]
pub struct StdRng {
rng: IsaacWordRng,
}
@ -322,7 +322,7 @@ static THREAD_RNG_RESEED_THRESHOLD: uint = 32_768;
type ThreadRngInner = reseeding::ReseedingRng<StdRng, ThreadRngReseeder>;
/// The thread-local RNG.
#[deriving(Clone)]
#[derive(Clone)]
pub struct ThreadRng {
rng: Rc<RefCell<ThreadRngInner>>,
}

View File

@ -466,19 +466,17 @@ fn free_handle(handle: *mut ()) {
#[cfg(test)]
mod tests {
use c_str::ToCStr;
use prelude::v1::*;
use str;
use ffi::CString;
use super::make_command_line;
#[test]
fn test_make_command_line() {
use prelude::v1::*;
use str;
use c_str::CString;
use super::make_command_line;
fn test_wrapper(prog: &str, args: &[&str]) -> String {
make_command_line(&prog.to_c_str(),
make_command_line(&CString::from_slice(prog.as_bytes()),
args.iter()
.map(|a| a.to_c_str())
.map(|a| CString::from_slice(a.as_bytes()))
.collect::<Vec<CString>>()
.as_slice())
}

View File

@ -267,7 +267,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
}
}
ast::ItemImpl(_, polarity, _, _, _, ref items) => {
ast::ItemImpl(_, polarity, _, _, _, _) => {
match polarity {
ast::ImplPolarity::Negative => {
self.gate_feature("optin_builtin_traits",
@ -294,18 +294,6 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
i.span,
"the new orphan check rules will eventually be strictly enforced");
}
for item in items.iter() {
match *item {
ast::MethodImplItem(_) => {}
ast::TypeImplItem(ref typedef) => {
self.gate_feature("associated_types",
typedef.span,
"associated types are \
experimental")
}
}
}
}
_ => {}

View File

@ -1244,7 +1244,7 @@ impl<'a> Parser<'a> {
let _ = self.parse_ret_ty();
self.obsolete(ty_closure_span, ObsoleteClosureType);
self.obsolete(ty_closure_span, ObsoleteSyntax::ClosureType);
TyInfer
}
@ -3897,16 +3897,10 @@ impl<'a> Parser<'a> {
_ => {
let e = self.mk_mac_expr(span.lo,
span.hi,
<<<<<<< HEAD
macro.and_then(|m| m.node));
mac.and_then(|m| m.node));
let e = self.parse_dot_or_call_expr_with(e);
let e = self.parse_more_binops(e, 0);
let e = self.parse_assign_expr_with(e);
=======
mac.and_then(|m| m.node));
let e =
self.parse_dot_or_call_expr_with(e);
>>>>>>> kmc/macro-reform
self.handle_expression_like_statement(
e,
ast::DUMMY_NODE_ID,
@ -5082,7 +5076,7 @@ impl<'a> Parser<'a> {
}
let _tref = Parser::trait_ref_from_ident(ident, span);
self.obsolete(span, ObsoleteForSized);
self.obsolete(span, ObsoleteSyntax::ForSized);
None
} else {

View File

@ -65,8 +65,8 @@ impl<'a, 'v> Visitor<'v> for ShowSpanVisitor<'a> {
visit::walk_ty(self, t);
}
fn visit_mac(&mut self, macro: &ast::Mac) {
visit::walk_mac(self, macro);
fn visit_mac(&mut self, mac: &ast::Mac) {
visit::walk_mac(self, mac);
}
}

View File

@ -10,7 +10,7 @@
// Test inherant trait impls work cross-crait.
pub trait Bar<'a> for ?Sized : 'a {}
pub trait Bar<'a> : 'a {}
impl<'a> Bar<'a> {
pub fn bar(&self) {}

View File

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// force-host
#[macro_export]
macro_rules! macro_one { () => ("one") }

View File

@ -11,8 +11,6 @@
// Test equality constraints in a where clause where the type being
// equated appears in a supertrait.
#![feature(associated_types)]
pub trait Vehicle {
type Color;

View File

@ -11,8 +11,6 @@
// Test equality constraints in a where clause where the type being
// equated appears in a supertrait.
#![feature(associated_types)]
pub trait Vehicle {
type Color;

View File

@ -11,8 +11,6 @@
// Test equality constraints in a where clause where the type being
// equated appears in a supertrait.
#![feature(associated_types)]
pub trait Vehicle {
type Color;

View File

@ -1,33 +0,0 @@
// 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.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <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.
trait Get {
type Value; //~ ERROR associated types are experimental
fn get(&self) -> Get::Value;
}
struct Struct {
x: int,
}
impl Get for Struct {
type Value = int; //~ ERROR associated types are experimental
fn get(&self) -> int {
self.x
}
}
fn main() {
let s = Struct {
x: 100,
};
assert_eq!(s.get(), 100);
}

View File

@ -11,8 +11,6 @@
// Test that we report an error if the trait ref in an qualified type
// uses invalid type arguments.
#![feature(associated_types)]
trait Foo<T> {
type Bar;
fn get_bar(&self) -> Self::Bar;

View File

@ -11,8 +11,6 @@
// Test that we do not ICE when an impl is missing an associated type (and that we report
// a useful error, of course).
#![feature(associated_types)]
trait Trait {
type Type;
}

View File

@ -1,22 +0,0 @@
// 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.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <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.
// aux-build:default_type_params_xc.rs
#![deny(default_type_param_usage)]
extern crate default_type_params_xc;
pub struct FooAlloc;
pub type VecFoo<T> = default_type_params_xc::FakeVec<T, FooAlloc>;
//~^ ERROR: default type parameters are experimental
fn main() {}

View File

@ -1,15 +0,0 @@
// 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.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <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.
struct Heap;
struct Vec<T, A = Heap>; //~ ERROR: default type parameters are experimental
fn main() {}

View File

@ -1,14 +0,0 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <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.
use std::*;
//~^ ERROR: glob import statements are experimental
fn main() {}

View File

@ -10,7 +10,7 @@
fn main() {
assert!(1 == 2)
assert!(3 == 4) //~ ERROR expected one of `.`, `;`, or `}`, found `assert`
assert!(3 == 4) //~ ERROR expected one of `.`, `;`, `}`, or an operator, found `assert`
println!("hello");
}

View File

@ -13,8 +13,8 @@ fn main() {
// (separate lines to ensure the spans are accurate)
// SNAP c894171 uncomment this after the next snapshot
// NOTE(stage0) just in case tidy doesn't check SNAP's in tests
// SNAP b2085d9 uncomment this after the next snapshot
// NOTE(stage0) just in case tidy doesn't check snap's in tests
// let &_ // ~ ERROR expected `&mut int`, found `&_`
// = foo;
let &mut _ = foo;

View File

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(associated_types)]
trait X {}
trait Iter {

View File

@ -20,7 +20,7 @@ fn f2<X>(x: &X) {
}
// Bounded.
trait T for {}
trait T {}
fn f3<X: ?Sized + T>(x: &X) {
f4::<X>(x);
//~^ ERROR the trait `core::kinds::Sized` is not implemented

View File

@ -18,8 +18,6 @@ pub fn main() {
unsafe {
let foo = &A as *const u8;
assert_eq!(str::from_utf8_unchecked(&A), "hi");
assert_eq!(String::from_raw_buf_len(foo, A.len()), "hi".to_string());
assert_eq!(String::from_raw_buf_len(C, B.len()), "hi".to_string());
assert!(*C == A[0]);
assert!(*(&B[0] as *const u8) == A[0]);
}

View File

@ -16,7 +16,7 @@
use std::kinds::Sized;
// Note: this must be generic for the problem to show up
trait Foo<A> for ?Sized {
trait Foo<A> {
fn foo(&self);
}

View File

@ -27,7 +27,7 @@ struct Foo<'a,'tcx:'a> {
impl<'a,'tcx> Foo<'a,'tcx> {
fn bother(&mut self) -> int {
self.elaborate_bounds(|this| {
self.elaborate_bounds(box |this| {
// (*) Here: type of `this` is `&'f0 Foo<&'f1, '_2>`,
// where `'f0` and `'f1` are fresh, free regions that
// result from the bound regions on the closure, and `'2`
@ -50,7 +50,7 @@ impl<'a,'tcx> Foo<'a,'tcx> {
fn elaborate_bounds(
&mut self,
mk_cand: for<'b>|this: &mut Foo<'b, 'tcx>| -> int)
mut mk_cand: Box<for<'b> FnMut(&mut Foo<'b, 'tcx>) -> int>)
-> int
{
mk_cand(self)

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::ffi;
use std::io::process::{Command, ProcessOutput};
use std::os;
use std::rt::unwind::try;
@ -34,7 +35,8 @@ fn start(argc: int, argv: *const *const u8) -> int {
let args = unsafe {
range(0, argc as uint).map(|i| {
String::from_raw_buf(*argv.offset(i as int)).into_bytes()
let ptr = *argv.offset(i as int) as *const _;
ffi::c_str_to_bytes(&ptr).to_vec()
}).collect::<Vec<_>>()
};
let me = args[0].as_slice();

View File

@ -12,9 +12,9 @@
// Test syntax checks for `?Sized` syntax.
trait T1 for ?Sized {}
pub trait T2 for ?Sized {}
trait T3<X: T1> for ?Sized: T2 {}
trait T1 {}
pub trait T2 {}
trait T3<X: T1> : T2 {}
trait T4<X: ?Sized> {}
trait T5<X: ?Sized, Y> {}
trait T6<Y, X: ?Sized> {}

View File

@ -22,7 +22,7 @@ fn f2<X>(x: &X) {
}
// Bounded.
trait T for ?Sized {}
trait T {}
fn f3<X: T+?Sized>(x: &X) {
f3::<X>(x);
}
@ -32,7 +32,7 @@ fn f4<X: T>(x: &X) {
}
// Self type.
trait T2 for ?Sized {
trait T2 {
fn f() -> Box<Self>;
}
struct S;
@ -48,7 +48,7 @@ fn f6<X: T2>(x: &X) {
let _: Box<X> = T2::f();
}
trait T3 for ?Sized {
trait T3 {
fn f() -> Box<Self>;
}
impl T3 for S {

View File

@ -11,6 +11,8 @@
#![feature(lang_items)]
#![no_std]
extern crate "std" as other;
#[macro_use]
extern crate core;
extern crate libc;
@ -22,10 +24,6 @@ use core::option::Option::Some;
use core::slice::SliceExt;
use collections::vec::Vec;
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
#[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} }
// Issue #16806
#[start]