std: Rename Show/String to Debug/Display
This commit is an implementation of [RFC 565][rfc] which is a stabilization of the `std::fmt` module and the implementations of various formatting traits. Specifically, the following changes were performed: [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0565-show-string-guidelines.md * The `Show` trait is now deprecated, it was renamed to `Debug` * The `String` trait is now deprecated, it was renamed to `Display` * Many `Debug` and `Display` implementations were audited in accordance with the RFC and audited implementations now have the `#[stable]` attribute * Integers and floats no longer print a suffix * Smart pointers no longer print details that they are a smart pointer * Paths with `Debug` are now quoted and escape characters * The `unwrap` methods on `Result` now require `Display` instead of `Debug` * The `Error` trait no longer has a `detail` method and now requires that `Display` must be implemented. With the loss of `String`, this has moved into libcore. * `impl<E: Error> FromError<E> for Box<Error>` now exists * `derive(Show)` has been renamed to `derive(Debug)`. This is not currently warned about due to warnings being emitted on stage1+ While backwards compatibility is attempted to be maintained with a blanket implementation of `Display` for the old `String` trait (and the same for `Show`/`Debug`) this is still a breaking change due to primitives no longer implementing `String` as well as modifications such as `unwrap` and the `Error` trait. Most code is fairly straightforward to update with a rename or tweaks of method calls. [breaking-change] Closes #21436
This commit is contained in:
parent
29bd9a06ef
commit
3cb9fa26ef
136 changed files with 763 additions and 706 deletions
|
|
@ -12,7 +12,7 @@
|
|||
// can't be used as rvalues
|
||||
|
||||
use std::ops::Index;
|
||||
use std::fmt::Show;
|
||||
use std::fmt::Debug;
|
||||
|
||||
struct S;
|
||||
|
||||
|
|
@ -31,9 +31,9 @@ struct T;
|
|||
impl Copy for T {}
|
||||
|
||||
impl Index<usize> for T {
|
||||
type Output = Show + 'static;
|
||||
type Output = Debug + 'static;
|
||||
|
||||
fn index<'a>(&'a self, idx: &usize) -> &'a (Show + 'static) {
|
||||
fn index<'a>(&'a self, idx: &usize) -> &'a (Debug + 'static) {
|
||||
static x: usize = 42;
|
||||
&x
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::fmt::Show;
|
||||
use std::fmt::Debug;
|
||||
|
||||
trait Str {}
|
||||
|
||||
trait Something {
|
||||
fn yay<T: Show>(_: Option<Self>, thing: &[T]);
|
||||
fn yay<T: Debug>(_: Option<Self>, thing: &[T]);
|
||||
}
|
||||
|
||||
struct X { data: u32 }
|
||||
|
|
|
|||
|
|
@ -12,19 +12,19 @@
|
|||
|
||||
use std::{fmt, ops};
|
||||
|
||||
struct Shower<T> {
|
||||
struct Debuger<T> {
|
||||
x: T
|
||||
}
|
||||
|
||||
impl<T: fmt::Show> ops::Fn<(), ()> for Shower<T> {
|
||||
impl<T: fmt::Debug> ops::Fn<(), ()> for Debuger<T> {
|
||||
fn call(&self, _args: ()) {
|
||||
//~^ ERROR `call` has an incompatible type for trait: expected "rust-call" fn, found "Rust" fn
|
||||
println!("{:?}", self.x);
|
||||
}
|
||||
}
|
||||
|
||||
fn make_shower<T>(x: T) -> Shower<T> {
|
||||
Shower { x: x }
|
||||
fn make_shower<T>(x: T) -> Debuger<T> {
|
||||
Debuger { x: x }
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn send<T:Send + std::fmt::Show>(ch: _chan<T>, data: T) {
|
||||
fn send<T:Send + std::fmt::Debug>(ch: _chan<T>, data: T) {
|
||||
println!("{:?}", ch);
|
||||
println!("{:?}", data);
|
||||
panic!();
|
||||
}
|
||||
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
struct _chan<T>(isize);
|
||||
|
||||
// Tests that "log(debug, message);" is flagged as using
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern:assertion failed: `(left == right) && (right == left)` (left: `14i`, right: `15i`)
|
||||
// error-pattern:assertion failed: `(left == right) && (right == left)` (left: `14`, right: `15`)
|
||||
|
||||
fn main() {
|
||||
assert_eq!(14i,15i);
|
||||
|
|
|
|||
|
|
@ -10,44 +10,44 @@
|
|||
|
||||
// compile-flags:--cfg set1 --cfg set2
|
||||
#![allow(dead_code)]
|
||||
use std::fmt::Show;
|
||||
use std::fmt::Debug;
|
||||
|
||||
struct NotShowable;
|
||||
struct NotDebugable;
|
||||
|
||||
#[cfg_attr(set1, derive(Show))]
|
||||
#[cfg_attr(set1, derive(Debug))]
|
||||
struct Set1;
|
||||
|
||||
#[cfg_attr(notset, derive(Show))]
|
||||
struct Notset(NotShowable);
|
||||
#[cfg_attr(notset, derive(Debug))]
|
||||
struct Notset(NotDebugable);
|
||||
|
||||
#[cfg_attr(not(notset), derive(Show))]
|
||||
#[cfg_attr(not(notset), derive(Debug))]
|
||||
struct NotNotset;
|
||||
|
||||
#[cfg_attr(not(set1), derive(Show))]
|
||||
struct NotSet1(NotShowable);
|
||||
#[cfg_attr(not(set1), derive(Debug))]
|
||||
struct NotSet1(NotDebugable);
|
||||
|
||||
#[cfg_attr(all(set1, set2), derive(Show))]
|
||||
#[cfg_attr(all(set1, set2), derive(Debug))]
|
||||
struct AllSet1Set2;
|
||||
|
||||
#[cfg_attr(all(set1, notset), derive(Show))]
|
||||
struct AllSet1Notset(NotShowable);
|
||||
#[cfg_attr(all(set1, notset), derive(Debug))]
|
||||
struct AllSet1Notset(NotDebugable);
|
||||
|
||||
#[cfg_attr(any(set1, notset), derive(Show))]
|
||||
#[cfg_attr(any(set1, notset), derive(Debug))]
|
||||
struct AnySet1Notset;
|
||||
|
||||
#[cfg_attr(any(notset, notset2), derive(Show))]
|
||||
struct AnyNotsetNotset2(NotShowable);
|
||||
#[cfg_attr(any(notset, notset2), derive(Debug))]
|
||||
struct AnyNotsetNotset2(NotDebugable);
|
||||
|
||||
#[cfg_attr(all(not(notset), any(set1, notset)), derive(Show))]
|
||||
#[cfg_attr(all(not(notset), any(set1, notset)), derive(Debug))]
|
||||
struct Complex;
|
||||
|
||||
#[cfg_attr(any(notset, not(any(set1, notset))), derive(Show))]
|
||||
struct ComplexNot(NotShowable);
|
||||
#[cfg_attr(any(notset, not(any(set1, notset))), derive(Debug))]
|
||||
struct ComplexNot(NotDebugable);
|
||||
|
||||
#[cfg_attr(any(target_endian = "little", target_endian = "big"), derive(Show))]
|
||||
#[cfg_attr(any(target_endian = "little", target_endian = "big"), derive(Debug))]
|
||||
struct KeyValue;
|
||||
|
||||
fn is_show<T: Show>() {}
|
||||
fn is_show<T: Debug>() {}
|
||||
|
||||
fn main() {
|
||||
is_show::<Set1>();
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
use std::fmt::Show;
|
||||
use std::fmt::Debug;
|
||||
|
||||
// Check that coercions apply at the pointer level and don't cause
|
||||
// rvalue expressions to be unsized. See #20169 for more information.
|
||||
|
|
@ -21,15 +21,15 @@ pub fn main() {
|
|||
let _: Box<[int]> = box if true { [1, 2, 3] } else { [1, 3, 4] };
|
||||
let _: Box<[int]> = box match true { true => [1, 2, 3], false => [1, 3, 4] };
|
||||
let _: Box<Fn(int) -> _> = box { |x| (x as u8) };
|
||||
let _: Box<Show> = box if true { false } else { true };
|
||||
let _: Box<Show> = box match true { true => 'a', false => 'b' };
|
||||
let _: Box<Debug> = box if true { false } else { true };
|
||||
let _: Box<Debug> = box match true { true => 'a', false => 'b' };
|
||||
|
||||
let _: &[int] = &{ [1, 2, 3] };
|
||||
let _: &[int] = &if true { [1, 2, 3] } else { [1, 3, 4] };
|
||||
let _: &[int] = &match true { true => [1, 2, 3], false => [1, 3, 4] };
|
||||
let _: &Fn(int) -> _ = &{ |x| (x as u8) };
|
||||
let _: &Show = &if true { false } else { true };
|
||||
let _: &Show = &match true { true => 'a', false => 'b' };
|
||||
let _: &Debug = &if true { false } else { true };
|
||||
let _: &Debug = &match true { true => 'a', false => 'b' };
|
||||
|
||||
let _: Box<[int]> = Box::new([1, 2, 3]);
|
||||
let _: Box<Fn(int) -> _> = Box::new(|x| (x as u8));
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::fmt::Show;
|
||||
use std::fmt::Debug;
|
||||
use std::default::Default;
|
||||
|
||||
trait MyTrait {
|
||||
|
|
@ -23,7 +23,7 @@ impl<T> MyTrait for T
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone,Show,PartialEq)]
|
||||
#[derive(Clone,Debug,PartialEq)]
|
||||
struct MyType {
|
||||
dummy: uint
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ impl MyTrait for MyType {
|
|||
}
|
||||
|
||||
fn test_eq<M>(m: M, n: M)
|
||||
where M : MyTrait + Show + PartialEq
|
||||
where M : MyTrait + Debug + PartialEq
|
||||
{
|
||||
assert_eq!(m.get(), n);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,39 +10,39 @@
|
|||
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
enum A {}
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
enum B { B1, B2, B3 }
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
enum C { C1(int), C2(B), C3(String) }
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
enum D { D1{ a: int } }
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
struct E;
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
struct F(int);
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
struct G(int, int);
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
struct H { a: int }
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
struct I { a: int, b: int }
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
struct J(Custom);
|
||||
|
||||
struct Custom;
|
||||
impl fmt::Show for Custom {
|
||||
impl fmt::Debug for Custom {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "yay")
|
||||
}
|
||||
}
|
||||
|
||||
trait ToShow {
|
||||
trait ToDebug {
|
||||
fn to_show(&self) -> String;
|
||||
}
|
||||
|
||||
impl<T: fmt::Show> ToShow for T {
|
||||
impl<T: fmt::Debug> ToDebug for T {
|
||||
fn to_show(&self) -> String {
|
||||
format!("{:?}", self)
|
||||
}
|
||||
|
|
@ -51,12 +51,12 @@ impl<T: fmt::Show> ToShow for T {
|
|||
pub fn main() {
|
||||
assert_eq!(B::B1.to_show(), "B1".to_string());
|
||||
assert_eq!(B::B2.to_show(), "B2".to_string());
|
||||
assert_eq!(C::C1(3).to_show(), "C1(3i)".to_string());
|
||||
assert_eq!(C::C1(3).to_show(), "C1(3)".to_string());
|
||||
assert_eq!(C::C2(B::B2).to_show(), "C2(B2)".to_string());
|
||||
assert_eq!(D::D1{ a: 2 }.to_show(), "D1 { a: 2i }".to_string());
|
||||
assert_eq!(D::D1{ a: 2 }.to_show(), "D1 { a: 2 }".to_string());
|
||||
assert_eq!(E.to_show(), "E".to_string());
|
||||
assert_eq!(F(3).to_show(), "F(3i)".to_string());
|
||||
assert_eq!(G(3, 4).to_show(), "G(3i, 4i)".to_string());
|
||||
assert_eq!(I{ a: 2, b: 4 }.to_show(), "I { a: 2i, b: 4i }".to_string());
|
||||
assert_eq!(F(3).to_show(), "F(3)".to_string());
|
||||
assert_eq!(G(3, 4).to_show(), "G(3, 4)".to_string());
|
||||
assert_eq!(I{ a: 2, b: 4 }.to_show(), "I { a: 2, b: 4 }".to_string());
|
||||
assert_eq!(J(Custom).to_show(), "J(yay)".to_string());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,16 +8,16 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
struct Unit;
|
||||
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
struct Tuple(int, uint);
|
||||
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
struct Struct { x: int, y: uint }
|
||||
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
enum Enum {
|
||||
Nullary,
|
||||
Variant(int, uint),
|
||||
|
|
@ -32,9 +32,9 @@ macro_rules! t {
|
|||
|
||||
pub fn main() {
|
||||
t!(Unit, "Unit");
|
||||
t!(Tuple(1, 2), "Tuple(1i, 2u)");
|
||||
t!(Struct { x: 1, y: 2 }, "Struct { x: 1i, y: 2u }");
|
||||
t!(Tuple(1, 2), "Tuple(1, 2)");
|
||||
t!(Struct { x: 1, y: 2 }, "Struct { x: 1, y: 2 }");
|
||||
t!(Enum::Nullary, "Nullary");
|
||||
t!(Enum::Variant(1, 2), "Variant(1i, 2u)");
|
||||
t!(Enum::StructVariant { x: 1, y: 2 }, "StructVariant { x: 1i, y: 2u }");
|
||||
t!(Enum::Variant(1, 2), "Variant(1, 2)");
|
||||
t!(Enum::StructVariant { x: 1, y: 2 }, "StructVariant { x: 1, y: 2 }");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
// work and don't ICE.
|
||||
|
||||
use std::ops::Index;
|
||||
use std::fmt::Show;
|
||||
use std::fmt::Debug;
|
||||
|
||||
struct S;
|
||||
|
||||
|
|
@ -27,16 +27,16 @@ impl Index<uint> for S {
|
|||
struct T;
|
||||
|
||||
impl Index<uint> for T {
|
||||
type Output = Show + 'static;
|
||||
type Output = Debug + 'static;
|
||||
|
||||
fn index<'a>(&'a self, idx: &uint) -> &'a (Show + 'static) {
|
||||
fn index<'a>(&'a self, idx: &uint) -> &'a (Debug + 'static) {
|
||||
static X: uint = 42;
|
||||
&X as &(Show + 'static)
|
||||
&X as &(Debug + 'static)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
assert_eq!(&S[0], "hello");
|
||||
&T[0];
|
||||
// let x = &x as &Show;
|
||||
// let x = &x as &Debug;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ impl fmt::UpperHex for B {
|
|||
f.write_str("adios")
|
||||
}
|
||||
}
|
||||
impl fmt::String for C {
|
||||
impl fmt::Display for C {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.pad_integral(true, "☃", "123")
|
||||
}
|
||||
|
|
@ -63,8 +63,8 @@ pub fn main() {
|
|||
t!(format!("{}", 10i), "10");
|
||||
t!(format!("{}", 10u), "10");
|
||||
t!(format!("{:?}", '☃'), "'\\u{2603}'");
|
||||
t!(format!("{:?}", 10i), "10i");
|
||||
t!(format!("{:?}", 10u), "10u");
|
||||
t!(format!("{:?}", 10i), "10");
|
||||
t!(format!("{:?}", 10u), "10");
|
||||
t!(format!("{:?}", "true"), "\"true\"");
|
||||
t!(format!("{:?}", "foo\nbar"), "\"foo\\nbar\"");
|
||||
t!(format!("{:o}", 10u), "12");
|
||||
|
|
@ -72,22 +72,22 @@ pub fn main() {
|
|||
t!(format!("{:X}", 10u), "A");
|
||||
t!(format!("{}", "foo"), "foo");
|
||||
t!(format!("{}", "foo".to_string()), "foo");
|
||||
t!(format!("{:p}", 0x1234 as *const int), "0x1234");
|
||||
t!(format!("{:p}", 0x1234 as *mut int), "0x1234");
|
||||
t!(format!("{:p}", 0x1234 as *const isize), "0x1234");
|
||||
t!(format!("{:p}", 0x1234 as *mut isize), "0x1234");
|
||||
t!(format!("{:x}", A), "aloha");
|
||||
t!(format!("{:X}", B), "adios");
|
||||
t!(format!("foo {} ☃☃☃☃☃☃", "bar"), "foo bar ☃☃☃☃☃☃");
|
||||
t!(format!("{1} {0}", 0i, 1i), "1 0");
|
||||
t!(format!("{foo} {bar}", foo=0i, bar=1i), "0 1");
|
||||
t!(format!("{foo} {1} {bar} {0}", 0i, 1i, foo=2i, bar=3i), "2 1 3 0");
|
||||
t!(format!("{foo} {bar}", foo=0i, bar=1is), "0 1");
|
||||
t!(format!("{foo} {1} {bar} {0}", 0is, 1is, foo=2is, bar=3is), "2 1 3 0");
|
||||
t!(format!("{} {0}", "a"), "a a");
|
||||
t!(format!("{foo_bar}", foo_bar=1i), "1");
|
||||
t!(format!("{}", 5i + 5i), "10");
|
||||
t!(format!("{:#4}", C), "☃123");
|
||||
|
||||
// FIXME(#20676)
|
||||
// let a: &fmt::Show = &1i;
|
||||
// t!(format!("{:?}", a), "1i");
|
||||
// let a: &fmt::Debug = &1i;
|
||||
// t!(format!("{:?}", a), "1");
|
||||
|
||||
|
||||
// Formatting strings and their arguments
|
||||
|
|
@ -154,7 +154,7 @@ pub fn main() {
|
|||
// make sure that format! doesn't cause spurious unused-unsafe warnings when
|
||||
// it's inside of an outer unsafe block
|
||||
unsafe {
|
||||
let a: int = ::std::mem::transmute(3u);
|
||||
let a: isize = ::std::mem::transmute(3u);
|
||||
format!("{}", a);
|
||||
}
|
||||
|
||||
|
|
@ -215,8 +215,8 @@ fn test_format_args() {
|
|||
fn test_order() {
|
||||
// Make sure format!() arguments are always evaluated in a left-to-right
|
||||
// ordering
|
||||
fn foo() -> int {
|
||||
static mut FOO: int = 0;
|
||||
fn foo() -> isize {
|
||||
static mut FOO: isize = 0;
|
||||
unsafe {
|
||||
FOO += 1;
|
||||
FOO
|
||||
|
|
|
|||
|
|
@ -15,6 +15,6 @@
|
|||
use std::fmt;
|
||||
|
||||
fn main() {
|
||||
let a: &fmt::Show = &1_i32;
|
||||
let a: &fmt::Debug = &1_i32;
|
||||
format!("{:?}", a);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,6 @@ pub fn main() {
|
|||
let mut table = HashMap::new();
|
||||
table.insert("one".to_string(), 1i);
|
||||
table.insert("two".to_string(), 2i);
|
||||
assert!(check_strs(format!("{:?}", table).as_slice(), "HashMap {\"one\": 1i, \"two\": 2i}") ||
|
||||
check_strs(format!("{:?}", table).as_slice(), "HashMap {\"two\": 2i, \"one\": 1i}"));
|
||||
assert!(check_strs(format!("{:?}", table).as_slice(), "HashMap {\"one\": 1, \"two\": 2}") ||
|
||||
check_strs(format!("{:?}", table).as_slice(), "HashMap {\"two\": 2, \"one\": 1}"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,28 +11,28 @@
|
|||
#![feature(unsafe_destructor)]
|
||||
|
||||
trait X {
|
||||
fn call<T: std::fmt::Show>(&self, x: &T);
|
||||
fn default_method<T: std::fmt::Show>(&self, x: &T) {
|
||||
fn call<T: std::fmt::Debug>(&self, x: &T);
|
||||
fn default_method<T: std::fmt::Debug>(&self, x: &T) {
|
||||
println!("X::default_method {:?}", x);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
struct Y(int);
|
||||
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
struct Z<T> {
|
||||
x: T
|
||||
}
|
||||
|
||||
impl X for Y {
|
||||
fn call<T: std::fmt::Show>(&self, x: &T) {
|
||||
fn call<T: std::fmt::Debug>(&self, x: &T) {
|
||||
println!("X::call {:?} {:?}", self, x);
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
impl<T: X + std::fmt::Show> Drop for Z<T> {
|
||||
impl<T: X + std::fmt::Debug> Drop for Z<T> {
|
||||
fn drop(&mut self) {
|
||||
// These statements used to cause an ICE.
|
||||
self.x.call(self);
|
||||
|
|
|
|||
|
|
@ -8,17 +8,17 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn assert_repr_eq<T: std::fmt::Show>(obj : T, expected : String) {
|
||||
fn assert_repr_eq<T: std::fmt::Debug>(obj : T, expected : String) {
|
||||
assert_eq!(expected, format!("{:?}", obj));
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let abc = [1i, 2, 3];
|
||||
let abc = [1, 2, 3];
|
||||
let tf = [true, false];
|
||||
let x = [(), ()];
|
||||
let slice = &x[..1];
|
||||
|
||||
assert_repr_eq(&abc[], "[1i, 2i, 3i]".to_string());
|
||||
assert_repr_eq(&abc[], "[1, 2, 3]".to_string());
|
||||
assert_repr_eq(&tf[], "[true, false]".to_string());
|
||||
assert_repr_eq(&x[], "[(), ()]".to_string());
|
||||
assert_repr_eq(slice, "[()]".to_string());
|
||||
|
|
|
|||
|
|
@ -8,19 +8,19 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[derive(Clone, Show)]
|
||||
#[derive(Clone, Debug)]
|
||||
enum foo {
|
||||
a(uint),
|
||||
b(String),
|
||||
}
|
||||
|
||||
fn check_log<T: std::fmt::Show>(exp: String, v: T) {
|
||||
fn check_log<T: std::fmt::Debug>(exp: String, v: T) {
|
||||
assert_eq!(exp, format!("{:?}", v));
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let mut x = Some(foo::a(22u));
|
||||
let exp = "Some(a(22u))".to_string();
|
||||
let mut x = Some(foo::a(22));
|
||||
let exp = "Some(a(22))".to_string();
|
||||
let act = format!("{:?}", x);
|
||||
assert_eq!(act, exp);
|
||||
check_log(exp, x);
|
||||
|
|
|
|||
|
|
@ -8,20 +8,20 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
enum foo {
|
||||
a(uint),
|
||||
a(usize),
|
||||
b(String),
|
||||
c,
|
||||
}
|
||||
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
enum bar {
|
||||
d, e, f
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
assert_eq!("a(22u)".to_string(), format!("{:?}", foo::a(22u)));
|
||||
assert_eq!("a(22)".to_string(), format!("{:?}", foo::a(22)));
|
||||
assert_eq!("c".to_string(), format!("{:?}", foo::c));
|
||||
assert_eq!("d".to_string(), format!("{:?}", bar::d));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::fmt::Show;
|
||||
use std::fmt::Debug;
|
||||
|
||||
trait MyTrait<T> {
|
||||
fn get(&self) -> T;
|
||||
|
|
@ -29,7 +29,7 @@ impl MyTrait<u8> for MyType {
|
|||
}
|
||||
|
||||
fn test_eq<T,M>(m: M, v: T)
|
||||
where T : Eq + Show,
|
||||
where T : Eq + Debug,
|
||||
M : MyTrait<T>
|
||||
{
|
||||
assert_eq!(m.get(), v);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::fmt::Show;
|
||||
use std::fmt::Debug;
|
||||
use std::default::Default;
|
||||
|
||||
trait MyTrait<T> {
|
||||
|
|
@ -34,7 +34,7 @@ impl MyTrait<uint> for MyType {
|
|||
}
|
||||
|
||||
fn test_eq<T,M>(m: M, v: T)
|
||||
where T : Eq + Show,
|
||||
where T : Eq + Debug,
|
||||
M : MyTrait<T>
|
||||
{
|
||||
assert_eq!(m.get(), v);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,6 @@ fn main() {
|
|||
Thread::scoped(move|| -> () {
|
||||
let _a = A;
|
||||
panic!();
|
||||
}).join().unwrap_err();
|
||||
}).join().err().unwrap();
|
||||
assert!(unsafe { !HIT });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ impl<K,V> AssociationList<K,V> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<K: PartialEq + std::fmt::Show, V:Clone> Index<K> for AssociationList<K,V> {
|
||||
impl<K: PartialEq + std::fmt::Debug, V:Clone> Index<K> for AssociationList<K,V> {
|
||||
type Output = V;
|
||||
|
||||
fn index<'a>(&'a self, index: &K) -> &'a V {
|
||||
|
|
|
|||
|
|
@ -22,14 +22,14 @@ mod rusti {
|
|||
}
|
||||
|
||||
// This is the type with the questionable alignment
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
struct Inner {
|
||||
c64: u32
|
||||
}
|
||||
|
||||
// This is the type that contains the type with the
|
||||
// questionable alignment, for testing
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
struct Outer {
|
||||
c8: u8,
|
||||
t: Inner
|
||||
|
|
@ -66,6 +66,6 @@ pub fn main() {
|
|||
// because `inner`s alignment was 4.
|
||||
assert_eq!(mem::size_of::<Outer>(), m::size());
|
||||
|
||||
assert_eq!(y, "Outer { c8: 22u8, t: Inner { c64: 44u32 } }".to_string());
|
||||
assert_eq!(y, "Outer { c8: 22, t: Inner { c64: 44 } }".to_string());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,14 +22,14 @@ mod rusti {
|
|||
}
|
||||
|
||||
// This is the type with the questionable alignment
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
struct Inner {
|
||||
c64: u64
|
||||
}
|
||||
|
||||
// This is the type that contains the type with the
|
||||
// questionable alignment, for testing
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
struct Outer {
|
||||
c8: u8,
|
||||
t: Inner
|
||||
|
|
@ -95,6 +95,6 @@ pub fn main() {
|
|||
// because `Inner`s alignment was 4.
|
||||
assert_eq!(mem::size_of::<Outer>(), m::m::size());
|
||||
|
||||
assert_eq!(y, "Outer { c8: 22u8, t: Inner { c64: 44u64 } }".to_string());
|
||||
assert_eq!(y, "Outer { c8: 22, t: Inner { c64: 44 } }".to_string());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,5 +36,5 @@ mod b {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
Thread::scoped(move|| { ::b::g() }).join().unwrap_err();
|
||||
Thread::scoped(move|| { ::b::g() }).join().err().unwrap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
struct Foo(Box<[u8]>);
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
use std::mem::size_of;
|
||||
|
||||
#[derive(PartialEq, Show)]
|
||||
#[derive(PartialEq, Debug)]
|
||||
enum Either<T, U> { Left(T), Right(U) }
|
||||
|
||||
macro_rules! check {
|
||||
|
|
@ -29,14 +29,14 @@ macro_rules! check {
|
|||
pub fn main() {
|
||||
check!(Option<u8>, 2,
|
||||
None, "None",
|
||||
Some(129u8), "Some(129u8)");
|
||||
Some(129u8), "Some(129)");
|
||||
check!(Option<i16>, 4,
|
||||
None, "None",
|
||||
Some(-20000i16), "Some(-20000i16)");
|
||||
Some(-20000i16), "Some(-20000)");
|
||||
check!(Either<u8, i8>, 2,
|
||||
Either::Left(132u8), "Left(132u8)",
|
||||
Either::Right(-32i8), "Right(-32i8)");
|
||||
Either::Left(132u8), "Left(132)",
|
||||
Either::Right(-32i8), "Right(-32)");
|
||||
check!(Either<u8, i16>, 4,
|
||||
Either::Left(132u8), "Left(132u8)",
|
||||
Either::Right(-20000i16), "Right(-20000i16)");
|
||||
Either::Left(132u8), "Left(132)",
|
||||
Either::Right(-20000i16), "Right(-20000)");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
enum a_tag {
|
||||
a_tag_var(u64)
|
||||
}
|
||||
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
struct t_rec {
|
||||
c8: u8,
|
||||
t: a_tag
|
||||
|
|
@ -23,5 +23,5 @@ pub fn main() {
|
|||
let x = t_rec {c8: 22u8, t: a_tag::a_tag_var(44u64)};
|
||||
let y = format!("{:?}", x);
|
||||
println!("y = {:?}", y);
|
||||
assert_eq!(y, "t_rec { c8: 22u8, t: a_tag_var(44u64) }".to_string());
|
||||
assert_eq!(y, "t_rec { c8: 22, t: a_tag_var(44) }".to_string());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,6 @@ pub fn main() {
|
|||
let _b = Foo;
|
||||
}).join();
|
||||
|
||||
let s = x.unwrap_err().downcast::<&'static str>().unwrap();
|
||||
let s = x.err().unwrap().downcast::<&'static str>().ok().unwrap();
|
||||
assert_eq!(s.as_slice(), "This panic should happen.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@
|
|||
// except according to those terms.
|
||||
|
||||
pub fn main() {
|
||||
assert_eq!(format!("{:?}", vec!(0i, 1)), "[0i, 1i]".to_string());
|
||||
assert_eq!(format!("{:?}", vec!(0i, 1)), "[0, 1]".to_string());
|
||||
|
||||
let foo = vec!(3i, 4);
|
||||
let bar: &[int] = &[4, 5];
|
||||
|
||||
assert_eq!(format!("{:?}", foo), "[3i, 4i]");
|
||||
assert_eq!(format!("{:?}", bar), "[4i, 5i]");
|
||||
assert_eq!(format!("{:?}", foo), "[3, 4]");
|
||||
assert_eq!(format!("{:?}", bar), "[4, 5]");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ fn main() {
|
|||
let _failures = range(0, 100).map(|_| {
|
||||
let cmd = Command::new(too_long.as_slice());
|
||||
let failed = cmd.spawn();
|
||||
assert!(failed.is_err(), "Make sure the command fails to spawn(): {}", cmd);
|
||||
assert!(failed.is_err(), "Make sure the command fails to spawn(): {:?}", cmd);
|
||||
failed
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue