More test fixes

This commit is contained in:
Alex Crichton 2015-01-06 16:16:35 -08:00
parent 24ccb34266
commit a64000820f
64 changed files with 227 additions and 187 deletions

View File

@ -9,7 +9,7 @@
// except according to those terms.
#![crate_type = "bin"]
#![feature(phase, slicing_syntax, globs, unboxed_closures)]
#![feature(slicing_syntax, unboxed_closures)]
#![deny(warnings)]

View File

@ -167,10 +167,10 @@ fn parse_version(header: &[u8]) -> Result<Version, ParseError> {
let version = parse_version(&[1, 2, 3, 4]);
match version {
Ok(v) => {
println!("working with version: {}", v);
println!("working with version: {:?}", v);
}
Err(e) => {
println!("error parsing header: {}", e);
println!("error parsing header: {:?}", e);
}
}
```

View File

@ -42,7 +42,7 @@ the pattern in the above code:
# let input_1 = T::SpecialA(0);
# let input_2 = T::SpecialA(0);
macro_rules! early_return {
($inp:expr $sp:path) => ( // invoke it like `(input_5 SpecialE)`
($inp:expr, $sp:path) => ( // invoke it like `(input_5 SpecialE)`
match $inp {
$sp(x) => { return x; }
_ => {}
@ -50,9 +50,9 @@ macro_rules! early_return {
);
}
// ...
early_return!(input_1 T::SpecialA);
early_return!(input_1, T::SpecialA);
// ...
early_return!(input_2 T::SpecialB);
early_return!(input_2, T::SpecialB);
# return 0;
# }
# fn main() {}

View File

@ -620,7 +620,7 @@ enum List<T> {
fn main() {
let list: List<int> = List::Cons(1, box List::Cons(2, box List::Cons(3, box List::Nil)));
println!("{}", list);
println!("{:?}", list);
}
```

View File

@ -41,7 +41,7 @@
//! let five = five.clone();
//!
//! Thread::spawn(move || {
//! println!("{}", five);
//! println!("{:?}", five);
//! });
//! }
//! ```

View File

@ -65,7 +65,7 @@
#![no_std]
#![allow(unknown_features)]
#![feature(lang_items, phase, unsafe_destructor)]
#![feature(lang_items, unsafe_destructor)]
#[macro_use]
extern crate core;

View File

@ -143,17 +143,17 @@ static FALSE: bool = false;
/// bv.set(3, true);
/// bv.set(5, true);
/// bv.set(7, true);
/// println!("{}", bv.to_string());
/// println!("{:?}", bv);
/// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());
///
/// // flip all values in bitvector, producing non-primes less than 10
/// bv.negate();
/// println!("{}", bv.to_string());
/// println!("{:?}", bv);
/// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());
///
/// // reset bitvector to empty
/// bv.clear();
/// println!("{}", bv.to_string());
/// println!("{:?}", bv);
/// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());
/// ```
#[stable]
@ -1881,10 +1881,10 @@ mod tests {
#[test]
fn test_to_str() {
let zerolen = Bitv::new();
assert_eq!(zerolen.to_string(), "");
assert_eq!(format!("{:?}", zerolen), "");
let eightbits = Bitv::from_elem(8u, false);
assert_eq!(eightbits.to_string(), "00000000")
assert_eq!(format!("{:?}", eightbits), "00000000")
}
#[test]
@ -1910,7 +1910,7 @@ mod tests {
let mut b = Bitv::from_elem(2, false);
b.set(0, true);
b.set(1, false);
assert_eq!(b.to_string(), "10");
assert_eq!(format!("{:?}", b), "10");
assert!(!b.none() && !b.all());
}
@ -2245,7 +2245,7 @@ mod tests {
fn test_from_bytes() {
let bitv = Bitv::from_bytes(&[0b10110110, 0b00000000, 0b11111111]);
let str = concat!("10110110", "00000000", "11111111");
assert_eq!(bitv.to_string(), str);
assert_eq!(format!("{:?}", bitv), str);
}
#[test]
@ -2264,7 +2264,7 @@ mod tests {
fn test_from_bools() {
let bools = vec![true, false, true, true];
let bitv: Bitv = bools.iter().map(|n| *n).collect();
assert_eq!(bitv.to_string(), "1011");
assert_eq!(format!("{:?}", bitv), "1011");
}
#[test]
@ -2622,7 +2622,7 @@ mod bitv_set_test {
s.insert(10);
s.insert(50);
s.insert(2);
assert_eq!("{1, 2, 10, 50}", s.to_string());
assert_eq!("BitvSet {1u, 2u, 10u, 50u}", format!("{:?}", s));
}
#[test]

View File

@ -1347,7 +1347,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
///
/// // count the number of occurrences of letters in the vec
/// for x in vec!["a","b","a","c","a","b"].iter() {
/// match count.entry(x) {
/// match count.entry(*x) {
/// Entry::Vacant(view) => {
/// view.insert(1);
/// },

View File

@ -842,9 +842,9 @@ mod test {
set.insert(1);
set.insert(2);
let set_str = format!("{}", set);
let set_str = format!("{:?}", set);
assert!(set_str == "{1, 2}");
assert_eq!(format!("{}", empty), "{}");
assert_eq!(set_str, "BTreeSet {1i, 2i}");
assert_eq!(format!("{:?}", empty), "BTreeSet {}");
}
}

View File

@ -1018,12 +1018,12 @@ mod tests {
#[test]
fn test_show() {
let list: DList<int> = range(0i, 10).collect();
assert!(list.to_string() == "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
assert_eq!(format!("{:?}", list), "DList [0i, 1i, 2i, 3i, 4i, 5i, 6i, 7i, 8i, 9i]");
let list: DList<&str> = vec!["just", "one", "test", "more"].iter()
.map(|&s| s)
.collect();
assert!(list.to_string() == "[just, one, test, more]");
assert_eq!(format!("{:?}", list), "DList [\"just\", \"one\", \"test\", \"more\"]");
}
#[cfg(test)]

View File

@ -24,6 +24,7 @@
#![allow(unknown_features)]
#![feature(unsafe_destructor, slicing_syntax)]
#![feature(old_impl_check)]
#![feature(unboxed_closures)]
#![no_std]
#[macro_use]

View File

@ -1648,21 +1648,15 @@ mod tests {
assert_eq!(d.len(), 3u);
d.push_back(137);
assert_eq!(d.len(), 4u);
debug!("{}", d.front());
assert_eq!(*d.front().unwrap(), 42);
debug!("{}", d.back());
assert_eq!(*d.back().unwrap(), 137);
let mut i = d.pop_front();
debug!("{}", i);
assert_eq!(i, Some(42));
i = d.pop_back();
debug!("{}", i);
assert_eq!(i, Some(137));
i = d.pop_back();
debug!("{}", i);
assert_eq!(i, Some(137));
i = d.pop_back();
debug!("{}", i);
assert_eq!(i, Some(17));
assert_eq!(d.len(), 0u);
d.push_back(3);
@ -2308,12 +2302,12 @@ mod tests {
#[test]
fn test_show() {
let ringbuf: RingBuf<int> = range(0i, 10).collect();
assert!(format!("{}", ringbuf) == "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
assert_eq!(format!("{:?}", ringbuf), "RingBuf [0i, 1i, 2i, 3i, 4i, 5i, 6i, 7i, 8i, 9i]");
let ringbuf: RingBuf<&str> = vec!["just", "one", "test", "more"].iter()
.map(|&s| s)
.collect();
assert!(format!("{}", ringbuf) == "[just, one, test, more]");
assert_eq!(format!("{:?}", ringbuf), "RingBuf [\"just\", \"one\", \"test\", \"more\"]");
}
#[test]

View File

@ -922,7 +922,6 @@ pub trait ToString {
}
#[cfg(stage0)]
//NOTE(stage0): remove after stage0 snapshot
impl<T: fmt::Show> ToString for T {
fn to_string(&self) -> String {
use core::fmt::Writer;

View File

@ -1448,14 +1448,23 @@ impl<T> Default for Vec<T> {
}
#[experimental = "waiting on Show stability"]
impl<T:fmt::Show> fmt::Show for Vec<T> {
impl<T: fmt::Show> fmt::Show for Vec<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Show::fmt(self.as_slice(), f)
}
}
#[cfg(stage0)]
#[experimental = "waiting on Show stability"]
impl<T:fmt::String> fmt::String for Vec<T> {
impl<T: fmt::Show> fmt::String for Vec<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self.as_slice(), f)
}
}
#[cfg(not(stage0))]
#[experimental = "waiting on Show stability"]
impl<T: fmt::String> fmt::String for Vec<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self.as_slice(), f)
}

View File

@ -46,10 +46,10 @@
//! // different type: just print it out unadorned.
//! match value_any.downcast_ref::<String>() {
//! Some(as_string) => {
//! println!("String ({}): {:?}", as_string.len(), as_string);
//! println!("String ({}): {}", as_string.len(), as_string);
//! }
//! None => {
//! println!("{}", value);
//! println!("{:?}", value);
//! }
//! }
//! }

View File

@ -213,15 +213,12 @@ pub struct Arguments<'a> {
args: &'a [Argument<'a>],
}
#[cfg(stage0)]
//FIXME: remove after stage0 snapshot
impl<'a> Show for Arguments<'a> {
fn fmt(&self, fmt: &mut Formatter) -> Result {
write(fmt.buf, *self)
String::fmt(self, fmt)
}
}
#[cfg(not(stage0))]
impl<'a> String for Arguments<'a> {
fn fmt(&self, fmt: &mut Formatter) -> Result {
write(fmt.buf, *self)
@ -799,10 +796,15 @@ floating! { f64 }
impl<T> Show for *const T {
fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) }
}
impl<T> String for *const T {
fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) }
}
impl<T> Show for *mut T {
fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) }
}
impl<T> String for *mut T {
fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) }
}
macro_rules! peel {
($name:ident, $($other:ident,)*) => (tuple! { $($other,)* })
@ -861,8 +863,12 @@ impl<T: Show> Show for [T] {
}
}
impl<T: String> String for [T] {
#[cfg(stage0)]
impl<T: Show> String for [T] {
fn fmt(&self, f: &mut Formatter) -> Result {
if f.flags & (1 << (rt::FlagAlternate as uint)) == 0 {
try!(write!(f, "["));
}
let mut is_first = true;
for x in self.iter() {
if is_first {
@ -870,7 +876,31 @@ impl<T: String> String for [T] {
} else {
try!(write!(f, ", "));
}
try!(String::fmt(x, f))
try!(write!(f, "{}", *x))
}
if f.flags & (1 << (rt::FlagAlternate as uint)) == 0 {
try!(write!(f, "]"));
}
Ok(())
}
}
#[cfg(not(stage0))]
impl<T: String> String for [T] {
fn fmt(&self, f: &mut Formatter) -> Result {
if f.flags & (1 << (rt::FlagAlternate as uint)) == 0 {
try!(write!(f, "["));
}
let mut is_first = true;
for x in self.iter() {
if is_first {
is_first = false;
} else {
try!(write!(f, ", "));
}
try!(write!(f, "{}", *x))
}
if f.flags & (1 << (rt::FlagAlternate as uint)) == 0 {
try!(write!(f, "]"));
}
Ok(())
}
@ -882,6 +912,12 @@ impl Show for () {
}
}
impl String for () {
fn fmt(&self, f: &mut Formatter) -> Result {
f.pad("()")
}
}
impl<T: Copy + Show> Show for Cell<T> {
fn fmt(&self, f: &mut Formatter) -> Result {
write!(f, "Cell {{ value: {:?} }}", self.get())

View File

@ -182,8 +182,8 @@ macro_rules! writeln {
($dst:expr, $fmt:expr) => (
write!($dst, concat!($fmt, "\n"))
);
($dst:expr, $fmt:expr, $($arg:expr),*) => (
write!($dst, concat!($fmt, "\n"), $($arg,)*)
($dst:expr, $fmt:expr, $($arg:tt)*) => (
write!($dst, concat!($fmt, "\n"), $($arg)*)
);
}

View File

@ -51,8 +51,8 @@
//! }
//! }
//! fn main() {
//! println!("{}", Point {x: 1, y: 0} + Point {x: 2, y: 3});
//! println!("{}", Point {x: 1, y: 0} - Point {x: 2, y: 3});
//! println!("{:?}", Point {x: 1, y: 0} + Point {x: 2, y: 3});
//! println!("{:?}", Point {x: 1, y: 0} - Point {x: 2, y: 3});
//! }
//! ```
//!

View File

@ -238,7 +238,7 @@ impl<T> Option<T> {
/// // First, cast `Option<String>` to `Option<&String>` with `as_ref`,
/// // then consume *that* with `map`, leaving `num_as_str` on the stack.
/// let num_as_int: Option<uint> = num_as_str.as_ref().map(|n| n.len());
/// println!("still can print num_as_str: {}", num_as_str);
/// println!("still can print num_as_str: {:?}", num_as_str);
/// ```
#[inline]
#[stable]

View File

@ -25,7 +25,7 @@
//! use std::simd::f32x4;
//! let a = f32x4(40.0, 41.0, 42.0, 43.0);
//! let b = f32x4(1.0, 1.1, 3.4, 9.8);
//! println!("{}", a + b);
//! println!("{:?}", a + b);
//! }
//! ```
//!

View File

@ -140,7 +140,7 @@ pub trait Rng : Sized {
///
/// let mut v = [0u8; 13579];
/// thread_rng().fill_bytes(&mut v);
/// println!("{}", v.as_slice());
/// println!("{:?}", v.as_slice());
/// ```
fn fill_bytes(&mut self, dest: &mut [u8]) {
// this could, in theory, be done by transmuting dest to a
@ -176,7 +176,7 @@ pub trait Rng : Sized {
/// let mut rng = thread_rng();
/// let x: uint = rng.gen();
/// println!("{}", x);
/// println!("{}", rng.gen::<(f64, bool)>());
/// println!("{:?}", rng.gen::<(f64, bool)>());
/// ```
#[inline(always)]
fn gen<T: Rand>(&mut self) -> T {
@ -194,8 +194,8 @@ pub trait Rng : Sized {
/// let mut rng = thread_rng();
/// let x = rng.gen_iter::<uint>().take(10).collect::<Vec<uint>>();
/// println!("{}", x);
/// println!("{}", rng.gen_iter::<(f64, bool)>().take(5)
/// .collect::<Vec<(f64, bool)>>());
/// println!("{:?}", rng.gen_iter::<(f64, bool)>().take(5)
/// .collect::<Vec<(f64, bool)>>());
/// ```
fn gen_iter<'a, T: Rand>(&'a mut self) -> Generator<'a, T, Self> {
Generator { rng: self }
@ -268,7 +268,7 @@ pub trait Rng : Sized {
///
/// let choices = [1i, 2, 4, 8, 16, 32];
/// let mut rng = thread_rng();
/// println!("{}", rng.choose(&choices));
/// println!("{:?}", rng.choose(&choices));
/// # // uncomment when slicing syntax is stable
/// //assert_eq!(rng.choose(choices.index(&(0..0))), None);
/// ```

View File

@ -12,7 +12,7 @@ macro_rules! regex {
($re:expr) => (
match ::regex::Regex::new($re) {
Ok(re) => re,
Err(err) => panic!("{}", err),
Err(err) => panic!("{:?}", err),
}
);
}

View File

@ -162,7 +162,7 @@ macro_rules! mat {
sgot = &sgot[..expected.len()]
}
if expected != sgot {
panic!("For RE '{}' against '{}', expected '{}' but got '{}'",
panic!("For RE '{}' against '{}', expected '{:?}' but got '{:?}'",
$re, text, expected, sgot);
}
}

View File

@ -204,7 +204,7 @@ impl<'a> CrateReader<'a> {
match i.node {
ast::ViewItemExternCrate(ident, ref path_opt, id) => {
let ident = token::get_ident(ident);
debug!("resolving extern crate stmt. ident: {} path_opt: {}",
debug!("resolving extern crate stmt. ident: {} path_opt: {:?}",
ident, path_opt);
let name = match *path_opt {
Some((ref path_str, _)) => {

View File

@ -419,7 +419,7 @@ mod test {
graph.each_incoming_edge(start_index, |edge_index, edge| {
assert!(graph.edge_data(edge_index) == &edge.data);
assert!(counter < expected_incoming.len());
debug!("counter={} expected={} edge_index={} edge={}",
debug!("counter={:?} expected={:?} edge_index={:?} edge={:?}",
counter, expected_incoming[counter], edge_index, edge);
match expected_incoming[counter] {
(ref e, ref n) => {
@ -437,7 +437,7 @@ mod test {
graph.each_outgoing_edge(start_index, |edge_index, edge| {
assert!(graph.edge_data(edge_index) == &edge.data);
assert!(counter < expected_outgoing.len());
debug!("counter={} expected={} edge_index={} edge={}",
debug!("counter={:?} expected={:?} edge_index={:?} edge={:?}",
counter, expected_outgoing[counter], edge_index, edge);
match expected_outgoing[counter] {
(ref e, ref n) => {

View File

@ -1726,7 +1726,7 @@ impl fmt::Show for RegionVid {
impl<'tcx> fmt::Show for FnSig<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "({}; variadic: {})->{}", self.inputs, self.variadic, self.output)
write!(f, "({:?}; variadic: {})->{:?}", self.inputs, self.variadic, self.output)
}
}

View File

@ -418,7 +418,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
self.ty_to_string(t_glb));
match self.glb().tys(t1, t2) {
Err(e) => {
panic!("unexpected error computing LUB: {}", e)
panic!("unexpected error computing LUB: {:?}", e)
}
Ok(t) => {
self.assert_eq(t, t_glb);
@ -841,7 +841,7 @@ fn walk_ty_skip_subtree() {
let mut walker = uniq_ty.walk();
while let Some(t) = walker.next() {
debug!("walked to {}", t);
debug!("walked to {:?}", t);
let (expected_ty, skip) = expected.pop().unwrap();
assert_eq!(t, expected_ty);
if skip { walker.skip_current_subtree(); }

View File

@ -446,7 +446,7 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext,
for pass in config.passes.iter() {
let pass = CString::from_slice(pass.as_bytes());
if !llvm::LLVMRustAddPass(mpm, pass.as_ptr()) {
cgcx.handler.warn(format!("unknown pass {}, ignoring",
cgcx.handler.warn(format!("unknown pass {:?}, ignoring",
pass).as_slice());
}
}

View File

@ -195,7 +195,7 @@ 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 b2085d9 remove this `if`-`else` entirely after next snapshot
// SNAP 340ac04 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)

View File

@ -176,8 +176,6 @@ impl TocBuilder {
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl fmt::Show for Toc {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)

View File

@ -2005,7 +2005,7 @@ macro_rules! expect {
match $e {
Json::Null => Ok(()),
other => Err(ExpectedError("Null".to_string(),
format!("{:?}", other)))
format!("{}", other)))
}
});
($e:expr, $t:ident) => ({
@ -2013,7 +2013,7 @@ macro_rules! expect {
Json::$t(v) => Ok(v),
other => {
Err(ExpectedError(stringify!($t).to_string(),
format!("{:?}", other)))
format!("{}", other)))
}
}
})
@ -2025,20 +2025,20 @@ macro_rules! read_primitive {
match self.pop() {
Json::I64(f) => match num::cast(f) {
Some(f) => Ok(f),
None => Err(ExpectedError("Number".to_string(), format!("{:?}", f))),
None => Err(ExpectedError("Number".to_string(), format!("{}", f))),
},
Json::U64(f) => match num::cast(f) {
Some(f) => Ok(f),
None => Err(ExpectedError("Number".to_string(), format!("{:?}", f))),
None => Err(ExpectedError("Number".to_string(), format!("{}", f))),
},
Json::F64(f) => Err(ExpectedError("Integer".to_string(), format!("{:?}", f))),
Json::F64(f) => Err(ExpectedError("Integer".to_string(), format!("{}", f))),
// re: #12967.. a type w/ numeric keys (ie HashMap<uint, V> etc)
// is going to have a string here, as per JSON spec.
Json::String(s) => match s.parse() {
Some(f) => Ok(f),
None => Err(ExpectedError("Number".to_string(), s)),
},
value => Err(ExpectedError("Number".to_string(), format!("{:?}", value))),
value => Err(ExpectedError("Number".to_string(), format!("{}", value))),
}
}
}
@ -2078,7 +2078,7 @@ impl ::Decoder for Decoder {
}
},
Json::Null => Ok(f64::NAN),
value => Err(ExpectedError("Number".to_string(), format!("{:?}", value)))
value => Err(ExpectedError("Number".to_string(), format!("{}", value)))
}
}
@ -2096,7 +2096,7 @@ impl ::Decoder for Decoder {
_ => ()
}
}
Err(ExpectedError("single character string".to_string(), format!("{:?}", s)))
Err(ExpectedError("single character string".to_string(), format!("{}", s)))
}
fn read_str(&mut self) -> DecodeResult<string::String> {
@ -2119,7 +2119,7 @@ impl ::Decoder for Decoder {
let n = match o.remove(&"variant".to_string()) {
Some(Json::String(s)) => s,
Some(val) => {
return Err(ExpectedError("String".to_string(), format!("{:?}", val)))
return Err(ExpectedError("String".to_string(), format!("{}", val)))
}
None => {
return Err(MissingFieldError("variant".to_string()))
@ -2132,7 +2132,7 @@ impl ::Decoder for Decoder {
}
},
Some(val) => {
return Err(ExpectedError("Array".to_string(), format!("{:?}", val)))
return Err(ExpectedError("Array".to_string(), format!("{}", val)))
}
None => {
return Err(MissingFieldError("fields".to_string()))
@ -2141,7 +2141,7 @@ impl ::Decoder for Decoder {
n
}
json => {
return Err(ExpectedError("String or Object".to_string(), format!("{:?}", json)))
return Err(ExpectedError("String or Object".to_string(), format!("{}", json)))
}
};
let idx = match names.iter().position(|n| *n == name.index(&FullRange)) {
@ -2911,7 +2911,8 @@ mod tests {
assert_eq!(v, i64::MAX);
let res: DecodeResult<i64> = super::decode("765.25252");
assert_eq!(res, Err(ExpectedError("Integer".to_string(), "765.25252".to_string())));
assert_eq!(res, Err(ExpectedError("Integer".to_string(),
"765.25252".to_string())));
}
#[test]

View File

@ -71,7 +71,7 @@
/// let mut flags = FLAG_A | FLAG_B;
/// flags.clear();
/// assert!(flags.is_empty());
/// assert_eq!(format!("{}", flags).as_slice(), "hi!");
/// assert_eq!(format!("{:?}", flags).as_slice(), "hi!");
/// }
/// ```
///

View File

@ -1894,7 +1894,8 @@ mod test_map {
let map_str = format!("{:?}", map);
assert!(map_str == "HashMap {1i: 2i, 3i: 4i}" || map_str == "{3i: 4i, 1i: 2i}");
assert!(map_str == "HashMap {1i: 2i, 3i: 4i}" ||
map_str == "HashMap {3i: 4i, 1i: 2i}");
assert_eq!(format!("{:?}", empty), "HashMap {}");
}

View File

@ -1130,7 +1130,7 @@ mod test_set {
let set_str = format!("{:?}", set);
assert!(set_str == "HashSet {1i, 2i}" || set_str == "{2i, 1i}");
assert!(set_str == "HashSet {1i, 2i}" || set_str == "HashSet {2i, 1i}");
assert_eq!(format!("{:?}", empty), "HashSet {}");
}

View File

@ -230,9 +230,9 @@
//! Some examples of the output from both traits:
//!
//! ```
//! assert_eq(format!("{} {:?}", 3i32, 4i32), "3 4i32");
//! assert_eq(format!("{} {:?}", 'a', 'b'), "a 'b'");
//! assert_eq(format!("{} {:?}", "foo\n", "bar\n"), "foo\n \"bar\\n\"");
//! assert_eq!(format!("{} {:?}", 3i32, 4i32), "3 4i32");
//! assert_eq!(format!("{} {:?}", 'a', 'b'), "a 'b'");
//! assert_eq!(format!("{} {:?}", "foo\n", "bar\n"), "foo\n \"bar\\n\"");
//! ```
//!
//! ### Related macros

View File

@ -107,7 +107,7 @@ impl File {
///
/// let file = match File::open_mode(&p, Open, ReadWrite) {
/// Ok(f) => f,
/// Err(e) => panic!("file error: {:?}", e),
/// Err(e) => panic!("file error: {}", e),
/// };
/// // do some stuff with that file
///
@ -156,7 +156,7 @@ impl File {
})
}
}).update_err("couldn't open path as file", |e| {
format!("{:?}; path={:?}; mode={}; access={}", e, path.display(),
format!("{}; path={:?}; mode={}; access={}", e, path.display(),
mode_string(mode), access_string(access))
})
}
@ -211,7 +211,7 @@ impl File {
pub fn fsync(&mut self) -> IoResult<()> {
self.fd.fsync()
.update_err("couldn't fsync file",
|e| format!("{:?}; path={:?}", e, self.path.display()))
|e| format!("{}; path={:?}", e, self.path.display()))
}
/// This function is similar to `fsync`, except that it may not synchronize
@ -221,7 +221,7 @@ impl File {
pub fn datasync(&mut self) -> IoResult<()> {
self.fd.datasync()
.update_err("couldn't datasync file",
|e| format!("{:?}; path={:?}", e, self.path.display()))
|e| format!("{}; path={:?}", e, self.path.display()))
}
/// Either truncates or extends the underlying file, updating the size of
@ -235,7 +235,7 @@ impl File {
pub fn truncate(&mut self, size: i64) -> IoResult<()> {
self.fd.truncate(size)
.update_err("couldn't truncate file", |e|
format!("{:?}; path={:?}; size={:?}", e, self.path.display(), size))
format!("{}; path={:?}; size={:?}", e, self.path.display(), size))
}
/// Returns true if the stream has reached the end of the file.
@ -255,7 +255,7 @@ impl File {
pub fn stat(&self) -> IoResult<FileStat> {
self.fd.fstat()
.update_err("couldn't fstat file", |e|
format!("{:?}; path={:?}", e, self.path.display()))
format!("{}; path={:?}", e, self.path.display()))
}
}
@ -283,7 +283,7 @@ impl File {
pub fn unlink(path: &Path) -> IoResult<()> {
fs_imp::unlink(path)
.update_err("couldn't unlink path", |e|
format!("{:?}; path={:?}", e, path.display()))
format!("{}; path={:?}", e, path.display()))
}
/// Given a path, query the file system to get information about a file,
@ -310,7 +310,7 @@ pub fn unlink(path: &Path) -> IoResult<()> {
pub fn stat(path: &Path) -> IoResult<FileStat> {
fs_imp::stat(path)
.update_err("couldn't stat path", |e|
format!("{:?}; path={:?}", e, path.display()))
format!("{}; path={:?}", e, path.display()))
}
/// Perform the same operation as the `stat` function, except that this
@ -324,7 +324,7 @@ pub fn stat(path: &Path) -> IoResult<FileStat> {
pub fn lstat(path: &Path) -> IoResult<FileStat> {
fs_imp::lstat(path)
.update_err("couldn't lstat path", |e|
format!("{:?}; path={:?}", e, path.display()))
format!("{}; path={:?}", e, path.display()))
}
/// Rename a file or directory to a new name.
@ -346,7 +346,7 @@ pub fn lstat(path: &Path) -> IoResult<FileStat> {
pub fn rename(from: &Path, to: &Path) -> IoResult<()> {
fs_imp::rename(from, to)
.update_err("couldn't rename path", |e|
format!("{:?}; from={:?}; to={:?}", e, from.display(), to.display()))
format!("{}; from={:?}; to={:?}", e, from.display(), to.display()))
}
/// Copies the contents of one file to another. This function will also
@ -380,7 +380,7 @@ pub fn rename(from: &Path, to: &Path) -> IoResult<()> {
pub fn copy(from: &Path, to: &Path) -> IoResult<()> {
fn update_err<T>(result: IoResult<T>, from: &Path, to: &Path) -> IoResult<T> {
result.update_err("couldn't copy path", |e| {
format!("{:?}; from={:?}; to={:?}", e, from.display(), to.display())
format!("{}; from={:?}; to={:?}", e, from.display(), to.display())
})
}
@ -424,14 +424,14 @@ pub fn copy(from: &Path, to: &Path) -> IoResult<()> {
pub fn chmod(path: &Path, mode: io::FilePermission) -> IoResult<()> {
fs_imp::chmod(path, mode.bits() as uint)
.update_err("couldn't chmod path", |e|
format!("{:?}; path={:?}; mode={:?}", e, path.display(), mode))
format!("{}; path={:?}; mode={:?}", e, path.display(), mode))
}
/// Change the user and group owners of a file at the specified path.
pub fn chown(path: &Path, uid: int, gid: int) -> IoResult<()> {
fs_imp::chown(path, uid, gid)
.update_err("couldn't chown path", |e|
format!("{:?}; path={:?}; uid={:?}; gid={:?}", e, path.display(), uid, gid))
format!("{}; path={:?}; uid={}; gid={}", e, path.display(), uid, gid))
}
/// Creates a new hard link on the filesystem. The `dst` path will be a
@ -440,7 +440,7 @@ pub fn chown(path: &Path, uid: int, gid: int) -> IoResult<()> {
pub fn link(src: &Path, dst: &Path) -> IoResult<()> {
fs_imp::link(src, dst)
.update_err("couldn't link path", |e|
format!("{:?}; src={:?}; dest={:?}", e, src.display(), dst.display()))
format!("{}; src={:?}; dest={:?}", e, src.display(), dst.display()))
}
/// Creates a new symbolic link on the filesystem. The `dst` path will be a
@ -448,7 +448,7 @@ pub fn link(src: &Path, dst: &Path) -> IoResult<()> {
pub fn symlink(src: &Path, dst: &Path) -> IoResult<()> {
fs_imp::symlink(src, dst)
.update_err("couldn't symlink path", |e|
format!("{:?}; src={:?}; dest={:?}", e, src.display(), dst.display()))
format!("{}; src={:?}; dest={:?}", e, src.display(), dst.display()))
}
/// Reads a symlink, returning the file that the symlink points to.
@ -460,7 +460,7 @@ pub fn symlink(src: &Path, dst: &Path) -> IoResult<()> {
pub fn readlink(path: &Path) -> IoResult<Path> {
fs_imp::readlink(path)
.update_err("couldn't resolve symlink for path", |e|
format!("{:?}; path={:?}", e, path.display()))
format!("{}; path={:?}", e, path.display()))
}
/// Create a new, empty directory at the provided path
@ -483,7 +483,7 @@ pub fn readlink(path: &Path) -> IoResult<Path> {
pub fn mkdir(path: &Path, mode: FilePermission) -> IoResult<()> {
fs_imp::mkdir(path, mode.bits() as uint)
.update_err("couldn't create directory", |e|
format!("{:?}; path={:?}; mode={:?}", e, path.display(), mode))
format!("{}; path={:?}; mode={:?}", e, path.display(), mode))
}
/// Remove an existing, empty directory
@ -505,7 +505,7 @@ pub fn mkdir(path: &Path, mode: FilePermission) -> IoResult<()> {
pub fn rmdir(path: &Path) -> IoResult<()> {
fs_imp::rmdir(path)
.update_err("couldn't remove directory", |e|
format!("{:?}; path={:?}", e, path.display()))
format!("{}; path={:?}", e, path.display()))
}
/// Retrieve a vector containing all entries within a provided directory
@ -545,7 +545,7 @@ pub fn rmdir(path: &Path) -> IoResult<()> {
pub fn readdir(path: &Path) -> IoResult<Vec<Path>> {
fs_imp::readdir(path)
.update_err("couldn't read directory",
|e| format!("{:?}; path={:?}", e, path.display()))
|e| format!("{}; path={:?}", e, path.display()))
}
/// Returns an iterator that will recursively walk the directory structure
@ -555,7 +555,7 @@ pub fn readdir(path: &Path) -> IoResult<Vec<Path>> {
pub fn walk_dir(path: &Path) -> IoResult<Directories> {
Ok(Directories {
stack: try!(readdir(path).update_err("couldn't walk directory",
|e| format!("{:?}; path={:?}", e, path.display())))
|e| format!("{}; path={:?}", e, path.display())))
})
}
@ -605,7 +605,7 @@ pub fn mkdir_recursive(path: &Path, mode: FilePermission) -> IoResult<()> {
let result = mkdir(&curpath, mode)
.update_err("couldn't recursively mkdir",
|e| format!("{:?}; path={:?}", e, path.display()));
|e| format!("{}; path={:?}", e, path.display()));
match result {
Err(mkdir_err) => {
@ -632,7 +632,7 @@ pub fn rmdir_recursive(path: &Path) -> IoResult<()> {
rm_stack.push(path.clone());
fn rmdir_failed(err: &IoError, path: &Path) -> String {
format!("rmdir_recursive failed; path={:?}; cause={:?}",
format!("rmdir_recursive failed; path={:?}; cause={}",
path.display(), err)
}
@ -692,14 +692,14 @@ pub fn rmdir_recursive(path: &Path) -> IoResult<()> {
pub fn change_file_times(path: &Path, atime: u64, mtime: u64) -> IoResult<()> {
fs_imp::utime(path, atime, mtime)
.update_err("couldn't change_file_times", |e|
format!("{:?}; path={:?}", e, path.display()))
format!("{}; path={:?}", e, path.display()))
}
impl Reader for File {
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
fn update_err<T>(result: IoResult<T>, file: &File) -> IoResult<T> {
result.update_err("couldn't read file",
|e| format!("{:?}; path={:?}",
|e| format!("{}; path={:?}",
e, file.path.display()))
}
@ -722,7 +722,7 @@ impl Writer for File {
fn write(&mut self, buf: &[u8]) -> IoResult<()> {
self.fd.write(buf)
.update_err("couldn't write to file",
|e| format!("{:?}; path={:?}", e, self.path.display()))
|e| format!("{}; path={:?}", e, self.path.display()))
}
}
@ -730,7 +730,7 @@ impl Seek for File {
fn tell(&self) -> IoResult<u64> {
self.fd.tell()
.update_err("couldn't retrieve file cursor (`tell`)",
|e| format!("{:?}; path={:?}", e, self.path.display()))
|e| format!("{}; path={:?}", e, self.path.display()))
}
fn seek(&mut self, pos: i64, style: SeekStyle) -> IoResult<()> {
@ -743,7 +743,7 @@ impl Seek for File {
Err(e) => Err(e),
};
err.update_err("couldn't seek in file",
|e| format!("{:?}; path={:?}", e, self.path.display()))
|e| format!("{}; path={:?}", e, self.path.display()))
}
}
@ -840,7 +840,7 @@ mod test {
match $e {
Ok(_) => panic!("Unexpected success. Should've been: {:?}", $s),
Err(ref err) => assert!(err.to_string().contains($s.as_slice()),
format!("`{:?}` did not contain `{:?}`", err, $s))
format!("`{}` did not contain `{}`", err, $s))
}
) }

View File

@ -662,7 +662,7 @@ mod test {
Ok(..) => panic!(),
Err(ref e) => {
assert!(e.kind == NotConnected || e.kind == EndOfFile,
"unknown kind: {}", e.kind);
"unknown kind: {:?}", e.kind);
}
}
}
@ -686,7 +686,7 @@ mod test {
Ok(..) => panic!(),
Err(ref e) => {
assert!(e.kind == NotConnected || e.kind == EndOfFile,
"unknown kind: {}", e.kind);
"unknown kind: {:?}", e.kind);
}
}
}
@ -999,7 +999,7 @@ mod test {
Ok(..) => panic!(),
Err(e) => {
assert!(e.kind == ConnectionRefused || e.kind == OtherIoError,
"unknown error: {} {}", e, e.kind);
"unknown error: {} {:?}", e, e.kind);
}
}
}

View File

@ -105,7 +105,7 @@
#![allow(unknown_features)]
#![feature(linkage, thread_local, asm)]
#![feature(phase, lang_items, unsafe_destructor)]
#![feature(lang_items, unsafe_destructor)]
#![feature(slicing_syntax, unboxed_closures)]
#![feature(old_impl_check)]
#![cfg_attr(stage0, allow(unused_attributes))]

View File

@ -371,7 +371,7 @@ pub mod builtin {
///
/// ```
#[macro_export]
macro_rules! format_args { ($fmt:expr $($args:tt)*) => ({
macro_rules! format_args { ($fmt:expr, $($args:tt)*) => ({
/* compiler built-in */
}) }
@ -407,7 +407,7 @@ pub mod builtin {
///
/// ```rust
/// let key: Option<&'static str> = option_env!("SECRET_KEY");
/// println!("the secret key might be: {}", key);
/// println!("the secret key might be: {:?}", key);
/// ```
#[macro_export]
macro_rules! option_env { ($name:expr) => ({ /* compiler built-in */ }) }

View File

@ -1622,7 +1622,7 @@ mod tests {
os::MapOption::MapWritable
]) {
Ok(chunk) => chunk,
Err(msg) => panic!("{}", msg)
Err(msg) => panic!("{:?}", msg)
};
assert!(chunk.len >= 16);

View File

@ -1150,7 +1150,7 @@ mod tests {
let comps = path.components().collect::<Vec<&[u8]>>();
let exp: &[&str] = &$exp;
let exps = exp.iter().map(|x| x.as_bytes()).collect::<Vec<&[u8]>>();
assert_eq!(comps, exprs);
assert_eq!(comps, exps);
let comps = path.components().rev().collect::<Vec<&[u8]>>();
let exps = exps.into_iter().rev().collect::<Vec<&[u8]>>();
assert_eq!(comps, exps);

View File

@ -1740,8 +1740,8 @@ mod tests {
let path = Path::new(pstr);
let arg = $arg;
let res = path.$op(arg);
let exp = $res;
assert_eq!(Path::new($path).$op($arg), $res);
let exp = Path::new($res);
assert_eq!(res, exp);
}
)
}
@ -1920,8 +1920,7 @@ mod tests {
{
let path = Path::new($path);
let (abs, vol, cwd, rel) = ($abs, $vol, $cwd, $rel);
let b = path.is_absolute();
assert_eq!(path.is_absolute(), asb);
assert_eq!(path.is_absolute(), abs);
assert_eq!(is_vol_relative(&path), vol);
assert_eq!(is_cwd_relative(&path), cwd);
assert_eq!(path.is_relative(), rel);
@ -1955,7 +1954,7 @@ mod tests {
let dest = Path::new($dest);
let exp = $exp;
let res = path.is_ancestor_of(&dest);
assert_eq!(Path::new($path).is_ancestor_of(Path::new($dest)), $exp);
assert_eq!(res, exp);
}
)
}
@ -2084,7 +2083,7 @@ mod tests {
macro_rules! t {
(s: $path:expr, $other:expr, $exp:expr) => (
{
assert_eq!(Path::new($path).path_relative_from(Path::new($other))
assert_eq!(Path::new($path).path_relative_from(&Path::new($other))
.as_ref().and_then(|x| x.as_str()), $exp);
}
)

View File

@ -71,7 +71,7 @@
//! use std::rand;
//!
//! let tuple = rand::random::<(f64, char)>();
//! println!("{}", tuple)
//! println!("{:?}", tuple)
//! ```
//!
//! ## Monte Carlo estimation of π

View File

@ -481,7 +481,7 @@ impl<T> UnsafeFlavor<T> for Receiver<T> {
/// // Do some useful work for awhile
///
/// // Let's see what that answer was
/// println!("{}", rx.recv().unwrap());
/// println!("{:?}", rx.recv().unwrap());
/// ```
#[stable]
pub fn channel<T: Send>() -> (Sender<T>, Receiver<T>) {

View File

@ -196,7 +196,7 @@ pub mod compat {
/// they are used to be passed to the real function if available.
macro_rules! compat_fn {
($module:ident::$symbol:ident($($argname:ident: $argtype:ty),*)
-> $rettype:ty $fallback:block) => (
-> $rettype:ty { $fallback:expr }) => (
#[inline(always)]
pub unsafe fn $symbol($($argname: $argtype),*) -> $rettype {
static mut ptr: extern "system" fn($($argname: $argtype),*) -> $rettype = thunk;
@ -211,14 +211,11 @@ pub mod compat {
}
}
extern "system" fn fallback($($argname: $argtype),*) -> $rettype $fallback
extern "system" fn fallback($($argname: $argtype),*)
-> $rettype { $fallback }
::intrinsics::atomic_load_relaxed(&ptr)($($argname),*)
}
);
($module:ident::$symbol:ident($($argname:ident: $argtype:ty),*) $fallback:block) => (
compat_fn!($module::$symbol($($argname: $argtype),*) -> () $fallback)
)
}
@ -236,20 +233,22 @@ pub mod compat {
fn SetLastError(dwErrCode: DWORD);
}
compat_fn! { kernel32::CreateSymbolicLinkW(_lpSymlinkFileName: LPCWSTR,
_lpTargetFileName: LPCWSTR,
_dwFlags: DWORD) -> BOOLEAN {
unsafe { SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); }
0
} }
compat_fn! {
kernel32::CreateSymbolicLinkW(_lpSymlinkFileName: LPCWSTR,
_lpTargetFileName: LPCWSTR,
_dwFlags: DWORD) -> BOOLEAN {
unsafe { SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0 }
}
}
compat_fn! { kernel32::GetFinalPathNameByHandleW(_hFile: HANDLE,
_lpszFilePath: LPCWSTR,
_cchFilePath: DWORD,
_dwFlags: DWORD) -> DWORD {
unsafe { SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); }
0
} }
compat_fn! {
kernel32::GetFinalPathNameByHandleW(_hFile: HANDLE,
_lpszFilePath: LPCWSTR,
_cchFilePath: DWORD,
_dwFlags: DWORD) -> DWORD {
unsafe { SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0 }
}
}
}
}

View File

@ -62,7 +62,7 @@ pub unsafe fn create(stack: uint, p: Thunk) -> rust_thread {
if ret as uint == 0 {
// be sure to not leak the closure
let _p: Box<Thunk> = mem::transmute(arg);
panic!("failed to spawn native thread: {}", ret);
panic!("failed to spawn native thread: {:?}", ret);
}
return ret;
}

View File

@ -103,26 +103,26 @@ impl Ident {
//NOTE(stage0): remove after snapshot
impl fmt::Show for Ident {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
write!(f, "{}#{}", self.name, self.ctxt)
}
}
impl fmt::String for Ident {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}#{}", self.name, self.ctxt)
fmt::String::fmt(&self.name, f)
}
}
impl fmt::Show for Name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
let Name(nm) = *self;
write!(f, "{:?}({})", token::get_name(*self).get(), nm)
}
}
impl fmt::String for Name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let Name(nm) = *self;
write!(f, "\"{}\"({})", token::get_name(*self).get(), nm)
fmt::String::fmt(token::get_name(*self).get(), f)
}
}

View File

@ -836,20 +836,20 @@ mod test {
ast::TtToken(_, token::Ident(name, token::Plain))]
if first_delimed.delim == token::Paren
&& name.as_str() == "a" => {},
_ => panic!("value 3: {}", **first_delimed),
_ => panic!("value 3: {:?}", **first_delimed),
}
match second_delimed.tts.index(&FullRange) {
[ast::TtToken(_, token::Dollar),
ast::TtToken(_, token::Ident(name, token::Plain))]
if second_delimed.delim == token::Paren
&& name.as_str() == "a" => {},
_ => panic!("value 4: {}", **second_delimed),
_ => panic!("value 4: {:?}", **second_delimed),
}
},
_ => panic!("value 2: {}", **macro_delimed),
_ => panic!("value 2: {:?}", **macro_delimed),
}
},
_ => panic!("value: {}",tts),
_ => panic!("value: {:?}",tts),
}
}

View File

@ -91,11 +91,7 @@ pub mod stats;
// colons. This way if some test runner wants to arrange the tests
// hierarchically it may.
<<<<<<< HEAD
#[derive(Clone, PartialEq, Eq, Hash)]
=======
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
>>>>>>> core: split into fmt::Show and fmt::String
#[derive(Clone, PartialEq, Eq, Hash, Show)]
pub enum TestName {
StaticTestName(&'static str),
DynTestName(String)

View File

@ -49,7 +49,7 @@ fn print_complements() {
let all = [Blue, Red, Yellow];
for aa in all.iter() {
for bb in all.iter() {
println!("{} + {} -> {}", *aa, *bb, transform(*aa, *bb));
println!("{:?} + {:?} -> {:?}", *aa, *bb, transform(*aa, *bb));
}
}
}
@ -84,7 +84,7 @@ fn show_color_list(set: Vec<Color>) -> String {
let mut out = String::new();
for col in set.iter() {
out.push(' ');
out.push_str(col.to_string().as_slice());
out.push_str(format!("{:?}", col).as_slice());
}
out
}
@ -170,7 +170,7 @@ fn creature(
}
}
// log creatures met and evil clones of self
let report = format!("{}{}", creatures_met, Number(evil_clones_met));
let report = format!("{}{:?}", creatures_met, Number(evil_clones_met));
to_rendezvous_log.send(report).unwrap();
}
@ -225,7 +225,7 @@ fn rendezvous(nn: uint, set: Vec<Color>) {
}
// print the total number of creatures met
println!("{}\n", Number(creatures_met));
println!("{:?}\n", Number(creatures_met));
}
fn main() {

View File

@ -241,7 +241,7 @@ fn parallel<'a, I, T, F>(mut iter: I, f: F)
// boundary.
let f = Racy(&f as *const F as *const uint);
let raw = Racy(chunk.repr());
Thread::spawn(move|| {
Thread::scoped(move|| {
let f = f.0 as *const F;
unsafe { (*f)(mem::transmute(raw.0)) }
})

View File

@ -128,7 +128,7 @@ fn parallel<T, F>(v: &mut [T], f: F)
// boundary.
let f = Racy(&f as *const _ as *const uint);
let raw = Racy(chunk.repr());
Thread::spawn(move|| {
Thread::scoped(move|| {
let f = f.0 as *const F;
unsafe { (*f)(i * size, mem::transmute(raw.0)) }
})

View File

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

View File

@ -9,7 +9,7 @@
// except according to those terms.
fn equal<T>(_: &T, _: &T) -> bool where int : Eq {
true //~^ ERROR cannot bound type `int`, where clause bounds may only be attached
true //~^ ERROR cannot bound type `isize`, where clause bounds may only be attached
}
// This should be fine involves a type parameter.
@ -17,22 +17,24 @@ fn test<T: Eq>() -> bool where Option<T> : Eq {}
// This should be rejected as well.
fn test2() -> bool where Option<int> : Eq {}
//~^ ERROR cannot bound type `core::option::Option<isize>`, where clause bounds
#[derive(PartialEq)]
//~^ ERROR cannot bound type `int`, where clause bounds
//~^ ERROR cannot bound type `isize`, where clause bounds
enum Foo<T> where int : Eq { MkFoo }
//~^ ERROR cannot bound type `isize`, where clause bounds
fn test3<T: Eq>() -> bool where Option<Foo<T>> : Eq {}
fn test4() -> bool where Option<Foo<int>> : Eq {}
//~^ ERROR cannot bound type `core::option::Option<Foo<int>>`, where clause bounds
//~^ ERROR cannot bound type `core::option::Option<Foo<isize>>`, where clause bounds
trait Baz<T> where int : Eq {
fn baz() where String : Eq;
}
impl Baz<int> for int where int : Eq {
//~^ ERROR cannot bound type `int`, where clause bounds
//~^ ERROR cannot bound type `isize`, where clause bounds
fn baz() where String : Eq {}
}

View File

@ -32,14 +32,14 @@
// lldb-command:run
// lldb-command:print int_int
// lldb-check:[...]$0 = AGenericStruct<int, int> { key: 0, value: 1 }
// lldb-check:[...]$0 = AGenericStruct<isize, isize> { key: 0, value: 1 }
// lldb-command:print int_float
// lldb-check:[...]$1 = AGenericStruct<int, f64> { key: 2, value: 3.5 }
// lldb-check:[...]$1 = AGenericStruct<isize, f64> { key: 2, value: 3.5 }
// lldb-command:print float_int
// lldb-check:[...]$2 = AGenericStruct<f64, int> { key: 4.5, value: 5 }
// lldb-check:[...]$2 = AGenericStruct<f64, isize> { key: 4.5, value: 5 }
// lldb-command:print float_int_float
// lldb-check:[...]$3 = AGenericStruct<f64, generic-struct::AGenericStruct<int, f64>> { key: 6.5, value: AGenericStruct<int, f64> { key: 7, value: 8.5 } }
// lldb-check:[...]$3 = AGenericStruct<f64, generic-struct::AGenericStruct<isize, f64>> { key: 6.5, value: AGenericStruct<isize, f64> { key: 7, value: 8.5 } }
#![omit_gdb_pretty_printer_section]

View File

@ -30,12 +30,13 @@ impl Index<uint> for T {
type Output = Show + 'static;
fn index<'a>(&'a self, idx: &uint) -> &'a (Show + 'static) {
static x: uint = 42;
&x
static X: uint = 42;
&X as &(Show + 'static)
}
}
fn main() {
assert_eq!(&S[0], "hello");
assert_eq!(format!("{:?}", &T[0]), "42u");
&T[0];
// let x = &x as &Show;
}

View File

@ -10,6 +10,7 @@
// A test of the macro system. Can we do HTML literals?
// ignore-test FIXME #20673
/*

View File

@ -82,8 +82,9 @@ pub fn main() {
t!(format!("{}", 5i + 5i), "10");
t!(format!("{:#4}", C), "☃123");
let a: &fmt::Show = &1i;
t!(format!("{:?}", a), "1i");
// FIXME(#20676)
// let a: &fmt::Show = &1i;
// t!(format!("{:?}", a), "1i");
// Formatting strings and their arguments

View File

@ -37,11 +37,13 @@ fn main() {
let args = os::args();
let args = args.as_slice();
if args.len() > 1 && args[1].as_slice() == "recurse" {
let _t = Thread::spawn(recurse);
let _t = Thread::scoped(recurse);
} else {
let recurse = Command::new(args[0].as_slice()).arg("recurse").output().unwrap();
assert!(!recurse.status.success());
let error = String::from_utf8_lossy(recurse.error.as_slice());
println!("wut");
println!("`{}`", error);
assert!(error.as_slice().contains("has overflowed its stack"));
}
}

View File

@ -9,11 +9,11 @@
// except according to those terms.
pub fn main() {
assert_eq!((vec!(0i, 1)).to_string(), "0, 1".to_string());
assert_eq!((vec!(0i, 1)).to_string(), "[0, 1]".to_string());
let foo = vec!(3i, 4);
let bar: &[int] = &[4, 5];
assert_eq!(foo.to_string(), "3, 4".to_string());
assert_eq!(bar.to_string(), "4, 5".to_string());
assert_eq!(foo.to_string(), "[3, 4]".to_string());
assert_eq!(bar.to_string(), "[4, 5]".to_string());
}