From 38aca17c474321e4c260e36f173275a90d753397 Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Tue, 14 Oct 2014 21:07:11 -0400 Subject: [PATCH] Remove libdebug and update tests. --- src/doc/reference.md | 2 +- src/liballoc/lib.rs | 1 - src/libcollections/lib.rs | 1 - src/libdebug/fmt.rs | 53 -- src/libdebug/lib.rs | 33 - src/libdebug/reflect.rs | 404 ------------ src/libdebug/repr.rs | 619 ------------------ src/libgetopts/lib.rs | 1 - src/libnative/lib.rs | 1 - src/librand/lib.rs | 1 - src/librlibc/lib.rs | 1 - src/librustc/lib.rs | 1 - src/librustdoc/lib.rs | 1 - src/libstd/fmt.rs | 11 +- src/libstd/lib.rs | 1 - src/libsyntax/lib.rs | 1 - src/libtime/lib.rs | 17 +- .../auxiliary/extern_calling_convention.rs | 6 +- src/test/auxiliary/logging_right_crate.rs | 3 +- src/test/bench/msgsend-pipes-shared.rs | 11 +- src/test/bench/msgsend-pipes.rs | 17 +- src/test/bench/std-smallintmap.rs | 5 +- src/test/compile-fail/block-coerce-no.rs | 4 +- .../borrowck-borrowed-uniq-rvalue-2.rs | 4 +- .../compile-fail/borrowck-if-with-else.rs | 4 +- .../compile-fail/borrowck-init-in-fn-expr.rs | 4 +- .../borrowck-move-out-of-vec-tail.rs | 6 +- .../borrowck-mut-addr-of-imm-var.rs | 4 +- src/test/compile-fail/copy-a-resource.rs | 5 +- .../compile-fail/if-without-else-result.rs | 4 +- src/test/compile-fail/issue-1476.rs | 4 +- src/test/compile-fail/issue-2281-part1.rs | 2 +- src/test/compile-fail/issue-2823.rs | 4 +- src/test/compile-fail/issue-3038.rs | 6 +- src/test/compile-fail/issue-3521.rs | 5 +- src/test/compile-fail/issue-5062.rs | 4 +- src/test/compile-fail/issue-6458-2.rs | 4 +- .../liveness-closure-require-ret.rs | 4 +- .../compile-fail/liveness-move-in-loop.rs | 4 +- .../compile-fail/liveness-move-in-while.rs | 4 +- .../compile-fail/liveness-use-after-move.rs | 4 +- .../compile-fail/liveness-use-after-send.rs | 11 +- src/test/compile-fail/match-join.rs | 4 +- .../moves-based-on-type-access-to-field.rs | 2 - ...ased-on-type-no-recursive-stack-closure.rs | 4 +- src/test/compile-fail/noncopyable-class.rs | 6 +- src/test/compile-fail/nonscalar-cast.rs | 7 +- .../packed-struct-generic-transmute.rs | 4 +- .../compile-fail/packed-struct-transmute.rs | 5 +- src/test/compile-fail/pattern-tyvar.rs | 4 +- src/test/compile-fail/str-idx.rs | 2 - src/test/compile-fail/unique-pinned-nocopy.rs | 5 +- src/test/compile-fail/unsupported-cast.rs | 2 +- src/test/run-fail/result-get-fail.rs | 4 +- src/test/run-pass/alignment-gep-tup-like-1.rs | 4 +- src/test/run-pass/auto-instantiate.rs | 7 +- src/test/run-pass/block-arg.rs | 4 +- src/test/run-pass/block-iter-1.rs | 4 +- src/test/run-pass/block-iter-2.rs | 4 +- src/test/run-pass/borrowck-mut-uniq.rs | 5 +- .../close-over-big-then-small-data.rs | 4 +- src/test/run-pass/comm.rs | 4 +- .../run-pass/conditional-debug-macro-off.rs | 3 +- .../run-pass/conditional-debug-macro-on.rs | 4 +- .../run-pass/const-fields-and-indexing.rs | 8 +- src/test/run-pass/const-vecs-and-slices.rs | 10 +- src/test/run-pass/dst-struct-reflect.rs | 61 -- src/test/run-pass/enum-discrim-width-stuff.rs | 7 +- src/test/run-pass/evec-slice.rs | 10 +- src/test/run-pass/fixed_length_vec_glue.rs | 22 - src/test/run-pass/float.rs | 4 +- src/test/run-pass/format-ref-cell.rs | 6 +- src/test/run-pass/functional-struct-upd.rs | 5 +- src/test/run-pass/generic-alias-unique.rs | 4 +- src/test/run-pass/generic-derived-type.rs | 6 +- src/test/run-pass/generic-fn-unique.rs | 4 +- src/test/run-pass/generic-tag-values.rs | 8 +- src/test/run-pass/generic-tup.rs | 4 +- src/test/run-pass/getopts_ref.rs | 1 - src/test/run-pass/hashmap-memory.rs | 3 +- src/test/run-pass/if-bot.rs | 4 +- src/test/run-pass/ifmt.rs | 13 +- src/test/run-pass/import.rs | 4 +- src/test/run-pass/issue-13434.rs | 5 +- src/test/run-pass/issue-1696.rs | 3 +- src/test/run-pass/issue-17737.rs | 24 - src/test/run-pass/issue-2216.rs | 4 +- src/test/run-pass/issue-2804-2.rs | 3 +- src/test/run-pass/issue-2804.rs | 7 +- src/test/run-pass/issue-2904.rs | 4 +- src/test/run-pass/issue-3109.rs | 4 +- src/test/run-pass/issue-3794.rs | 5 +- src/test/run-pass/issue-4241.rs | 2 +- src/test/run-pass/issue-4252.rs | 16 +- src/test/run-pass/issue-5688.rs | 4 +- src/test/run-pass/issue-6344-let.rs | 4 +- src/test/run-pass/issue-6344-match.rs | 4 +- src/test/run-pass/issue-7563.rs | 9 +- src/test/run-pass/issue-8898.rs | 16 +- src/test/run-pass/issue-9737.rs | 2 +- src/test/run-pass/last-use-is-capture.rs | 4 +- src/test/run-pass/lazy-and-or.rs | 4 +- src/test/run-pass/linear-for-loop.rs | 10 +- .../log-knows-the-names-of-variants-in-std.rs | 14 +- .../log-knows-the-names-of-variants.rs | 10 +- src/test/run-pass/log-poly.rs | 7 +- src/test/run-pass/match-unique-bind.rs | 4 +- src/test/run-pass/nested-matchs.rs | 4 +- src/test/run-pass/over-constrained-vregs.rs | 4 +- src/test/run-pass/overload-index-operator.rs | 6 +- src/test/run-pass/rec-align-u32.rs | 12 +- src/test/run-pass/rec-align-u64.rs | 9 +- src/test/run-pass/regions-self-impls.rs | 4 +- src/test/run-pass/regions-self-in-enums.rs | 4 +- src/test/run-pass/regions-simple.rs | 4 +- src/test/run-pass/repeated-vector-syntax.rs | 11 +- src/test/run-pass/shadow.rs | 4 +- src/test/run-pass/signal-exit-status.rs | 4 +- src/test/run-pass/size-and-align.rs | 4 +- src/test/run-pass/small-enums-with-fields.rs | 18 +- src/test/run-pass/spawn-fn.rs | 6 +- src/test/run-pass/tag-align-shape.rs | 8 +- src/test/run-pass/tag-disr-val-shape.rs | 9 +- src/test/run-pass/tail-cps.rs | 6 +- src/test/run-pass/task-comm-3.rs | 4 +- src/test/run-pass/task-comm-9.rs | 4 +- src/test/run-pass/tcp-stress.rs | 5 +- src/test/run-pass/tempfile.rs | 6 +- src/test/run-pass/trivial-message.rs | 4 +- src/test/run-pass/tuple-struct-construct.rs | 5 +- src/test/run-pass/unique-in-tag.rs | 4 +- src/test/run-pass/unique-log.rs | 4 +- src/test/run-pass/unique-pat-3.rs | 4 +- src/test/run-pass/vec-dst.rs | 68 -- 134 files changed, 236 insertions(+), 1716 deletions(-) delete mode 100644 src/libdebug/fmt.rs delete mode 100644 src/libdebug/lib.rs delete mode 100644 src/libdebug/reflect.rs delete mode 100644 src/libdebug/repr.rs delete mode 100644 src/test/run-pass/dst-struct-reflect.rs delete mode 100644 src/test/run-pass/fixed_length_vec_glue.rs delete mode 100644 src/test/run-pass/issue-17737.rs diff --git a/src/doc/reference.md b/src/doc/reference.md index 3c4b973002e..6536172e2da 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -1177,7 +1177,7 @@ This is a list of behaviour not considered *unsafe* in Rust terms, but that may be undesired. * Deadlocks -* Reading data from private fields (`std::repr`, `format!("{:?}", x)`) +* Reading data from private fields (`std::repr`) * Leaks due to reference count cycles, even in the global heap * Exiting without calling destructors * Sending signals diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 7b008a76dd6..2df9a585fec 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -77,7 +77,6 @@ extern crate libc; // Allow testing this library -#[cfg(test)] extern crate debug; #[cfg(test)] extern crate native; #[cfg(test)] #[phase(plugin, link)] extern crate std; #[cfg(test)] #[phase(plugin, link)] extern crate log; diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index 535b15708c3..9f989434820 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -33,7 +33,6 @@ extern crate alloc; #[cfg(test)] extern crate native; #[cfg(test)] extern crate test; -#[cfg(test)] extern crate debug; #[cfg(test)] #[phase(plugin, link)] extern crate std; #[cfg(test)] #[phase(plugin, link)] extern crate log; diff --git a/src/libdebug/fmt.rs b/src/libdebug/fmt.rs deleted file mode 100644 index 0b04a07ea88..00000000000 --- a/src/libdebug/fmt.rs +++ /dev/null @@ -1,53 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Implementation of the `{:?}` format qualifier -//! -//! This module contains the `Poly` trait which is used to implement the `{:?}` -//! format expression in formatting macros. This trait is defined for all types -//! automatically, so it is likely not necessary to use this module manually - -use std::fmt; - -use repr; - -/// Format trait for the `?` character -pub trait Poly { - /// Formats the value using the given formatter. - #[experimental] - fn fmt(&self, &mut fmt::Formatter) -> fmt::Result; -} - -#[doc(hidden)] -pub fn secret_poly(x: &T, fmt: &mut fmt::Formatter) -> fmt::Result { - // FIXME #11938 - UFCS would make us able call the this method - // directly Poly::fmt(x, fmt). - x.fmt(fmt) -} - -impl Poly for T { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match (f.width, f.precision) { - (None, None) => { - match repr::write_repr(f, self) { - Ok(()) => Ok(()), - Err(..) => Err(fmt::WriteError), - } - } - - // If we have a specified width for formatting, then we have to make - // this allocation of a new string - _ => { - let s = repr::repr_to_string(self); - f.pad(s.as_slice()) - } - } - } -} diff --git a/src/libdebug/lib.rs b/src/libdebug/lib.rs deleted file mode 100644 index 459e1592f67..00000000000 --- a/src/libdebug/lib.rs +++ /dev/null @@ -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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Debugging utilities for Rust programs -//! -//! This crate is intended to provide useful functionality when debugging -//! programs, such as reflection for printing values. This crate is currently -//! entirely experimental as its makeup will likely change over time. -//! Additionally, it is not guaranteed that functionality such as reflection -//! will persist into the future. - -#![crate_name = "debug"] -#![experimental] -#![license = "MIT/ASL2"] -#![crate_type = "rlib"] -#![crate_type = "dylib"] -#![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/")] -#![experimental] -#![feature(macro_rules)] -#![allow(experimental)] - -pub mod fmt; -pub mod reflect; -pub mod repr; diff --git a/src/libdebug/reflect.rs b/src/libdebug/reflect.rs deleted file mode 100644 index 1e771a2b40a..00000000000 --- a/src/libdebug/reflect.rs +++ /dev/null @@ -1,404 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/*! - -Runtime type reflection - -*/ - -#![allow(missing_doc)] - -use std::intrinsics::{Disr, Opaque, TyDesc, TyVisitor}; -use std::mem; - -/** - * Trait for visitor that wishes to reflect on data. - * - * To use this, create a struct that encapsulates the set of pointers you wish - * to walk through a data structure, and implement both `MovePtr` for it as well - * as `TyVisitor`; then build a MovePtrAdaptor wrapped around your struct. - */ -pub trait MovePtr { - fn move_ptr(&mut self, adjustment: |*const u8| -> *const u8); - fn push_ptr(&mut self); - fn pop_ptr(&mut self); -} - -/// Helper function for alignment calculation. -#[inline] -pub fn align(size: uint, align: uint) -> uint { - ((size + align) - 1u) & !(align - 1u) -} - -/// Adaptor to wrap around visitors implementing MovePtr. -pub struct MovePtrAdaptor { - inner: V -} - -impl MovePtrAdaptor { - pub fn new(v: V) -> MovePtrAdaptor { - MovePtrAdaptor { inner: v } - } - - #[inline] - pub fn bump(&mut self, sz: uint) { - self.inner.move_ptr(|p| ((p as uint) + sz) as *const u8) - } - - #[inline] - pub fn align(&mut self, a: uint) { - self.inner.move_ptr(|p| align(p as uint, a) as *const u8) - } - - #[inline] - pub fn align_to(&mut self) { - self.align(mem::min_align_of::()); - } - - #[inline] - pub fn bump_past(&mut self) { - self.bump(mem::size_of::()); - } - - pub fn unwrap(self) -> V { self.inner } -} - -/// Abstract type-directed pointer-movement using the MovePtr trait -impl TyVisitor for MovePtrAdaptor { - fn visit_bot(&mut self) -> bool { - self.align_to::<()>(); - if ! self.inner.visit_bot() { return false; } - self.bump_past::<()>(); - true - } - - fn visit_nil(&mut self) -> bool { - self.align_to::<()>(); - if ! self.inner.visit_nil() { return false; } - self.bump_past::<()>(); - true - } - - fn visit_bool(&mut self) -> bool { - self.align_to::(); - if ! self.inner.visit_bool() { return false; } - self.bump_past::(); - true - } - - fn visit_int(&mut self) -> bool { - self.align_to::(); - if ! self.inner.visit_int() { return false; } - self.bump_past::(); - true - } - - fn visit_i8(&mut self) -> bool { - self.align_to::(); - if ! self.inner.visit_i8() { return false; } - self.bump_past::(); - true - } - - fn visit_i16(&mut self) -> bool { - self.align_to::(); - if ! self.inner.visit_i16() { return false; } - self.bump_past::(); - true - } - - fn visit_i32(&mut self) -> bool { - self.align_to::(); - if ! self.inner.visit_i32() { return false; } - self.bump_past::(); - true - } - - fn visit_i64(&mut self) -> bool { - self.align_to::(); - if ! self.inner.visit_i64() { return false; } - self.bump_past::(); - true - } - - fn visit_uint(&mut self) -> bool { - self.align_to::(); - if ! self.inner.visit_uint() { return false; } - self.bump_past::(); - true - } - - fn visit_u8(&mut self) -> bool { - self.align_to::(); - if ! self.inner.visit_u8() { return false; } - self.bump_past::(); - true - } - - fn visit_u16(&mut self) -> bool { - self.align_to::(); - if ! self.inner.visit_u16() { return false; } - self.bump_past::(); - true - } - - fn visit_u32(&mut self) -> bool { - self.align_to::(); - if ! self.inner.visit_u32() { return false; } - self.bump_past::(); - true - } - - fn visit_u64(&mut self) -> bool { - self.align_to::(); - if ! self.inner.visit_u64() { return false; } - self.bump_past::(); - true - } - - fn visit_f32(&mut self) -> bool { - self.align_to::(); - if ! self.inner.visit_f32() { return false; } - self.bump_past::(); - true - } - - fn visit_f64(&mut self) -> bool { - self.align_to::(); - if ! self.inner.visit_f64() { return false; } - self.bump_past::(); - true - } - - fn visit_char(&mut self) -> bool { - self.align_to::(); - if ! self.inner.visit_char() { return false; } - self.bump_past::(); - true - } - - fn visit_estr_slice(&mut self) -> bool { - self.align_to::<&'static str>(); - if ! self.inner.visit_estr_slice() { return false; } - self.bump_past::<&'static str>(); - true - } - - fn visit_box(&mut self, mtbl: uint, inner: *const TyDesc) -> bool { - self.align_to::>(); - if ! self.inner.visit_box(mtbl, inner) { return false; } - self.bump_past::>(); - true - } - - fn visit_uniq(&mut self, mtbl: uint, inner: *const TyDesc) -> bool { - self.align_to::>(); - if ! self.inner.visit_uniq(mtbl, inner) { return false; } - self.bump_past::>(); - true - } - - fn visit_ptr(&mut self, mtbl: uint, inner: *const TyDesc) -> bool { - self.align_to::<*const u8>(); - if ! self.inner.visit_ptr(mtbl, inner) { return false; } - self.bump_past::<*const u8>(); - true - } - - fn visit_rptr(&mut self, mtbl: uint, inner: *const TyDesc) -> bool { - self.align_to::<&'static u8>(); - if ! self.inner.visit_rptr(mtbl, inner) { return false; } - self.bump_past::<&'static u8>(); - true - } - - fn visit_evec_slice(&mut self, mtbl: uint, inner: *const TyDesc) -> bool { - self.align_to::<&'static [u8]>(); - if ! self.inner.visit_evec_slice(mtbl, inner) { return false; } - self.bump_past::<&'static [u8]>(); - true - } - - fn visit_evec_fixed(&mut self, n: uint, sz: uint, align: uint, - inner: *const TyDesc) -> bool { - self.align(align); - if ! self.inner.visit_evec_fixed(n, sz, align, inner) { - return false; - } - self.bump(sz); - true - } - - fn visit_enter_rec(&mut self, n_fields: uint, sz: uint, align: uint) -> bool { - self.align(align); - if ! self.inner.visit_enter_rec(n_fields, sz, align) { return false; } - true - } - - fn visit_rec_field(&mut self, i: uint, name: &str, - mtbl: uint, inner: *const TyDesc) -> bool { - unsafe { self.align((*inner).align); } - if ! self.inner.visit_rec_field(i, name, mtbl, inner) { - return false; - } - unsafe { self.bump((*inner).size); } - true - } - - fn visit_leave_rec(&mut self, n_fields: uint, sz: uint, align: uint) -> bool { - if ! self.inner.visit_leave_rec(n_fields, sz, align) { return false; } - true - } - - fn visit_enter_class(&mut self, name: &str, named_fields: bool, n_fields: uint, sz: uint, - align: uint) -> bool { - self.align(align); - if ! self.inner.visit_enter_class(name, named_fields, n_fields, sz, align) { - return false; - } - true - } - - fn visit_class_field(&mut self, i: uint, name: &str, named: bool, mtbl: uint, - inner: *const TyDesc) -> bool { - unsafe { self.align((*inner).align); } - if ! self.inner.visit_class_field(i, name, named, mtbl, inner) { - return false; - } - unsafe { self.bump((*inner).size); } - true - } - - fn visit_leave_class(&mut self, name: &str, named_fields: bool, n_fields: uint, sz: uint, - align: uint) -> bool { - if ! self.inner.visit_leave_class(name, named_fields, n_fields, sz, align) { - return false; - } - true - } - - fn visit_enter_tup(&mut self, n_fields: uint, sz: uint, align: uint) -> bool { - self.align(align); - if ! self.inner.visit_enter_tup(n_fields, sz, align) { return false; } - true - } - - fn visit_tup_field(&mut self, i: uint, inner: *const TyDesc) -> bool { - unsafe { self.align((*inner).align); } - if ! self.inner.visit_tup_field(i, inner) { return false; } - unsafe { self.bump((*inner).size); } - true - } - - fn visit_leave_tup(&mut self, n_fields: uint, sz: uint, align: uint) -> bool { - if ! self.inner.visit_leave_tup(n_fields, sz, align) { return false; } - true - } - - fn visit_enter_fn(&mut self, purity: uint, proto: uint, - n_inputs: uint, retstyle: uint) -> bool { - if ! self.inner.visit_enter_fn(purity, proto, n_inputs, retstyle) { - return false - } - true - } - - fn visit_fn_input(&mut self, i: uint, mode: uint, - inner: *const TyDesc) -> bool { - if ! self.inner.visit_fn_input(i, mode, inner) { return false; } - true - } - - fn visit_fn_output(&mut self, retstyle: uint, variadic: bool, - inner: *const TyDesc) -> bool { - if ! self.inner.visit_fn_output(retstyle, variadic, inner) { return false; } - true - } - - fn visit_leave_fn(&mut self, purity: uint, proto: uint, - n_inputs: uint, retstyle: uint) -> bool { - if ! self.inner.visit_leave_fn(purity, proto, n_inputs, retstyle) { - return false; - } - true - } - - fn visit_enter_enum(&mut self, n_variants: uint, - get_disr: unsafe extern fn(ptr: *const Opaque) -> Disr, - sz: uint, align: uint) - -> bool { - self.align(align); - if ! self.inner.visit_enter_enum(n_variants, get_disr, sz, align) { - return false; - } - true - } - - fn visit_enter_enum_variant(&mut self, variant: uint, - disr_val: Disr, - n_fields: uint, - name: &str) -> bool { - if ! self.inner.visit_enter_enum_variant(variant, disr_val, - n_fields, name) { - return false; - } - true - } - - fn visit_enum_variant_field(&mut self, i: uint, offset: uint, - inner: *const TyDesc) -> bool { - self.inner.push_ptr(); - self.bump(offset); - if ! self.inner.visit_enum_variant_field(i, offset, inner) { return false; } - self.inner.pop_ptr(); - true - } - - fn visit_leave_enum_variant(&mut self, variant: uint, - disr_val: Disr, - n_fields: uint, - name: &str) -> bool { - if ! self.inner.visit_leave_enum_variant(variant, disr_val, - n_fields, name) { - return false; - } - true - } - - fn visit_leave_enum(&mut self, n_variants: uint, - get_disr: unsafe extern fn(ptr: *const Opaque) -> Disr, - sz: uint, align: uint) -> bool { - if ! self.inner.visit_leave_enum(n_variants, get_disr, sz, align) { - return false; - } - self.bump(sz); - true - } - - fn visit_trait(&mut self, name: &str) -> bool { - self.align_to::>(); - if ! self.inner.visit_trait(name) { return false; } - self.bump_past::>(); - true - } - - fn visit_param(&mut self, i: uint) -> bool { - if ! self.inner.visit_param(i) { return false; } - true - } - - fn visit_self(&mut self) -> bool { - self.align_to::<&'static u8>(); - if ! self.inner.visit_self() { return false; } - self.align_to::<&'static u8>(); - true - } -} diff --git a/src/libdebug/repr.rs b/src/libdebug/repr.rs deleted file mode 100644 index e27816c8165..00000000000 --- a/src/libdebug/repr.rs +++ /dev/null @@ -1,619 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/*! - -More runtime type reflection - -*/ - -use std::char; -use std::intrinsics::{Disr, Opaque, TyDesc, TyVisitor, get_tydesc, visit_tydesc}; -use std::io; -use std::mem; -use std::raw; - -use reflect; -use reflect::{MovePtr, align}; - -macro_rules! try( ($me:expr, $e:expr) => ( - match $e { - Ok(()) => {}, - Err(e) => { $me.last_err = Some(e); return false; } - } -) ) - -/// Representations - -pub trait Repr { - fn write_repr(&self, writer: &mut io::Writer) -> io::IoResult<()>; -} - -impl Repr for () { - fn write_repr(&self, writer: &mut io::Writer) -> io::IoResult<()> { - writer.write("()".as_bytes()) - } -} - -impl Repr for bool { - fn write_repr(&self, writer: &mut io::Writer) -> io::IoResult<()> { - let s = if *self { "true" } else { "false" }; - writer.write(s.as_bytes()) - } -} - -impl Repr for int { - fn write_repr(&self, writer: &mut io::Writer) -> io::IoResult<()> { - write!(writer, "{}", *self) - } -} - -macro_rules! int_repr(($ty:ident, $suffix:expr) => (impl Repr for $ty { - fn write_repr(&self, writer: &mut io::Writer) -> io::IoResult<()> { - write!(writer, "{}{}", *self, $suffix) - } -})) - -int_repr!(i8, "i8") -int_repr!(i16, "i16") -int_repr!(i32, "i32") -int_repr!(i64, "i64") -int_repr!(uint, "u") -int_repr!(u8, "u8") -int_repr!(u16, "u16") -int_repr!(u32, "u32") -int_repr!(u64, "u64") - -macro_rules! num_repr(($ty:ident, $suffix:expr) => (impl Repr for $ty { - fn write_repr(&self, writer: &mut io::Writer) -> io::IoResult<()> { - let s = self.to_string(); - writer.write(s.as_bytes()).and_then(|()| { - writer.write($suffix) - }) - } -})) - -num_repr!(f32, b"f32") -num_repr!(f64, b"f64") - -// New implementation using reflect::MovePtr - -enum VariantState { - SearchingFor(Disr), - Matched, - AlreadyFound -} - -pub struct ReprVisitor<'a> { - ptr: *const u8, - ptr_stk: Vec<*const u8>, - var_stk: Vec, - writer: &'a mut io::Writer+'a, - last_err: Option, -} - -impl<'a> MovePtr for ReprVisitor<'a> { - #[inline] - fn move_ptr(&mut self, adjustment: |*const u8| -> *const u8) { - self.ptr = adjustment(self.ptr); - } - fn push_ptr(&mut self) { - self.ptr_stk.push(self.ptr); - } - fn pop_ptr(&mut self) { - self.ptr = self.ptr_stk.pop().unwrap(); - } -} - -impl<'a> ReprVisitor<'a> { - // Various helpers for the TyVisitor impl - pub fn new(ptr: *const u8, writer: &'a mut io::Writer) -> ReprVisitor<'a> { - ReprVisitor { - ptr: ptr, - ptr_stk: vec!(), - var_stk: vec!(), - writer: writer, - last_err: None, - } - } - - #[inline] - pub fn get(&mut self, f: |&mut ReprVisitor, &T| -> bool) -> bool { - unsafe { - let ptr = self.ptr; - f(self, mem::transmute::<*const u8,&T>(ptr)) - } - } - - #[inline] - pub fn visit_inner(&mut self, inner: *const TyDesc) -> bool { - let ptr = self.ptr; - self.visit_ptr_inner(ptr, inner) - } - - #[inline] - pub fn visit_ptr_inner(&mut self, ptr: *const u8, - inner: *const TyDesc) -> bool { - unsafe { - let u = ReprVisitor::new(ptr, mem::transmute_copy(&self.writer)); - let mut v = reflect::MovePtrAdaptor::new(u); - // Obviously this should not be a thing, but blame #8401 for now - visit_tydesc(inner, &mut v as &mut TyVisitor); - match v.unwrap().last_err { - Some(e) => { - self.last_err = Some(e); - false - } - None => true, - } - } - } - - #[inline] - pub fn write(&mut self) -> bool { - self.get(|this, v:&T| { - try!(this, v.write_repr(this.writer)); - true - }) - } - - pub fn write_escaped_slice(&mut self, slice: &str) -> bool { - try!(self, self.writer.write([b'"'])); - for ch in slice.chars() { - if !self.write_escaped_char(ch, true) { return false } - } - try!(self, self.writer.write([b'"'])); - true - } - - pub fn write_mut_qualifier(&mut self, mtbl: uint) -> bool { - if mtbl == 0 { - try!(self, self.writer.write("mut ".as_bytes())); - } else if mtbl == 1 { - // skip, this is ast::m_imm - } else { - fail!("invalid mutability value"); - } - true - } - - pub fn write_vec_range(&mut self, ptr: *const (), len: uint, - inner: *const TyDesc) -> bool { - let mut p = ptr as *const u8; - let (sz, al) = unsafe { ((*inner).size, (*inner).align) }; - try!(self, self.writer.write([b'['])); - let mut first = true; - let mut left = len; - // unit structs have 0 size, and don't loop forever. - let dec = if sz == 0 {1} else {sz}; - while left > 0 { - if first { - first = false; - } else { - try!(self, self.writer.write(", ".as_bytes())); - } - self.visit_ptr_inner(p as *const u8, inner); - p = align(unsafe { p.offset(sz as int) as uint }, al) as *const u8; - left -= dec; - } - try!(self, self.writer.write([b']'])); - true - } - - fn write_escaped_char(&mut self, ch: char, is_str: bool) -> bool { - try!(self, match ch { - '\t' => self.writer.write("\\t".as_bytes()), - '\r' => self.writer.write("\\r".as_bytes()), - '\n' => self.writer.write("\\n".as_bytes()), - '\\' => self.writer.write("\\\\".as_bytes()), - '\'' => { - if is_str { - self.writer.write("'".as_bytes()) - } else { - self.writer.write("\\'".as_bytes()) - } - } - '"' => { - if is_str { - self.writer.write("\\\"".as_bytes()) - } else { - self.writer.write("\"".as_bytes()) - } - } - '\x20'...'\x7e' => self.writer.write([ch as u8]), - _ => { - char::escape_unicode(ch, |c| { - let _ = self.writer.write([c as u8]); - }); - Ok(()) - } - }); - return true; - } -} - -impl<'a> TyVisitor for ReprVisitor<'a> { - fn visit_bot(&mut self) -> bool { - try!(self, self.writer.write("!".as_bytes())); - true - } - fn visit_nil(&mut self) -> bool { self.write::<()>() } - fn visit_bool(&mut self) -> bool { self.write::() } - fn visit_int(&mut self) -> bool { self.write::() } - fn visit_i8(&mut self) -> bool { self.write::() } - fn visit_i16(&mut self) -> bool { self.write::() } - fn visit_i32(&mut self) -> bool { self.write::() } - fn visit_i64(&mut self) -> bool { self.write::() } - - fn visit_uint(&mut self) -> bool { self.write::() } - fn visit_u8(&mut self) -> bool { self.write::() } - fn visit_u16(&mut self) -> bool { self.write::() } - fn visit_u32(&mut self) -> bool { self.write::() } - fn visit_u64(&mut self) -> bool { self.write::() } - - fn visit_f32(&mut self) -> bool { self.write::() } - fn visit_f64(&mut self) -> bool { self.write::() } - - fn visit_char(&mut self) -> bool { - self.get::(|this, &ch| { - try!(this, this.writer.write([b'\''])); - if !this.write_escaped_char(ch, false) { return false } - try!(this, this.writer.write([b'\''])); - true - }) - } - - fn visit_estr_slice(&mut self) -> bool { - self.get::<&str>(|this, s| this.write_escaped_slice(*s)) - } - - fn visit_box(&mut self, _mtbl: uint, _inner: *const TyDesc) -> bool { - try!(self, self.writer.write("box(GC) ???".as_bytes())); - true - } - - fn visit_uniq(&mut self, _mtbl: uint, inner: *const TyDesc) -> bool { - try!(self, self.writer.write("box ".as_bytes())); - self.get::<*const u8>(|this, b| { - this.visit_ptr_inner(*b, inner) - }) - } - - fn visit_ptr(&mut self, mtbl: uint, _inner: *const TyDesc) -> bool { - self.get::<*const u8>(|this, p| { - try!(this, write!(this.writer, "({} as *", *p)); - if mtbl == 0 { - try!(this, this.writer.write("mut ".as_bytes())); - } else if mtbl == 1 { - try!(this, this.writer.write("const ".as_bytes())); - } else { - fail!("invalid mutability value"); - } - try!(this, this.writer.write("())".as_bytes())); - true - }) - } - - fn visit_rptr(&mut self, mtbl: uint, inner: *const TyDesc) -> bool { - try!(self, self.writer.write([b'&'])); - self.write_mut_qualifier(mtbl); - self.get::<*const u8>(|this, p| { - this.visit_ptr_inner(*p, inner) - }) - } - - fn visit_evec_slice(&mut self, mtbl: uint, inner: *const TyDesc) -> bool { - self.get::>(|this, s| { - try!(this, this.writer.write([b'&'])); - this.write_mut_qualifier(mtbl); - let size = unsafe { - if (*inner).size == 0 { 1 } else { (*inner).size } - }; - this.write_vec_range(s.data, s.len * size, inner) - }) - } - - fn visit_evec_fixed(&mut self, n: uint, sz: uint, _align: uint, - inner: *const TyDesc) -> bool { - let assumed_size = if sz == 0 { n } else { sz }; - self.get::<()>(|this, b| { - this.write_vec_range(b, assumed_size, inner) - }) - } - - - fn visit_enter_rec(&mut self, _n_fields: uint, - _sz: uint, _align: uint) -> bool { - try!(self, self.writer.write([b'{'])); - true - } - - fn visit_rec_field(&mut self, i: uint, name: &str, - mtbl: uint, inner: *const TyDesc) -> bool { - if i != 0 { - try!(self, self.writer.write(", ".as_bytes())); - } - self.write_mut_qualifier(mtbl); - try!(self, self.writer.write(name.as_bytes())); - try!(self, self.writer.write(": ".as_bytes())); - self.visit_inner(inner); - true - } - - fn visit_leave_rec(&mut self, _n_fields: uint, - _sz: uint, _align: uint) -> bool { - try!(self, self.writer.write([b'}'])); - true - } - - fn visit_enter_class(&mut self, name: &str, named_fields: bool, n_fields: uint, - _sz: uint, _align: uint) -> bool { - try!(self, self.writer.write(name.as_bytes())); - if n_fields != 0 { - if named_fields { - try!(self, self.writer.write([b'{'])); - } else { - try!(self, self.writer.write([b'('])); - } - } - true - } - - fn visit_class_field(&mut self, i: uint, name: &str, named: bool, - _mtbl: uint, inner: *const TyDesc) -> bool { - if i != 0 { - try!(self, self.writer.write(", ".as_bytes())); - } - if named { - try!(self, self.writer.write(name.as_bytes())); - try!(self, self.writer.write(": ".as_bytes())); - } - self.visit_inner(inner); - true - } - - fn visit_leave_class(&mut self, _name: &str, named_fields: bool, n_fields: uint, - _sz: uint, _align: uint) -> bool { - if n_fields != 0 { - if named_fields { - try!(self, self.writer.write([b'}'])); - } else { - try!(self, self.writer.write([b')'])); - } - } - true - } - - fn visit_enter_tup(&mut self, _n_fields: uint, - _sz: uint, _align: uint) -> bool { - try!(self, self.writer.write([b'('])); - true - } - - fn visit_tup_field(&mut self, i: uint, inner: *const TyDesc) -> bool { - if i != 0 { - try!(self, self.writer.write(", ".as_bytes())); - } - self.visit_inner(inner); - true - } - - fn visit_leave_tup(&mut self, _n_fields: uint, - _sz: uint, _align: uint) -> bool { - if _n_fields == 1 { - try!(self, self.writer.write([b','])); - } - try!(self, self.writer.write([b')'])); - true - } - - fn visit_enter_enum(&mut self, - _n_variants: uint, - get_disr: unsafe extern fn(ptr: *const Opaque) -> Disr, - _sz: uint, - _align: uint) -> bool { - let disr = unsafe { - get_disr(mem::transmute(self.ptr)) - }; - self.var_stk.push(SearchingFor(disr)); - true - } - - fn visit_enter_enum_variant(&mut self, _variant: uint, - disr_val: Disr, - n_fields: uint, - name: &str) -> bool { - let mut write = false; - match self.var_stk.pop().unwrap() { - SearchingFor(sought) => { - if disr_val == sought { - self.var_stk.push(Matched); - write = true; - } else { - self.var_stk.push(SearchingFor(sought)); - } - } - Matched | AlreadyFound => { - self.var_stk.push(AlreadyFound); - } - } - - if write { - try!(self, self.writer.write(name.as_bytes())); - if n_fields > 0 { - try!(self, self.writer.write([b'('])); - } - } - true - } - - fn visit_enum_variant_field(&mut self, - i: uint, - _offset: uint, - inner: *const TyDesc) - -> bool { - match self.var_stk[self.var_stk.len() - 1] { - Matched => { - if i != 0 { - try!(self, self.writer.write(", ".as_bytes())); - } - if ! self.visit_inner(inner) { - return false; - } - } - _ => () - } - true - } - - fn visit_leave_enum_variant(&mut self, _variant: uint, - _disr_val: Disr, - n_fields: uint, - _name: &str) -> bool { - match self.var_stk[self.var_stk.len() - 1] { - Matched => { - if n_fields > 0 { - try!(self, self.writer.write([b')'])); - } - } - _ => () - } - true - } - - fn visit_leave_enum(&mut self, - _n_variants: uint, - _get_disr: unsafe extern fn(ptr: *const Opaque) -> Disr, - _sz: uint, - _align: uint) - -> bool { - match self.var_stk.pop().unwrap() { - SearchingFor(..) => fail!("enum value matched no variant"), - _ => true - } - } - - fn visit_enter_fn(&mut self, _purity: uint, _proto: uint, - _n_inputs: uint, _retstyle: uint) -> bool { - try!(self, self.writer.write("fn(".as_bytes())); - true - } - - fn visit_fn_input(&mut self, i: uint, _mode: uint, - inner: *const TyDesc) -> bool { - if i != 0 { - try!(self, self.writer.write(", ".as_bytes())); - } - let name = unsafe { (*inner).name }; - try!(self, self.writer.write(name.as_bytes())); - true - } - - fn visit_fn_output(&mut self, _retstyle: uint, variadic: bool, - inner: *const TyDesc) -> bool { - if variadic { - try!(self, self.writer.write(", ...".as_bytes())); - } - try!(self, self.writer.write(")".as_bytes())); - let name = unsafe { (*inner).name }; - if name != "()" { - try!(self, self.writer.write(" -> ".as_bytes())); - try!(self, self.writer.write(name.as_bytes())); - } - true - } - - fn visit_leave_fn(&mut self, _purity: uint, _proto: uint, - _n_inputs: uint, _retstyle: uint) -> bool { true } - - - fn visit_trait(&mut self, name: &str) -> bool { - try!(self, self.writer.write(name.as_bytes())); - true - } - - fn visit_param(&mut self, _i: uint) -> bool { true } - fn visit_self(&mut self) -> bool { true } -} - -pub fn write_repr(writer: &mut io::Writer, object: &T) -> io::IoResult<()> { - unsafe { - let ptr = object as *const T as *const u8; - let tydesc = get_tydesc::(); - let u = ReprVisitor::new(ptr, writer); - let mut v = reflect::MovePtrAdaptor::new(u); - visit_tydesc(tydesc, &mut v as &mut TyVisitor); - match v.unwrap().last_err { - Some(e) => Err(e), - None => Ok(()), - } - } -} - -pub fn repr_to_string(t: &T) -> String { - let mut result = io::MemWriter::new(); - write_repr(&mut result as &mut io::Writer, t).unwrap(); - String::from_utf8(result.unwrap()).unwrap() -} - -#[cfg(test)] -#[allow(dead_code)] -struct P {a: int, b: f64} - -#[test] -fn test_repr() { - use std::io::stdio::println; - use std::char::is_alphabetic; - use std::mem::swap; - - fn exact_test(t: &T, e:&str) { - let mut m = io::MemWriter::new(); - write_repr(&mut m as &mut io::Writer, t).unwrap(); - let s = String::from_utf8(m.unwrap()).unwrap(); - assert_eq!(s.as_slice(), e); - } - - exact_test(&10i, "10"); - exact_test(&true, "true"); - exact_test(&false, "false"); - exact_test(&1.234f64, "1.234f64"); - exact_test(&("hello"), "\"hello\""); - - exact_test(&(box 10i), "box 10"); - exact_test(&(&10i), "&10"); - let mut x = 10i; - exact_test(&(&mut x), "&mut 10"); - - exact_test(&(0i as *const()), "(0x0 as *const ())"); - exact_test(&(0i as *mut ()), "(0x0 as *mut ())"); - - exact_test(&(1i,), "(1,)"); - exact_test(&(&["hi", "there"]), - "&[\"hi\", \"there\"]"); - exact_test(&(P{a:10, b:1.234}), - "repr::P{a: 10, b: 1.234f64}"); - exact_test(&(box P{a:10, b:1.234}), - "box repr::P{a: 10, b: 1.234f64}"); - - exact_test(&(&[1i, 2i]), "&[1, 2]"); - exact_test(&(&mut [1i, 2i]), "&mut [1, 2]"); - - exact_test(&'\'', "'\\''"); - exact_test(&'"', "'\"'"); - exact_test(&("'"), "\"'\""); - exact_test(&("\""), "\"\\\"\""); - - exact_test(&println, "fn(&str)"); - exact_test(&swap::, "fn(&mut int, &mut int)"); - exact_test(&is_alphabetic, "fn(char) -> bool"); - - struct Bar(int, int); - exact_test(&(Bar(2, 2)), "repr::test_repr::Bar(2, 2)"); -} diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index 5adad73b22d..37b3458b555 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -91,7 +91,6 @@ #![feature(import_shadowing)] #![deny(missing_doc)] -#[cfg(test)] extern crate debug; #[cfg(test)] #[phase(plugin, link)] extern crate log; use std::cmp::PartialEq; diff --git a/src/libnative/lib.rs b/src/libnative/lib.rs index d738a3c93b8..71a1645f9ff 100644 --- a/src/libnative/lib.rs +++ b/src/libnative/lib.rs @@ -67,7 +67,6 @@ extern crate alloc; extern crate libc; -#[cfg(test)] extern crate debug; use std::os; use std::rt; diff --git a/src/librand/lib.rs b/src/librand/lib.rs index 9a364150ec5..ff7d3c29620 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -34,7 +34,6 @@ extern crate core; #[cfg(test)] #[phase(plugin, link)] extern crate std; #[cfg(test)] #[phase(plugin, link)] extern crate log; #[cfg(test)] extern crate native; -#[cfg(test)] extern crate debug; use core::prelude::*; diff --git a/src/librlibc/lib.rs b/src/librlibc/lib.rs index faa89bc9b11..ca7ce2a8b71 100644 --- a/src/librlibc/lib.rs +++ b/src/librlibc/lib.rs @@ -39,7 +39,6 @@ #[cfg(test)] extern crate native; #[cfg(test)] extern crate test; -#[cfg(test)] extern crate debug; #[cfg(test)] #[phase(plugin, link)] extern crate std; diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 6d5cd6061cf..eb78762906e 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -34,7 +34,6 @@ This API is completely unstable and subject to change. #![feature(rustc_diagnostic_macros)] extern crate arena; -extern crate debug; extern crate flate; extern crate getopts; extern crate graphviz; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 77d63224fcd..44827a7b02c 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -19,7 +19,6 @@ #![feature(globs, struct_variant, macro_rules, phase, slicing_syntax)] extern crate arena; -extern crate debug; extern crate getopts; extern crate libc; extern crate rustc; diff --git a/src/libstd/fmt.rs b/src/libstd/fmt.rs index f69f94c4db6..27451c91f3f 100644 --- a/src/libstd/fmt.rs +++ b/src/libstd/fmt.rs @@ -36,12 +36,11 @@ format arguments directly while performing minimal allocations. Some examples of the `format!` extension are: ```rust -# extern crate debug; # fn main() { format!("Hello"); // => "Hello" format!("Hello, {:s}!", "world"); // => "Hello, world!" format!("The number is {:d}", 1i); // => "The number is 1" -format!("{:?}", (3i, 4i)); // => "(3, 4)" +format!("{}", (3i, 4i)); // => "(3, 4)" format!("{value}", value=4i); // => "4" format!("{} {}", 1i, 2i); // => "1 2" # } @@ -94,11 +93,10 @@ identifier '=' expression For example, the following `format!` expressions all use named argument: ```rust -# extern crate debug; # fn main() { format!("{argument}", argument = "test"); // => "test" format!("{name} {}", 1i, name = 2i); // => "2 1" -format!("{a:s} {c:d} {b:?}", a="a", b=(), c=3i); // => "a 3 ()" +format!("{a:s} {c:d} {b}", a="a", b=(), c=3i); // => "a 3 ()" # } ``` @@ -154,11 +152,6 @@ The current mapping of types to traits is: * `f` ⇒ `Float` * `e` ⇒ `LowerExp` * `E` ⇒ `UpperExp` -* `?` ⇒ `Poly` - -> **Note**: The `Poly` formatting trait is provided by [libdebug](../../debug/) -> and is an experimental implementation that should not be relied upon. In order -> to use the `?` modifier, the libdebug crate must be linked against. What this means is that any type of argument which implements the `std::fmt::Binary` trait can then be formatted with `{:t}`. Implementations are diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 13adfeecf85..82c8d8071b3 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -118,7 +118,6 @@ #![reexport_test_harness_main = "test_main"] #[cfg(test)] extern crate green; -#[cfg(test)] extern crate debug; #[cfg(test)] #[phase(plugin, link)] extern crate log; extern crate alloc; diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 3a4c7abd7b8..8c2652e5699 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -30,7 +30,6 @@ extern crate arena; extern crate fmt_macros; -extern crate debug; #[phase(plugin, link)] extern crate log; extern crate serialize; extern crate term; diff --git a/src/libtime/lib.rs b/src/libtime/lib.rs index 5f8c7d29444..ee06c3f6caa 100644 --- a/src/libtime/lib.rs +++ b/src/libtime/lib.rs @@ -22,7 +22,6 @@ html_playground_url = "http://play.rust-lang.org/")] #![feature(phase)] -#[cfg(test)] extern crate debug; #[cfg(test)] #[phase(plugin, link)] extern crate log; extern crate serialize; @@ -1184,13 +1183,13 @@ mod tests { static SOME_FUTURE_DATE: i64 = 1577836800i64; // 2020-01-01T00:00:00Z let tv1 = get_time(); - debug!("tv1={:?} sec + {:?} nsec", tv1.sec as uint, tv1.nsec as uint); + debug!("tv1={} sec + {} nsec", tv1.sec as uint, tv1.nsec as uint); assert!(tv1.sec > SOME_RECENT_DATE); assert!(tv1.nsec < 1000000000i32); let tv2 = get_time(); - debug!("tv2={:?} sec + {:?} nsec", tv2.sec as uint, tv2.nsec as uint); + debug!("tv2={} sec + {} nsec", tv2.sec as uint, tv2.nsec as uint); assert!(tv2.sec >= tv1.sec); assert!(tv2.sec < SOME_FUTURE_DATE); @@ -1207,12 +1206,12 @@ mod tests { let ns0 = precise_time_ns(); let ns1 = precise_time_ns(); - debug!("ns0={:?} ns", ns0); - debug!("ns1={:?} ns", ns1); + debug!("ns0={} ns", ns0); + debug!("ns1={} ns", ns1); assert!(ns1 >= ns0); let ns2 = precise_time_ns(); - debug!("ns2={:?} ns", ns2); + debug!("ns2={} ns", ns2); assert!(ns2 >= ns1); } @@ -1241,7 +1240,7 @@ mod tests { let time = Timespec::new(1234567890, 54321); let local = at(time); - debug!("time_at: {:?}", local); + debug!("time_at: {}", local); assert_eq!(local.tm_sec, 30_i32); assert_eq!(local.tm_min, 31_i32); @@ -1446,7 +1445,7 @@ mod tests { let utc = at_utc(time); let local = at(time); - debug!("test_ctime: {:?} {:?}", utc.asctime(), local.asctime()); + debug!("test_ctime: {} {}", utc.asctime(), local.asctime()); assert_eq!(utc.asctime(), "Fri Feb 13 23:31:30 2009".to_string()); assert_eq!(local.asctime(), "Fri Feb 13 15:31:30 2009".to_string()); @@ -1459,7 +1458,7 @@ mod tests { let utc = at_utc(time); let local = at(time); - debug!("test_ctime: {:?} {:?}", utc.ctime(), local.ctime()); + debug!("test_ctime: {} {}", utc.ctime(), local.ctime()); assert_eq!(utc.ctime(), "Fri Feb 13 15:31:30 2009".to_string()); assert_eq!(local.ctime(), "Fri Feb 13 15:31:30 2009".to_string()); diff --git a/src/test/auxiliary/extern_calling_convention.rs b/src/test/auxiliary/extern_calling_convention.rs index 2319a4545ef..1a579dd1b0e 100644 --- a/src/test/auxiliary/extern_calling_convention.rs +++ b/src/test/auxiliary/extern_calling_convention.rs @@ -11,8 +11,6 @@ // Make sure Rust generates the correct calling convention for extern // functions. -extern crate debug; - #[inline(never)] #[cfg(target_arch = "x86_64")] pub extern "win64" fn foo(a: int, b: int, c: int, d: int) { @@ -21,7 +19,7 @@ pub extern "win64" fn foo(a: int, b: int, c: int, d: int) { assert!(c == 3); assert!(d == 4); - println!("a: {:?}, b: {:?}, c: {:?}, d: {:?}", + println!("a: {}, b: {}, c: {}, d: {}", a, b, c, d) } @@ -33,6 +31,6 @@ pub extern fn foo(a: int, b: int, c: int, d: int) { assert!(c == 3); assert!(d == 4); - println!("a: {:?}, b: {:?}, c: {:?}, d: {:?}", + println!("a: {}, b: {}, c: {}, d: {}", a, b, c, d) } diff --git a/src/test/auxiliary/logging_right_crate.rs b/src/test/auxiliary/logging_right_crate.rs index 0c4af97b410..6bc5b677a27 100644 --- a/src/test/auxiliary/logging_right_crate.rs +++ b/src/test/auxiliary/logging_right_crate.rs @@ -10,9 +10,8 @@ #![feature(phase)] #[phase(plugin, link)] extern crate log; -extern crate debug; pub fn foo() { fn death() -> int { fail!() } - debug!("{:?}", (||{ death() })()); + debug!("{}", (||{ death() })()); } diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs index 3b39ce610a1..34479f296bb 100644 --- a/src/test/bench/msgsend-pipes-shared.rs +++ b/src/test/bench/msgsend-pipes-shared.rs @@ -19,7 +19,6 @@ // version. extern crate time; -extern crate debug; use std::comm; use std::os; @@ -41,7 +40,7 @@ fn server(requests: &Receiver, responses: &Sender) { match requests.recv_opt() { Ok(get_count) => { responses.send(count.clone()); } Ok(bytes(b)) => { - //println!("server: received {:?} bytes", b); + //println!("server: received {} bytes", b); count += b; } Err(..) => { done = true; } @@ -65,10 +64,10 @@ fn run(args: &[String]) { let to_child = to_child.clone(); worker_results.push(task::try_future(proc() { for _ in range(0u, size / workers) { - //println!("worker {:?}: sending {:?} bytes", i, num_bytes); + //println!("worker {}: sending {} bytes", i, num_bytes); to_child.send(bytes(num_bytes)); } - //println!("worker {:?} exiting", i); + //println!("worker {} exiting", i); })); } task::spawn(proc() { @@ -85,8 +84,8 @@ fn run(args: &[String]) { let result = from_child.recv(); let end = time::precise_time_s(); let elapsed = end - start; - print!("Count is {:?}\n", result); - print!("Test took {:?} seconds\n", elapsed); + print!("Count is {}\n", result); + print!("Test took {} seconds\n", elapsed); let thruput = ((size / workers * workers) as f64) / (elapsed as f64); print!("Throughput={} per sec\n", thruput); assert_eq!(result, num_bytes * size); diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs index f103014ca88..7a06b43ba2d 100644 --- a/src/test/bench/msgsend-pipes.rs +++ b/src/test/bench/msgsend-pipes.rs @@ -15,7 +15,6 @@ // I *think* it's the same, more or less. extern crate time; -extern crate debug; use std::os; use std::task; @@ -36,7 +35,7 @@ fn server(requests: &Receiver, responses: &Sender) { match requests.recv_opt() { Ok(get_count) => { responses.send(count.clone()); } Ok(bytes(b)) => { - //println!("server: received {:?} bytes", b); + //println!("server: received {} bytes", b); count += b; } Err(..) => { done = true; } @@ -59,10 +58,10 @@ fn run(args: &[String]) { let (to_child, from_parent) = channel(); worker_results.push(task::try_future(proc() { for _ in range(0u, size / workers) { - //println!("worker {:?}: sending {:?} bytes", i, num_bytes); + //println!("worker {}: sending {} bytes", i, num_bytes); to_child.send(bytes(num_bytes)); } - //println!("worker {:?} exiting", i); + //println!("worker {} exiting", i); })); from_parent } else { @@ -71,10 +70,10 @@ fn run(args: &[String]) { let to_child = to_child.clone(); worker_results.push(task::try_future(proc() { for _ in range(0u, size / workers) { - //println!("worker {:?}: sending {:?} bytes", i, num_bytes); + //println!("worker {}: sending {} bytes", i, num_bytes); to_child.send(bytes(num_bytes)); } - //println!("worker {:?} exiting", i); + //println!("worker {} exiting", i); })); } from_parent @@ -93,8 +92,8 @@ fn run(args: &[String]) { let result = from_child.recv(); let end = time::precise_time_s(); let elapsed = end - start; - print!("Count is {:?}\n", result); - print!("Test took {:?} seconds\n", elapsed); + print!("Count is {}\n", result); + print!("Test took {} seconds\n", elapsed); let thruput = ((size / workers * workers) as f64) / (elapsed as f64); print!("Throughput={} per sec\n", thruput); assert_eq!(result, num_bytes * size); @@ -110,6 +109,6 @@ fn main() { args.clone().into_iter().map(|x| x.to_string()).collect() }; - println!("{:?}", args); + println!("{}", args); run(args.as_slice()); } diff --git a/src/test/bench/std-smallintmap.rs b/src/test/bench/std-smallintmap.rs index ba1bce2f834..c495e597ca6 100644 --- a/src/test/bench/std-smallintmap.rs +++ b/src/test/bench/std-smallintmap.rs @@ -12,7 +12,6 @@ extern crate collections; extern crate time; -extern crate debug; use std::collections::SmallIntMap; use std::os; @@ -59,8 +58,8 @@ fn main() { let maxf = max as f64; - println!("insert(): {:?} seconds\n", checkf); + println!("insert(): {} seconds\n", checkf); println!(" : {} op/sec\n", maxf/checkf); - println!("get() : {:?} seconds\n", appendf); + println!("get() : {} seconds\n", appendf); println!(" : {} op/sec\n", maxf/appendf); } diff --git a/src/test/compile-fail/block-coerce-no.rs b/src/test/compile-fail/block-coerce-no.rs index 5d58774f1d7..76af956a26f 100644 --- a/src/test/compile-fail/block-coerce-no.rs +++ b/src/test/compile-fail/block-coerce-no.rs @@ -11,8 +11,6 @@ // Make sure that fn-to-block coercion isn't incorrectly lifted over // other tycons. -extern crate debug; - fn coerce(b: ||) -> extern fn() { fn lol(f: extern fn(v: ||) -> extern fn(), g: ||) -> extern fn() { return f(g); } @@ -23,6 +21,6 @@ fn coerce(b: ||) -> extern fn() { fn main() { let i = 8i; - let f = coerce(|| println!("{:?}", i) ); + let f = coerce(|| println!("{}", i) ); f(); } diff --git a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs index 081dc61d9fc..10c63965a7b 100644 --- a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs +++ b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs @@ -10,8 +10,6 @@ #![feature(unsafe_destructor)] -extern crate debug; - struct defer<'a> { x: &'a [&'a str], } @@ -20,7 +18,7 @@ struct defer<'a> { impl<'a> Drop for defer<'a> { fn drop(&mut self) { unsafe { - println!("{:?}", self.x); + println!("{}", self.x); } } } diff --git a/src/test/compile-fail/borrowck-if-with-else.rs b/src/test/compile-fail/borrowck-if-with-else.rs index 74888cca2d4..e6d59062af2 100644 --- a/src/test/compile-fail/borrowck-if-with-else.rs +++ b/src/test/compile-fail/borrowck-if-with-else.rs @@ -8,9 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - -fn foo(x: int) { println!("{:?}", x); } +fn foo(x: int) { println!("{}", x); } fn main() { let x: int; diff --git a/src/test/compile-fail/borrowck-init-in-fn-expr.rs b/src/test/compile-fail/borrowck-init-in-fn-expr.rs index 83bfc754a6b..07e2ff08466 100644 --- a/src/test/compile-fail/borrowck-init-in-fn-expr.rs +++ b/src/test/compile-fail/borrowck-init-in-fn-expr.rs @@ -8,12 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn main() { let f: || -> int = || { let i: int; i //~ ERROR use of possibly uninitialized variable: `i` }; - println!("{:?}", f()); + println!("{}", f()); } diff --git a/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs b/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs index d3c6a280e8c..8d94b553f11 100644 --- a/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs +++ b/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs @@ -10,9 +10,7 @@ // Test that we do not permit moves from &[] matched by a vec pattern. -extern crate debug; - -#[deriving(Clone)] +#[deriving(Clone, Show)] struct Foo { string: String } @@ -37,7 +35,7 @@ pub fn main() { } } let z = tail[0].clone(); - println!("{:?}", z); + println!("{}", z); } _ => { unreachable!(); diff --git a/src/test/compile-fail/borrowck-mut-addr-of-imm-var.rs b/src/test/compile-fail/borrowck-mut-addr-of-imm-var.rs index 84b8b2c59e6..0c0377e7411 100644 --- a/src/test/compile-fail/borrowck-mut-addr-of-imm-var.rs +++ b/src/test/compile-fail/borrowck-mut-addr-of-imm-var.rs @@ -8,11 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn main() { let x: int = 3; let y: &mut int = &mut x; //~ ERROR cannot borrow *y = 5; - println!("{:?}", *y); + println!("{}", *y); } diff --git a/src/test/compile-fail/copy-a-resource.rs b/src/test/compile-fail/copy-a-resource.rs index ee2a183cbe1..67537464a33 100644 --- a/src/test/compile-fail/copy-a-resource.rs +++ b/src/test/compile-fail/copy-a-resource.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - +#[deriving(Show)] struct foo { i: int, } @@ -28,5 +27,5 @@ fn main() { let x = foo(10); let _y = x.clone(); //~^ ERROR does not implement any method in scope - println!("{:?}", x); + println!("{}", x); } diff --git a/src/test/compile-fail/if-without-else-result.rs b/src/test/compile-fail/if-without-else-result.rs index 0754d273a9b..89beb9a3160 100644 --- a/src/test/compile-fail/if-without-else-result.rs +++ b/src/test/compile-fail/if-without-else-result.rs @@ -8,10 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn main() { let a = if true { true }; //~^ ERROR if may be missing an else clause: expected `()`, found `bool` (expected (), found bool) - println!("{:?}", a); + println!("{}", a); } diff --git a/src/test/compile-fail/issue-1476.rs b/src/test/compile-fail/issue-1476.rs index 8526596acaa..01683d001ac 100644 --- a/src/test/compile-fail/issue-1476.rs +++ b/src/test/compile-fail/issue-1476.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn main() { - println!("{:?}", x); //~ ERROR unresolved name `x`. + println!("{}", x); //~ ERROR unresolved name `x`. } diff --git a/src/test/compile-fail/issue-2281-part1.rs b/src/test/compile-fail/issue-2281-part1.rs index 9d4a691d4f9..14096ca7bca 100644 --- a/src/test/compile-fail/issue-2281-part1.rs +++ b/src/test/compile-fail/issue-2281-part1.rs @@ -10,4 +10,4 @@ // error-pattern: unresolved name `foobar`. -fn main() { println!("{:?}", foobar); } +fn main() { println!("{}", foobar); } diff --git a/src/test/compile-fail/issue-2823.rs b/src/test/compile-fail/issue-2823.rs index 3d3a0740e44..b6820a1d8e4 100644 --- a/src/test/compile-fail/issue-2823.rs +++ b/src/test/compile-fail/issue-2823.rs @@ -8,15 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - struct C { x: int, } impl Drop for C { fn drop(&mut self) { - println!("dropping: {:?}", self.x); + println!("dropping: {}", self.x); } } diff --git a/src/test/compile-fail/issue-3038.rs b/src/test/compile-fail/issue-3038.rs index b13b037ef1a..049c6130d2d 100644 --- a/src/test/compile-fail/issue-3038.rs +++ b/src/test/compile-fail/issue-3038.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - enum f { g(int, int) } enum h { i(j, k) } @@ -21,13 +19,13 @@ fn main() { let _z = match g(1, 2) { - g(x, x) => { println!("{:?}", x + x); } + g(x, x) => { println!("{}", x + x); } //~^ ERROR identifier `x` is bound more than once in the same pattern }; let _z = match i(l(1, 2), m(3, 4)) { i(l(x, _), m(_, x)) //~ ERROR identifier `x` is bound more than once in the same pattern - => { println!("{:?}", x + x); } + => { println!("{}", x + x); } }; let _z = match (1, 2) { diff --git a/src/test/compile-fail/issue-3521.rs b/src/test/compile-fail/issue-3521.rs index 7b7cdd20851..2e0006bb1fe 100644 --- a/src/test/compile-fail/issue-3521.rs +++ b/src/test/compile-fail/issue-3521.rs @@ -8,14 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn main() { let foo = 100; + #[deriving(Show)] enum Stuff { Bar = foo //~ ERROR attempt to use a non-constant value in a constant } - println!("{:?}", Bar); + println!("{}", Bar); } diff --git a/src/test/compile-fail/issue-5062.rs b/src/test/compile-fail/issue-5062.rs index df888fe7802..5082c3102dd 100644 --- a/src/test/compile-fail/issue-5062.rs +++ b/src/test/compile-fail/issue-5062.rs @@ -8,7 +8,5 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - -fn main() { format!("{:?}", None); } +fn main() { format!("{}", None); } //~^ ERROR type annotations required diff --git a/src/test/compile-fail/issue-6458-2.rs b/src/test/compile-fail/issue-6458-2.rs index 94884c133b7..07c1686a7ac 100644 --- a/src/test/compile-fail/issue-6458-2.rs +++ b/src/test/compile-fail/issue-6458-2.rs @@ -8,10 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn main() { // Unconstrained type: - format!("{:?}", None); + format!("{}", None); //~^ ERROR type annotations required } diff --git a/src/test/compile-fail/liveness-closure-require-ret.rs b/src/test/compile-fail/liveness-closure-require-ret.rs index 65856c5250c..6466310eb4d 100644 --- a/src/test/compile-fail/liveness-closure-require-ret.rs +++ b/src/test/compile-fail/liveness-closure-require-ret.rs @@ -8,7 +8,5 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn force(f: || -> int) -> int { f() } -fn main() { println!("{:?}", force(|| {})); } //~ ERROR mismatched types +fn main() { println!("{}", force(|| {})); } //~ ERROR mismatched types diff --git a/src/test/compile-fail/liveness-move-in-loop.rs b/src/test/compile-fail/liveness-move-in-loop.rs index 270142c6378..127a68bd339 100644 --- a/src/test/compile-fail/liveness-move-in-loop.rs +++ b/src/test/compile-fail/liveness-move-in-loop.rs @@ -8,13 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn main() { let y: Box = box 42; let mut x: Box; loop { - println!("{:?}", y); + println!("{}", y); loop { loop { loop { diff --git a/src/test/compile-fail/liveness-move-in-while.rs b/src/test/compile-fail/liveness-move-in-while.rs index f40b866214d..2cebe3f573b 100644 --- a/src/test/compile-fail/liveness-move-in-while.rs +++ b/src/test/compile-fail/liveness-move-in-while.rs @@ -8,13 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn main() { let y: Box = box 42; let mut x: Box; loop { - println!("{:?}", y); //~ ERROR use of moved value: `y` + println!("{}", y); //~ ERROR use of moved value: `y` while true { while true { while true { x = y; x.clone(); } } } //~^ ERROR use of moved value: `y` } diff --git a/src/test/compile-fail/liveness-use-after-move.rs b/src/test/compile-fail/liveness-use-after-move.rs index cd7401a65ae..a988254141a 100644 --- a/src/test/compile-fail/liveness-use-after-move.rs +++ b/src/test/compile-fail/liveness-use-after-move.rs @@ -8,11 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn main() { let x = box 5i; let y = x; - println!("{:?}", *x); //~ ERROR use of moved value: `*x` + println!("{}", *x); //~ ERROR use of moved value: `*x` y.clone(); } diff --git a/src/test/compile-fail/liveness-use-after-send.rs b/src/test/compile-fail/liveness-use-after-send.rs index 6a2a1e7dec5..54d0b2d00c7 100644 --- a/src/test/compile-fail/liveness-use-after-send.rs +++ b/src/test/compile-fail/liveness-use-after-send.rs @@ -8,21 +8,20 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - -fn send(ch: _chan, data: T) { - println!("{:?}", ch); - println!("{:?}", data); +fn send(ch: _chan, data: T) { + println!("{}", ch); + println!("{}", data); fail!(); } +#[deriving(Show)] struct _chan(int); // Tests that "log(debug, message);" is flagged as using // message after the send deinitializes it fn test00_start(ch: _chan>, message: Box, _count: Box) { send(ch, message); - println!("{:?}", message); //~ ERROR use of moved value: `message` + println!("{}", message); //~ ERROR use of moved value: `message` } fn main() { fail!(); } diff --git a/src/test/compile-fail/match-join.rs b/src/test/compile-fail/match-join.rs index c16d85cd73e..de44a005fc3 100644 --- a/src/test/compile-fail/match-join.rs +++ b/src/test/compile-fail/match-join.rs @@ -11,13 +11,11 @@ // a good test that we merge paths correctly in the presence of a // variable that's used before it's declared -extern crate debug; - fn my_fail() -> ! { fail!(); } fn main() { match true { false => { my_fail(); } true => { } } - println!("{:?}", x); //~ ERROR unresolved name `x`. + println!("{}", x); //~ ERROR unresolved name `x`. let x: int; } diff --git a/src/test/compile-fail/moves-based-on-type-access-to-field.rs b/src/test/compile-fail/moves-based-on-type-access-to-field.rs index 6214466cd49..85723936997 100644 --- a/src/test/compile-fail/moves-based-on-type-access-to-field.rs +++ b/src/test/compile-fail/moves-based-on-type-access-to-field.rs @@ -11,8 +11,6 @@ // Tests that if you move from `x.f` or `x[0]`, `x` is inaccessible. // Also tests that we give a more specific error message. -extern crate debug; - struct Foo { f: String, y: int } fn consume(_s: String) {} fn touch(_a: &A) {} diff --git a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs b/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs index aded89e5820..ff5ad2c5e19 100644 --- a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs +++ b/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs @@ -12,8 +12,6 @@ // bound must be noncopyable. For details see // http://smallcultfollowing.com/babysteps/blog/2013/04/30/the-case-of-the-recurring-closure/ -extern crate debug; - struct R<'a> { // This struct is needed to create the // otherwise infinite type of a fn that @@ -31,7 +29,7 @@ fn innocent_looking_victim() { Some(ref msg) => { (f.c)(f, true); //~^ ERROR: cannot borrow `*f` as mutable because - println!("{:?}", msg); + println!("{}", msg); }, None => fail!("oops"), } diff --git a/src/test/compile-fail/noncopyable-class.rs b/src/test/compile-fail/noncopyable-class.rs index 8594e7ca625..bf762eaa80f 100644 --- a/src/test/compile-fail/noncopyable-class.rs +++ b/src/test/compile-fail/noncopyable-class.rs @@ -11,8 +11,7 @@ // Test that a class with a non-copyable field can't be // copied -extern crate debug; - +#[deriving(Show)] struct bar { x: int, } @@ -27,6 +26,7 @@ fn bar(x:int) -> bar { } } +#[deriving(Show)] struct foo { i: int, j: bar, @@ -42,5 +42,5 @@ fn foo(i:int) -> foo { fn main() { let x = foo(10); let _y = x.clone(); //~ ERROR does not implement any method in scope - println!("{:?}", x); + println!("{}", x); } diff --git a/src/test/compile-fail/nonscalar-cast.rs b/src/test/compile-fail/nonscalar-cast.rs index 97a514e1584..346661e3c1f 100644 --- a/src/test/compile-fail/nonscalar-cast.rs +++ b/src/test/compile-fail/nonscalar-cast.rs @@ -10,12 +10,11 @@ // error-pattern:non-scalar cast -extern crate debug; - +#[deriving(Show)] struct foo { - x:int + x: int } fn main() { - println!("{:?}", foo{ x: 1 } as int); + println!("{}", foo{ x: 1 } as int); } diff --git a/src/test/compile-fail/packed-struct-generic-transmute.rs b/src/test/compile-fail/packed-struct-generic-transmute.rs index 7a1ff574488..d699f69864e 100644 --- a/src/test/compile-fail/packed-struct-generic-transmute.rs +++ b/src/test/compile-fail/packed-struct-generic-transmute.rs @@ -15,7 +15,7 @@ // error-pattern: transmute called on types with different size -extern crate debug; +#![feature(slicing_syntax)] use std::mem; @@ -34,6 +34,6 @@ fn main() { let foo = Foo { bar: [1u8, 2, 3, 4, 5], baz: 10i32 }; unsafe { let oof: Oof<[u8, .. 5], i32> = mem::transmute(foo); - println!("{:?}", oof); + println!("{} {}", oof.rab[], oof.zab); } } diff --git a/src/test/compile-fail/packed-struct-transmute.rs b/src/test/compile-fail/packed-struct-transmute.rs index f92cc4b1344..9c8e8193319 100644 --- a/src/test/compile-fail/packed-struct-transmute.rs +++ b/src/test/compile-fail/packed-struct-transmute.rs @@ -15,8 +15,6 @@ // error-pattern: transmute called on types with different size -extern crate debug; - use std::mem; #[repr(packed)] @@ -25,6 +23,7 @@ struct Foo { baz: uint } +#[deriving(Show)] struct Oof { rab: u8, zab: uint @@ -34,6 +33,6 @@ fn main() { let foo = Foo { bar: 1, baz: 10 }; unsafe { let oof: Oof = mem::transmute(foo); - println!("{:?}", oof); + println!("{}", oof); } } diff --git a/src/test/compile-fail/pattern-tyvar.rs b/src/test/compile-fail/pattern-tyvar.rs index 83f2ef250dc..efb98a74538 100644 --- a/src/test/compile-fail/pattern-tyvar.rs +++ b/src/test/compile-fail/pattern-tyvar.rs @@ -10,14 +10,12 @@ // error-pattern: mismatched types -extern crate debug; - enum bar { t1((), Option >), t2, } fn foo(t: bar) { match t { t1(_, Some::(x)) => { - println!("{:?}", x); + println!("{}", x); } _ => { fail!(); } } diff --git a/src/test/compile-fail/str-idx.rs b/src/test/compile-fail/str-idx.rs index 25e4c90e774..424ffed989b 100644 --- a/src/test/compile-fail/str-idx.rs +++ b/src/test/compile-fail/str-idx.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - pub fn main() { let s: &str = "hello"; let c: u8 = s[4]; //~ ERROR cannot index a value of type `&str` diff --git a/src/test/compile-fail/unique-pinned-nocopy.rs b/src/test/compile-fail/unique-pinned-nocopy.rs index 940ca765828..c812b0d96a2 100644 --- a/src/test/compile-fail/unique-pinned-nocopy.rs +++ b/src/test/compile-fail/unique-pinned-nocopy.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - +#[deriving(Show)] struct r { b: bool, } @@ -21,5 +20,5 @@ impl Drop for r { fn main() { let i = box r { b: true }; let _j = i.clone(); //~ ERROR not implemented - println!("{:?}", i); + println!("{}", i); } diff --git a/src/test/compile-fail/unsupported-cast.rs b/src/test/compile-fail/unsupported-cast.rs index 1fdba7d8b66..205c912f5a0 100644 --- a/src/test/compile-fail/unsupported-cast.rs +++ b/src/test/compile-fail/unsupported-cast.rs @@ -14,5 +14,5 @@ extern crate libc; fn main() { - println!("{:?}", 1.0 as *libc::FILE); // Can't cast float to foreign. + println!("{}", 1.0 as *libc::FILE); // Can't cast float to foreign. } diff --git a/src/test/run-fail/result-get-fail.rs b/src/test/run-fail/result-get-fail.rs index 216cf7211f6..6098b97c79a 100644 --- a/src/test/run-fail/result-get-fail.rs +++ b/src/test/run-fail/result-get-fail.rs @@ -10,10 +10,8 @@ // error-pattern:called `Result::unwrap()` on an `Err` value -extern crate debug; - use std::result; fn main() { - println!("{:?}", result::Err::("kitty".to_string()).unwrap()); + println!("{}", result::Err::("kitty".to_string()).unwrap()); } diff --git a/src/test/run-pass/alignment-gep-tup-like-1.rs b/src/test/run-pass/alignment-gep-tup-like-1.rs index 6e67b3f6add..ecc1a6a495c 100644 --- a/src/test/run-pass/alignment-gep-tup-like-1.rs +++ b/src/test/run-pass/alignment-gep-tup-like-1.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - struct pair { a: A, b: B } @@ -38,7 +36,7 @@ fn f(a: A, b: u16) -> Box+'static> { pub fn main() { let (a, b) = f(22_u64, 44u16).f(); - println!("a={:?} b={:?}", a, b); + println!("a={} b={}", a, b); assert_eq!(a, 22u64); assert_eq!(b, 44u16); } diff --git a/src/test/run-pass/auto-instantiate.rs b/src/test/run-pass/auto-instantiate.rs index 5167764dd28..6195c259414 100644 --- a/src/test/run-pass/auto-instantiate.rs +++ b/src/test/run-pass/auto-instantiate.rs @@ -8,14 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - +#[deriving(Show)] struct Pair { a: T, b: U } struct Triple { x: int, y: int, z: int } fn f(x: T, y: U) -> Pair { return Pair {a: x, b: y}; } pub fn main() { - println!("{:?}", f(Triple {x: 3, y: 4, z: 5}, 4i).a.x); - println!("{:?}", f(5i, 6i).a); + println!("{}", f(Triple {x: 3, y: 4, z: 5}, 4i).a.x); + println!("{}", f(5i, 6i).a); } diff --git a/src/test/run-pass/block-arg.rs b/src/test/run-pass/block-arg.rs index 59786e993f2..4b81654a1d0 100644 --- a/src/test/run-pass/block-arg.rs +++ b/src/test/run-pass/block-arg.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn inty(fun: proc(int) -> int) -> int { fun(100) } @@ -24,7 +22,7 @@ pub fn main() { // Statement form does not require parentheses: for i in v.iter() { - println!("{:?}", *i); + println!("{}", *i); } } diff --git a/src/test/run-pass/block-iter-1.rs b/src/test/run-pass/block-iter-1.rs index dee013a9140..ce20c3024d6 100644 --- a/src/test/run-pass/block-iter-1.rs +++ b/src/test/run-pass/block-iter-1.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn iter_vec(v: Vec , f: |&T|) { for x in v.iter() { f(x); } } pub fn main() { @@ -20,6 +18,6 @@ pub fn main() { odds += 1; } }); - println!("{:?}", odds); + println!("{}", odds); assert_eq!(odds, 4); } diff --git a/src/test/run-pass/block-iter-2.rs b/src/test/run-pass/block-iter-2.rs index 82b162ba4bc..7bb9d0ddf99 100644 --- a/src/test/run-pass/block-iter-2.rs +++ b/src/test/run-pass/block-iter-2.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn iter_vec(v: Vec , f: |&T|) { for x in v.iter() { f(x); } } pub fn main() { @@ -20,6 +18,6 @@ pub fn main() { sum += *i * *j; }); }); - println!("{:?}", sum); + println!("{}", sum); assert_eq!(sum, 225); } diff --git a/src/test/run-pass/borrowck-mut-uniq.rs b/src/test/run-pass/borrowck-mut-uniq.rs index 993ce37a1ec..867fdd531e9 100644 --- a/src/test/run-pass/borrowck-mut-uniq.rs +++ b/src/test/run-pass/borrowck-mut-uniq.rs @@ -8,10 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - use std::mem::swap; +#[deriving(Show)] struct Ints {sum: Box, values: Vec } fn add_int(x: &mut Ints, v: int) { @@ -37,5 +36,5 @@ pub fn main() { true }); - println!("ints={:?}", ints); + println!("ints={}", ints); } diff --git a/src/test/run-pass/close-over-big-then-small-data.rs b/src/test/run-pass/close-over-big-then-small-data.rs index 69878d4a06b..375767c8f51 100644 --- a/src/test/run-pass/close-over-big-then-small-data.rs +++ b/src/test/run-pass/close-over-big-then-small-data.rs @@ -12,8 +12,6 @@ // storing closure data (as we used to do), the u64 would // overwrite the u16. -extern crate debug; - struct Pair { a: A, b: B } @@ -42,7 +40,7 @@ fn f(a: A, b: u16) -> Box+'static> { pub fn main() { let (a, b) = f(22_u64, 44u16).f(); - println!("a={:?} b={:?}", a, b); + println!("a={} b={}", a, b); assert_eq!(a, 22u64); assert_eq!(b, 44u16); } diff --git a/src/test/run-pass/comm.rs b/src/test/run-pass/comm.rs index 7f5454405df..18cc92f335d 100644 --- a/src/test/run-pass/comm.rs +++ b/src/test/run-pass/comm.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - use std::task; pub fn main() { @@ -17,7 +15,7 @@ pub fn main() { let _t = task::spawn(proc() { child(&tx) }); let y = rx.recv(); println!("received"); - println!("{:?}", y); + println!("{}", y); assert_eq!(y, 10); } diff --git a/src/test/run-pass/conditional-debug-macro-off.rs b/src/test/run-pass/conditional-debug-macro-off.rs index b7c4ccb3c2a..29d329d46a0 100644 --- a/src/test/run-pass/conditional-debug-macro-off.rs +++ b/src/test/run-pass/conditional-debug-macro-off.rs @@ -14,9 +14,8 @@ #![feature(phase)] #[phase(plugin, link)] extern crate log; -extern crate debug; pub fn main() { // only fails if println! evaluates its argument. - debug!("{:?}", { if true { fail!() } }); + debug!("{}", { if true { fail!() } }); } diff --git a/src/test/run-pass/conditional-debug-macro-on.rs b/src/test/run-pass/conditional-debug-macro-on.rs index 399a145468d..9d09740f3b4 100644 --- a/src/test/run-pass/conditional-debug-macro-on.rs +++ b/src/test/run-pass/conditional-debug-macro-on.rs @@ -10,12 +10,10 @@ // exec-env:RUST_LOG=conditional-debug-macro-on=4 -extern crate debug; - pub fn main() { // exits early if println! evaluates its arguments, otherwise it // will hit the fail. - println!("{:?}", { if true { return; } }); + println!("{}", { if true { return; } }); fail!(); } diff --git a/src/test/run-pass/const-fields-and-indexing.rs b/src/test/run-pass/const-fields-and-indexing.rs index fc098ff9357..49b244a162b 100644 --- a/src/test/run-pass/const-fields-and-indexing.rs +++ b/src/test/run-pass/const-fields-and-indexing.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - const x : [int, ..4] = [1,2,3,4]; static p : int = x[2]; const y : &'static [int] = &[1,2,3,4]; @@ -27,9 +25,9 @@ const k : K = K {a: 10, b: 20, c: D {d: 30, e: 40}}; static m : int = k.c.e; pub fn main() { - println!("{:?}", p); - println!("{:?}", q); - println!("{:?}", t); + println!("{}", p); + println!("{}", q); + println!("{}", t); assert_eq!(p, 3); assert_eq!(q, 3); assert_eq!(t, 20); diff --git a/src/test/run-pass/const-vecs-and-slices.rs b/src/test/run-pass/const-vecs-and-slices.rs index 43e4950a244..c61f26e0bb6 100644 --- a/src/test/run-pass/const-vecs-and-slices.rs +++ b/src/test/run-pass/const-vecs-and-slices.rs @@ -8,18 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - static x : [int, ..4] = [1,2,3,4]; static y : &'static [int] = &[1,2,3,4]; static z : &'static [int, ..4] = &[1,2,3,4]; static zz : &'static [int] = [1,2,3,4]; pub fn main() { - println!("{:?}", x[1]); - println!("{:?}", y[1]); - println!("{:?}", z[1]); - println!("{:?}", zz[1]); + println!("{}", x[1]); + println!("{}", y[1]); + println!("{}", z[1]); + println!("{}", zz[1]); assert_eq!(x[1], 2); assert_eq!(x[3], 4); assert_eq!(x[3], y[3]); diff --git a/src/test/run-pass/dst-struct-reflect.rs b/src/test/run-pass/dst-struct-reflect.rs deleted file mode 100644 index 2028ebf64c2..00000000000 --- a/src/test/run-pass/dst-struct-reflect.rs +++ /dev/null @@ -1,61 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// FIXME(15049) Re-enable this test. -// ignore-test -// Test that structs with unsized fields work with {:?} reflection. - -extern crate debug; - -struct Fat { - f1: int, - f2: &'static str, - ptr: T -} - -// x is a fat pointer -fn reflect(x: &Fat<[int]>, cmp: &str) { - // Don't test this result because reflecting unsized fields is undefined for now. - let _s = format!("{:?}", x); - let s = format!("{:?}", &x.ptr); - assert!(s == cmp.to_string()) - - println!("{:?}", x); - println!("{:?}", &x.ptr); -} - -fn reflect_0(x: &Fat<[int]>) { - let _s = format!("{:?}", x.ptr[0]); - println!("{:?}", x.ptr[0]); -} - -pub fn main() { - // With a vec of ints. - let f1 = Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }; - reflect(&f1, "&[1, 2, 3]"); - reflect_0(&f1); - let f2 = &f1; - reflect(f2, "&[1, 2, 3]"); - reflect_0(f2); - let f3: &Fat<[int]> = f2; - reflect(f3, "&[1, 2, 3]"); - reflect_0(f3); - let f4: &Fat<[int]> = &f1; - reflect(f4, "&[1, 2, 3]"); - reflect_0(f4); - let f5: &Fat<[int]> = &Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }; - reflect(f5, "&[1, 2, 3]"); - reflect_0(f5); - - // Zero size vec. - let f5: &Fat<[int]> = &Fat { f1: 5, f2: "some str", ptr: [] }; - reflect(f5, "&[]"); -} - diff --git a/src/test/run-pass/enum-discrim-width-stuff.rs b/src/test/run-pass/enum-discrim-width-stuff.rs index ccbc5d12191..e0799168140 100644 --- a/src/test/run-pass/enum-discrim-width-stuff.rs +++ b/src/test/run-pass/enum-discrim-width-stuff.rs @@ -10,12 +10,11 @@ #![feature(macro_rules)] -extern crate debug; - macro_rules! check { ($m:ident, $t:ty, $v:expr) => {{ mod $m { use std::mem::size_of; + #[deriving(Show)] enum E { V = $v, A = 0 @@ -25,8 +24,8 @@ macro_rules! check { assert_eq!(size_of::(), size_of::<$t>()); assert_eq!(V as $t, $v as $t); assert_eq!(C as $t, $v as $t); - assert_eq!(format!("{:?}", V), "V".to_string()); - assert_eq!(format!("{:?}", C), "V".to_string()); + assert_eq!(format!("{}", V), "V".to_string()); + assert_eq!(format!("{}", C), "V".to_string()); } } $m::check(); diff --git a/src/test/run-pass/evec-slice.rs b/src/test/run-pass/evec-slice.rs index 4a112f145c3..ab6576b9b42 100644 --- a/src/test/run-pass/evec-slice.rs +++ b/src/test/run-pass/evec-slice.rs @@ -10,8 +10,6 @@ #![allow(dead_assignment)] -extern crate debug; - pub fn main() { let x : &[int] = &[1,2,3,4,5]; let mut z : &[int] = &[1,2,3,4,5]; @@ -24,7 +22,7 @@ pub fn main() { let c : &[int] = &[2,2,2,2,3]; let cc : &[int] = &[2,2,2,2,2,2]; - println!("{:?}", a); + println!("{}", a); assert!(a < b); assert!(a <= b); @@ -32,7 +30,7 @@ pub fn main() { assert!(b >= a); assert!(b > a); - println!("{:?}", b); + println!("{}", b); assert!(b < c); assert!(b <= c); @@ -46,7 +44,7 @@ pub fn main() { assert!(c >= a); assert!(c > a); - println!("{:?}", c); + println!("{}", c); assert!(a < cc); assert!(a <= cc); @@ -54,5 +52,5 @@ pub fn main() { assert!(cc >= a); assert!(cc > a); - println!("{:?}", cc); + println!("{}", cc); } diff --git a/src/test/run-pass/fixed_length_vec_glue.rs b/src/test/run-pass/fixed_length_vec_glue.rs deleted file mode 100644 index 3b7c5083bb4..00000000000 --- a/src/test/run-pass/fixed_length_vec_glue.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate debug; - -use debug::repr; - -struct Struc { a: u8, b: [int, ..3], c: int } - -pub fn main() { - let arr = [1,2,3]; - let struc = Struc {a: 13u8, b: arr, c: 42}; - let s = repr::repr_to_string(&struc); - assert_eq!(s, "Struc{a: 13u8, b: [1, 2, 3], c: 42}".to_string()); -} diff --git a/src/test/run-pass/float.rs b/src/test/run-pass/float.rs index f2a41b4f09e..22d54162c43 100644 --- a/src/test/run-pass/float.rs +++ b/src/test/run-pass/float.rs @@ -8,11 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - pub fn main() { let pi = 3.1415927f64; - println!("{:?}", -pi * (pi + 2.0 / pi) - pi * 5.0); + println!("{}", -pi * (pi + 2.0 / pi) - pi * 5.0); if pi == 5.0 || pi < 10.0 || pi <= 2.0 || pi != 22.0 / 7.0 || pi >= 10.0 || pi > 1.0 { println!("yes"); diff --git a/src/test/run-pass/format-ref-cell.rs b/src/test/run-pass/format-ref-cell.rs index 3267ca06171..2122759b3d3 100644 --- a/src/test/run-pass/format-ref-cell.rs +++ b/src/test/run-pass/format-ref-cell.rs @@ -8,13 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - use std::cell::RefCell; pub fn main() { let name = RefCell::new("rust"); let what = RefCell::new("rocks"); - let msg = format!("{name:?} {:?}", &*what.borrow(), name=&*name.borrow()); - assert_eq!(msg, "&\"rust\" &\"rocks\"".to_string()); + let msg = format!("{name} {}", &*what.borrow(), name=&*name.borrow()); + assert_eq!(msg, "rust rocks".to_string()); } diff --git a/src/test/run-pass/functional-struct-upd.rs b/src/test/run-pass/functional-struct-upd.rs index 215de30535d..a8d0c7d44fd 100644 --- a/src/test/run-pass/functional-struct-upd.rs +++ b/src/test/run-pass/functional-struct-upd.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - +#[deriving(Show)] struct Foo { x: int, y: int @@ -18,5 +17,5 @@ struct Foo { pub fn main() { let a = Foo { x: 1, y: 2 }; let c = Foo { x: 4, .. a}; - println!("{:?}", c); + println!("{}", c); } diff --git a/src/test/run-pass/generic-alias-unique.rs b/src/test/run-pass/generic-alias-unique.rs index f9d05458261..8b5dfb6cf75 100644 --- a/src/test/run-pass/generic-alias-unique.rs +++ b/src/test/run-pass/generic-alias-unique.rs @@ -8,13 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn id(t: T) -> T { return t; } pub fn main() { let expected = box 100i; let actual = id::>(expected.clone()); - println!("{:?}", *actual); + println!("{}", *actual); assert_eq!(*expected, *actual); } diff --git a/src/test/run-pass/generic-derived-type.rs b/src/test/run-pass/generic-derived-type.rs index 09a53f86f2d..177455515dd 100644 --- a/src/test/run-pass/generic-derived-type.rs +++ b/src/test/run-pass/generic-derived-type.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn g(x: X) -> X { return x; } #[deriving(Clone)] @@ -25,8 +23,8 @@ fn f(t: T) -> Pair { pub fn main() { let b = f::(10); - println!("{:?}" ,b.a); - println!("{:?}", b.b); + println!("{}" ,b.a); + println!("{}", b.b); assert_eq!(b.a, 10); assert_eq!(b.b, 10); } diff --git a/src/test/run-pass/generic-fn-unique.rs b/src/test/run-pass/generic-fn-unique.rs index 14991ca3ba6..e1a8ad7c20a 100644 --- a/src/test/run-pass/generic-fn-unique.rs +++ b/src/test/run-pass/generic-fn-unique.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn f(x: Box) -> Box { return x; } -pub fn main() { let x = f(box 3i); println!("{:?}", *x); } +pub fn main() { let x = f(box 3i); println!("{}", *x); } diff --git a/src/test/run-pass/generic-tag-values.rs b/src/test/run-pass/generic-tag-values.rs index e3ed380c37e..26b9afcea8f 100644 --- a/src/test/run-pass/generic-tag-values.rs +++ b/src/test/run-pass/generic-tag-values.rs @@ -8,20 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - enum noption { some(T), } struct Pair { x: int, y: int } pub fn main() { let nop: noption = some::(5); - match nop { some::(n) => { println!("{:?}", n); assert!((n == 5)); } } + match nop { some::(n) => { println!("{}", n); assert!((n == 5)); } } let nop2: noption = some(Pair{x: 17, y: 42}); match nop2 { some(t) => { - println!("{:?}", t.x); - println!("{:?}", t.y); + println!("{}", t.x); + println!("{}", t.y); assert_eq!(t.x, 17); assert_eq!(t.y, 42); } diff --git a/src/test/run-pass/generic-tup.rs b/src/test/run-pass/generic-tup.rs index 2f41cac6258..dc9a90f7025 100644 --- a/src/test/run-pass/generic-tup.rs +++ b/src/test/run-pass/generic-tup.rs @@ -8,12 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn get_third(t: (T, T, T)) -> T { let (_, _, x) = t; return x; } pub fn main() { - println!("{:?}", get_third((1i, 2i, 3i))); + println!("{}", get_third((1i, 2i, 3i))); assert_eq!(get_third((1i, 2i, 3i)), 3); assert_eq!(get_third((5u8, 6u8, 7u8)), 7u8); } diff --git a/src/test/run-pass/getopts_ref.rs b/src/test/run-pass/getopts_ref.rs index 98a7b67e0dc..afa4b7a1ad0 100644 --- a/src/test/run-pass/getopts_ref.rs +++ b/src/test/run-pass/getopts_ref.rs @@ -9,7 +9,6 @@ // except according to those terms. extern crate getopts; -extern crate debug; use getopts::{optopt, getopts}; diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index f733fc1eb8f..8ff89ae2cde 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -11,7 +11,6 @@ extern crate collections; -extern crate debug; /** A somewhat reduced test case to expose some Valgrind issues. @@ -56,7 +55,7 @@ mod map_reduce { ctrl.send(find_reducer(Vec::from_slice(key.as_bytes()), tx)); println!("receiving"); let c = rx.recv(); - println!("{:?}", c); + println!("{}", c); im.insert(key, c); } diff --git a/src/test/run-pass/if-bot.rs b/src/test/run-pass/if-bot.rs index c5193b2aa6f..bfe3e9beddc 100644 --- a/src/test/run-pass/if-bot.rs +++ b/src/test/run-pass/if-bot.rs @@ -8,9 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - pub fn main() { let i: int = if false { fail!() } else { 5 }; - println!("{:?}", i); + println!("{}", i); } diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index 365070f704f..b384d7c5583 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -15,8 +15,6 @@ #![deny(warnings)] #![allow(unused_must_use)] -extern crate debug; - use std::fmt; use std::io::MemWriter; use std::io; @@ -45,11 +43,6 @@ impl fmt::Show for C { macro_rules! t(($a:expr, $b:expr) => { assert_eq!($a.as_slice(), $b) }) pub fn main() { - // Make sure there's a poly formatter that takes anything - t!(format!("{:?}", 1i), "1"); - t!(format!("{:?}", A), "A"); - t!(format!("{:?}", ()), "()"); - // Various edge cases without formats t!(format!(""), ""); t!(format!("hello"), "hello"); @@ -148,8 +141,8 @@ pub fn main() { // make sure that format! doesn't move out of local variables let a = box 3i; - format!("{:?}", a); - format!("{:?}", a); + format!("{}", a); + format!("{}", a); // make sure that format! doesn't cause spurious unused-unsafe warnings when // it's inside of an outer unsafe block @@ -186,7 +179,7 @@ fn test_write() { // can do with them just yet (to test the output) fn test_print() { print!("hi"); - print!("{:?}", vec!(0u8)); + print!("{}", vec!(0u8)); println!("hello"); println!("this is a {}", "test"); println!("{foo}", foo="bar"); diff --git a/src/test/run-pass/import.rs b/src/test/run-pass/import.rs index cf825bbbcea..3470b54ccbb 100644 --- a/src/test/run-pass/import.rs +++ b/src/test/run-pass/import.rs @@ -8,10 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - mod foo { - pub fn x(y: int) { println!("{:?}", y); } + pub fn x(y: int) { println!("{}", y); } } mod bar { diff --git a/src/test/run-pass/issue-13434.rs b/src/test/run-pass/issue-13434.rs index 25b53bb3a53..ac7a55ee405 100644 --- a/src/test/run-pass/issue-13434.rs +++ b/src/test/run-pass/issue-13434.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - +#[deriving(Show)] struct MyStruct; trait Repro { @@ -27,5 +26,5 @@ fn do_stuff(r: R) -> String { } pub fn main() { - assert_eq!("MyStruct".to_string(), do_stuff(|s: MyStruct| format!("{:?}", s))); + assert_eq!("MyStruct".to_string(), do_stuff(|s: MyStruct| format!("{}", s))); } diff --git a/src/test/run-pass/issue-1696.rs b/src/test/run-pass/issue-1696.rs index 291fab29584..e69738d4caa 100644 --- a/src/test/run-pass/issue-1696.rs +++ b/src/test/run-pass/issue-1696.rs @@ -9,12 +9,11 @@ // except according to those terms. extern crate collections; -extern crate debug; use std::collections::HashMap; pub fn main() { let mut m = HashMap::new(); m.insert(b"foo".to_vec(), b"bar".to_vec()); - println!("{:?}", m); + println!("{}", m); } diff --git a/src/test/run-pass/issue-17737.rs b/src/test/run-pass/issue-17737.rs deleted file mode 100644 index ec0cb488c68..00000000000 --- a/src/test/run-pass/issue-17737.rs +++ /dev/null @@ -1,24 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(unboxed_closures)] - -// Test generating type visitor glue for unboxed closures - -extern crate debug; - -fn main() { - let expected = "fn(); fn(uint, uint) -> uint; fn() -> !"; - let result = format!("{:?}; {:?}; {:?}", - |:| {}, - |&: x: uint, y: uint| { x + y }, - |&mut:| -> ! { fail!() }); - assert_eq!(expected, result.as_slice()); -} diff --git a/src/test/run-pass/issue-2216.rs b/src/test/run-pass/issue-2216.rs index d9d4120d4f4..98e6e051343 100644 --- a/src/test/run-pass/issue-2216.rs +++ b/src/test/run-pass/issue-2216.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - pub fn main() { let mut x = 0i; @@ -29,6 +27,6 @@ pub fn main() { break; } - println!("{:?}", x); + println!("{}", x); assert_eq!(x, 42); } diff --git a/src/test/run-pass/issue-2804-2.rs b/src/test/run-pass/issue-2804-2.rs index 4b6b3ef8136..32fefac52eb 100644 --- a/src/test/run-pass/issue-2804-2.rs +++ b/src/test/run-pass/issue-2804-2.rs @@ -13,12 +13,11 @@ // clobber the previous node ID in a macro expr extern crate collections; -extern crate debug; use std::collections::HashMap; fn add_interfaces(managed_ip: String, device: HashMap) { - println!("{}, {:?}", managed_ip, device.get(&"interfaces".to_string())); + println!("{}, {}", managed_ip, device.get(&"interfaces".to_string())); } pub fn main() {} diff --git a/src/test/run-pass/issue-2804.rs b/src/test/run-pass/issue-2804.rs index b160fa34c91..7228f12c030 100644 --- a/src/test/run-pass/issue-2804.rs +++ b/src/test/run-pass/issue-2804.rs @@ -11,7 +11,6 @@ extern crate collections; extern crate serialize; -extern crate debug; use std::collections::HashMap; use serialize::json; @@ -29,7 +28,7 @@ fn lookup(table: json::JsonObject, key: String, default: String) -> String s.to_string() } option::Some(value) => { - println!("{} was expected to be a string but is a {:?}", key, value); + println!("{} was expected to be a string but is a {}", key, value); default } option::None => { @@ -50,7 +49,7 @@ fn add_interface(_store: int, managed_ip: String, data: json::Json) -> (String, (label, bool_value(false)) } _ => { - println!("Expected dict for {} interfaces, found {:?}", managed_ip, data); + println!("Expected dict for {} interfaces, found {}", managed_ip, data); ("gnos:missing-interface".to_string(), bool_value(true)) } } @@ -68,7 +67,7 @@ fn add_interfaces(store: int, managed_ip: String, device: HashMap { - println!("Expected list for {} interfaces, found {:?}", managed_ip, + println!("Expected list for {} interfaces, found {}", managed_ip, device.get(&"interfaces".to_string())); Vec::new() } diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs index 89552d73d7e..01bfdddd285 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -10,8 +10,6 @@ // except according to those terms. -extern crate debug; - /// Map representation use std::io; @@ -54,7 +52,7 @@ fn square_from_char(c: char) -> square { '.' => { earth } ' ' => { empty } _ => { - println!("invalid square: {:?}", c); + println!("invalid square: {}", c); fail!() } } diff --git a/src/test/run-pass/issue-3109.rs b/src/test/run-pass/issue-3109.rs index cef42966889..86913c0e8d4 100644 --- a/src/test/run-pass/issue-3109.rs +++ b/src/test/run-pass/issue-3109.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - pub fn main() { - println!("{:?}", ("hi there!", "you")); + println!("{}", ("hi there!", "you")); } diff --git a/src/test/run-pass/issue-3794.rs b/src/test/run-pass/issue-3794.rs index 54225bbe01e..f32564e8b75 100644 --- a/src/test/run-pass/issue-3794.rs +++ b/src/test/run-pass/issue-3794.rs @@ -8,19 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - trait T { fn print(&self); } +#[deriving(Show)] struct S { s: int, } impl T for S { fn print(&self) { - println!("{:?}", self); + println!("{}", self); } } diff --git a/src/test/run-pass/issue-4241.rs b/src/test/run-pass/issue-4241.rs index 15423121fda..d8c08f8ac32 100644 --- a/src/test/run-pass/issue-4241.rs +++ b/src/test/run-pass/issue-4241.rs @@ -119,7 +119,7 @@ fn query2(cmd: ~[String]) -> Result { let _cmd = cmd_to_string(cmd); io::with_str_reader("$3\r\nXXX\r\n".to_string())(|sb| { let res = parse_response(@sb as @io::Reader); - println!("{:?}", res); + println!("{}", res); res }); } diff --git a/src/test/run-pass/issue-4252.rs b/src/test/run-pass/issue-4252.rs index 186dd0363ee..04b1cbf577d 100644 --- a/src/test/run-pass/issue-4252.rs +++ b/src/test/run-pass/issue-4252.rs @@ -10,29 +10,29 @@ #![feature(unsafe_destructor)] -extern crate debug; - trait X { - fn call(&self, x: &T); - fn default_method(&self, x: &T) { - println!("X::default_method {:?} {:?}", self, x); + fn call(&self, x: &T); + fn default_method(&self, x: &T) { + println!("X::default_method {}", x); } } +#[deriving(Show)] struct Y(int); +#[deriving(Show)] struct Z { x: T } impl X for Y { - fn call(&self, x: &T) { - println!("X::call {:?} {:?}", self, x); + fn call(&self, x: &T) { + println!("X::call {} {}", self, x); } } #[unsafe_destructor] -impl Drop for Z { +impl Drop for Z { fn drop(&mut self) { // These statements used to cause an ICE. self.x.call(self); diff --git a/src/test/run-pass/issue-5688.rs b/src/test/run-pass/issue-5688.rs index 281070754c4..73bf375923a 100644 --- a/src/test/run-pass/issue-5688.rs +++ b/src/test/run-pass/issue-5688.rs @@ -17,12 +17,10 @@ with the representation of [int, ..n] and [int] somehow, or at least failed to typecheck correctly. */ -extern crate debug; - struct X { vec: &'static [int] } static V: &'static [X] = &[X { vec: &[1, 2, 3] }]; pub fn main() { for &v in V.iter() { - println!("{:?}", v.vec); + println!("{}", v.vec); } } diff --git a/src/test/run-pass/issue-6344-let.rs b/src/test/run-pass/issue-6344-let.rs index 0b5e92fcf30..65ee062a039 100644 --- a/src/test/run-pass/issue-6344-let.rs +++ b/src/test/run-pass/issue-6344-let.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - struct A { x: uint } impl Drop for A { @@ -20,5 +18,5 @@ pub fn main() { let a = A { x: 0 }; let A { x: ref x } = a; - println!("{:?}", x) + println!("{}", x) } diff --git a/src/test/run-pass/issue-6344-match.rs b/src/test/run-pass/issue-6344-match.rs index 67807a82759..ee99ec957b5 100644 --- a/src/test/run-pass/issue-6344-match.rs +++ b/src/test/run-pass/issue-6344-match.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - struct A { x: uint } impl Drop for A { @@ -21,7 +19,7 @@ pub fn main() { match a { A { x : ref x } => { - println!("{:?}", x) + println!("{}", x) } } } diff --git a/src/test/run-pass/issue-7563.rs b/src/test/run-pass/issue-7563.rs index bf62c2e459a..73697b2bdb8 100644 --- a/src/test/run-pass/issue-7563.rs +++ b/src/test/run-pass/issue-7563.rs @@ -8,13 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - trait IDummy { fn do_nothing(&self); } +#[deriving(Show)] struct A { a: int } +#[deriving(Show)] struct B<'a> { b: int, pa: &'a A } impl IDummy for A { @@ -31,7 +31,6 @@ pub fn main() { let sa = A { a: 100 }; let sb = B { b: 200, pa: &sa }; - println!("sa is {:?}", sa); - println!("sb is {:?}", sb); - println!("sb.pa is {:?}", sb.get_pa()); + println!("sa is {}", sa); + println!("sb is {}", sb); } diff --git a/src/test/run-pass/issue-8898.rs b/src/test/run-pass/issue-8898.rs index 3fff58410a4..305f984f98e 100644 --- a/src/test/run-pass/issue-8898.rs +++ b/src/test/run-pass/issue-8898.rs @@ -10,10 +10,8 @@ #![feature(slicing_syntax)] -extern crate debug; - -fn assert_repr_eq(obj : T, expected : String) { - assert_eq!(expected, format!("{:?}", obj)); +fn assert_repr_eq(obj : T, expected : String) { + assert_eq!(expected, format!("{}", obj)); } pub fn main() { @@ -22,9 +20,9 @@ pub fn main() { let x = [(), ()]; let slice = x[0..1]; - 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()); - assert_repr_eq(&x, "&[(), ()]".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()); + assert_repr_eq(x[], "[(), ()]".to_string()); } diff --git a/src/test/run-pass/issue-9737.rs b/src/test/run-pass/issue-9737.rs index 02d730889a7..1f385b2fb15 100644 --- a/src/test/run-pass/issue-9737.rs +++ b/src/test/run-pass/issue-9737.rs @@ -12,7 +12,7 @@ #![feature(macro_rules)] -macro_rules! f((v: $x:expr) => ( println!("{:?}", $x) )) +macro_rules! f((v: $x:expr) => ( println!("{}", $x) )) fn main () { let v = 5; diff --git a/src/test/run-pass/last-use-is-capture.rs b/src/test/run-pass/last-use-is-capture.rs index fa3f3117c64..6d5624e2b58 100644 --- a/src/test/run-pass/last-use-is-capture.rs +++ b/src/test/run-pass/last-use-is-capture.rs @@ -10,13 +10,11 @@ // Make sure #1399 stays fixed -extern crate debug; - struct A { a: Box } pub fn main() { fn invoke(f: ||) { f(); } let k = box 22i; let _u = A {a: k.clone()}; - invoke(|| println!("{:?}", k.clone()) ) + invoke(|| println!("{}", k.clone()) ) } diff --git a/src/test/run-pass/lazy-and-or.rs b/src/test/run-pass/lazy-and-or.rs index 366b3c41328..043961ce599 100644 --- a/src/test/run-pass/lazy-and-or.rs +++ b/src/test/run-pass/lazy-and-or.rs @@ -8,15 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn incr(x: &mut int) -> bool { *x += 1; assert!((false)); return false; } pub fn main() { let x = 1i == 2 || 3i == 3; assert!((x)); let mut y: int = 10; - println!("{:?}", x || incr(&mut y)); + println!("{}", x || incr(&mut y)); assert_eq!(y, 10); if true && x { assert!((true)); } else { assert!((false)); } } diff --git a/src/test/run-pass/linear-for-loop.rs b/src/test/run-pass/linear-for-loop.rs index e9e2a753469..f527ad77a92 100644 --- a/src/test/run-pass/linear-for-loop.rs +++ b/src/test/run-pass/linear-for-loop.rs @@ -10,13 +10,11 @@ // no-pretty-expanded FIXME #15189 -extern crate debug; - pub fn main() { let x = vec!(1i, 2i, 3i); let mut y = 0i; - for i in x.iter() { println!("{:?}", *i); y += *i; } - println!("{:?}", y); + for i in x.iter() { println!("{}", *i); y += *i; } + println!("{}", y); assert_eq!(y, 6); let s = "hello there".to_string(); let mut i: int = 0; @@ -29,8 +27,8 @@ pub fn main() { // ... i += 1; - println!("{:?}", i); - println!("{:?}", c); + println!("{}", i); + println!("{}", c); } assert_eq!(i, 11); } diff --git a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs index cb7a5989430..3d8eaeea618 100644 --- a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs +++ b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs @@ -8,28 +8,26 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - -#[deriving(Clone)] +#[deriving(Clone, Show)] enum foo { a(uint), b(String), } -fn check_log(exp: String, v: T) { - assert_eq!(exp, format!("{:?}", v)); +fn check_log(exp: String, v: T) { + assert_eq!(exp, format!("{}", v)); } pub fn main() { let mut x = Some(a(22u)); - let exp = "Some(a(22u))".to_string(); - let act = format!("{:?}", x); + let exp = "Some(a(22))".to_string(); + let act = format!("{}", x); assert_eq!(act, exp); check_log(exp, x); x = None; let exp = "None".to_string(); - let act = format!("{:?}", x); + let act = format!("{}", x); assert_eq!(act, exp); check_log(exp, x); } diff --git a/src/test/run-pass/log-knows-the-names-of-variants.rs b/src/test/run-pass/log-knows-the-names-of-variants.rs index e6a23d99290..8445f3e3160 100644 --- a/src/test/run-pass/log-knows-the-names-of-variants.rs +++ b/src/test/run-pass/log-knows-the-names-of-variants.rs @@ -8,20 +8,20 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - +#[deriving(Show)] enum foo { a(uint), b(String), c, } +#[deriving(Show)] enum bar { d, e, f } pub fn main() { - assert_eq!("a(22u)".to_string(), format!("{:?}", a(22u))); - assert_eq!("c".to_string(), format!("{:?}", c)); - assert_eq!("d".to_string(), format!("{:?}", d)); + assert_eq!("a(22)".to_string(), format!("{}", a(22u))); + assert_eq!("c".to_string(), format!("{}", c)); + assert_eq!("d".to_string(), format!("{}", d)); } diff --git a/src/test/run-pass/log-poly.rs b/src/test/run-pass/log-poly.rs index c265bb0bcb1..cf733fe4893 100644 --- a/src/test/run-pass/log-poly.rs +++ b/src/test/run-pass/log-poly.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - +#[deriving(Show)] enum Numbers { Three } @@ -17,6 +16,6 @@ enum Numbers { pub fn main() { println!("{}", 1i); println!("{}", 2.0f64); - println!("{:?}", Three); - println!("{:?}", vec!(4i)); + println!("{}", Three); + println!("{}", vec!(4i)); } diff --git a/src/test/run-pass/match-unique-bind.rs b/src/test/run-pass/match-unique-bind.rs index f6b2027e0fe..5c834a06a74 100644 --- a/src/test/run-pass/match-unique-bind.rs +++ b/src/test/run-pass/match-unique-bind.rs @@ -8,12 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - pub fn main() { match box 100i { box x => { - println!("{:?}", x); + println!("{}", x); assert_eq!(x, 100); } } diff --git a/src/test/run-pass/nested-matchs.rs b/src/test/run-pass/nested-matchs.rs index e95ee4c99c5..fa28025afa0 100644 --- a/src/test/run-pass/nested-matchs.rs +++ b/src/test/run-pass/nested-matchs.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn baz() -> ! { fail!(); } fn foo() { @@ -17,7 +15,7 @@ fn foo() { Some::(_x) => { let mut bar; match None:: { None:: => { bar = 5i; } _ => { baz(); } } - println!("{:?}", bar); + println!("{}", bar); } None:: => { println!("hello"); } } diff --git a/src/test/run-pass/over-constrained-vregs.rs b/src/test/run-pass/over-constrained-vregs.rs index 3cc485c8f3a..4cd8e65e500 100644 --- a/src/test/run-pass/over-constrained-vregs.rs +++ b/src/test/run-pass/over-constrained-vregs.rs @@ -8,14 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - // Regression test for issue #152. pub fn main() { let mut b: uint = 1u; while b <= 32u { 0u << b; b <<= 1u; - println!("{:?}", b); + println!("{}", b); } } diff --git a/src/test/run-pass/overload-index-operator.rs b/src/test/run-pass/overload-index-operator.rs index 6b1ac0b821c..d047f02fe2f 100644 --- a/src/test/run-pass/overload-index-operator.rs +++ b/src/test/run-pass/overload-index-operator.rs @@ -11,8 +11,6 @@ // Test overloading of the `[]` operator. In particular test that it // takes its argument *by reference*. -extern crate debug; - use std::ops::Index; struct AssociationList { @@ -30,14 +28,14 @@ impl AssociationList { } } -impl Index for AssociationList { +impl Index for AssociationList { fn index<'a>(&'a self, index: &K) -> &'a V { for pair in self.pairs.iter() { if pair.key == *index { return &pair.value } } - fail!("No value found for key: {:?}", index); + fail!("No value found for key: {}", index); } } diff --git a/src/test/run-pass/rec-align-u32.rs b/src/test/run-pass/rec-align-u32.rs index c5a721ee326..ce8c5df0740 100644 --- a/src/test/run-pass/rec-align-u32.rs +++ b/src/test/run-pass/rec-align-u32.rs @@ -12,8 +12,6 @@ #![feature(intrinsics)] -extern crate debug; - use std::mem; mod rusti { @@ -24,12 +22,14 @@ mod rusti { } // This is the type with the questionable alignment +#[deriving(Show)] struct Inner { c64: u32 } // This is the type that contains the type with the // questionable alignment, for testing +#[deriving(Show)] struct Outer { c8: u8, t: Inner @@ -53,10 +53,10 @@ pub fn main() { let x = Outer {c8: 22u8, t: Inner {c64: 44u32}}; // Send it through the shape code - let y = format!("{:?}", x); + let y = format!("{}", x); - println!("align inner = {:?}", rusti::min_align_of::()); - println!("size outer = {:?}", mem::size_of::()); + println!("align inner = {}", rusti::min_align_of::()); + println!("size outer = {}", mem::size_of::()); println!("y = {}", y); // per clang/gcc the alignment of `inner` is 4 on x86. @@ -66,6 +66,6 @@ pub fn main() { // because `inner`s alignment was 4. assert_eq!(mem::size_of::(), 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()); } } diff --git a/src/test/run-pass/rec-align-u64.rs b/src/test/run-pass/rec-align-u64.rs index 4e41caf138e..c0c7f4c99be 100644 --- a/src/test/run-pass/rec-align-u64.rs +++ b/src/test/run-pass/rec-align-u64.rs @@ -12,8 +12,6 @@ #![feature(intrinsics)] -extern crate debug; - use std::mem; mod rusti { @@ -24,12 +22,14 @@ mod rusti { } // This is the type with the questionable alignment +#[deriving(Show)] struct Inner { c64: u64 } // This is the type that contains the type with the // questionable alignment, for testing +#[deriving(Show)] struct Outer { c8: u8, t: Inner @@ -82,8 +82,7 @@ pub fn main() { unsafe { let x = Outer {c8: 22u8, t: Inner {c64: 44u64}}; - // Send it through the shape code - let y = format!("{:?}", x); + let y = format!("{}", x); println!("align inner = {}", rusti::min_align_of::()); println!("size outer = {}", mem::size_of::()); @@ -96,6 +95,6 @@ pub fn main() { // because `Inner`s alignment was 4. assert_eq!(mem::size_of::(), 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()); } } diff --git a/src/test/run-pass/regions-self-impls.rs b/src/test/run-pass/regions-self-impls.rs index 33f080d8db2..b30b3cfa476 100644 --- a/src/test/run-pass/regions-self-impls.rs +++ b/src/test/run-pass/regions-self-impls.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - struct Clam<'a> { chowder: &'a int } @@ -24,6 +22,6 @@ impl<'a> get_chowder<'a> for Clam<'a> { pub fn main() { let clam = Clam { chowder: &3 }; - println!("{:?}", *clam.get_chowder()); + println!("{}", *clam.get_chowder()); clam.get_chowder(); } diff --git a/src/test/run-pass/regions-self-in-enums.rs b/src/test/run-pass/regions-self-in-enums.rs index 9b817c5c906..987392c70e3 100644 --- a/src/test/run-pass/regions-self-in-enums.rs +++ b/src/test/run-pass/regions-self-in-enums.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - enum int_wrapper<'a> { int_wrapper_ctor(&'a int) } @@ -21,5 +19,5 @@ pub fn main() { match y { int_wrapper_ctor(zz) => { z = zz; } } - println!("{:?}", *z); + println!("{}", *z); } diff --git a/src/test/run-pass/regions-simple.rs b/src/test/run-pass/regions-simple.rs index bcd66eef957..d540605180a 100644 --- a/src/test/run-pass/regions-simple.rs +++ b/src/test/run-pass/regions-simple.rs @@ -8,11 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - pub fn main() { let mut x: int = 3; let y: &mut int = &mut x; *y = 5; - println!("{:?}", *y); + println!("{}", *y); } diff --git a/src/test/run-pass/repeated-vector-syntax.rs b/src/test/run-pass/repeated-vector-syntax.rs index 76d15f12b60..9c369c0d770 100644 --- a/src/test/run-pass/repeated-vector-syntax.rs +++ b/src/test/run-pass/repeated-vector-syntax.rs @@ -8,13 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -extern crate debug; +#![feature(slicing_syntax)] pub fn main() { let x = [ [true], ..512 ]; let y = [ 0i, ..1 ]; - println!("{:?}", x); - println!("{:?}", y); + print!("["); + for xi in x.iter() { + print!("{}, ", (*xi)[]); + } + println!("]"); + println!("{}", y[]); } diff --git a/src/test/run-pass/shadow.rs b/src/test/run-pass/shadow.rs index 96a12494b2f..9f553cd2a00 100644 --- a/src/test/run-pass/shadow.rs +++ b/src/test/run-pass/shadow.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn foo(c: Vec ) { let a: int = 5; let mut b: Vec = Vec::new(); @@ -18,7 +16,7 @@ fn foo(c: Vec ) { match none:: { some::(_) => { for _i in c.iter() { - println!("{:?}", a); + println!("{}", a); let a = 17i; b.push(a); } diff --git a/src/test/run-pass/signal-exit-status.rs b/src/test/run-pass/signal-exit-status.rs index ed7145412b0..52fa8e1132e 100644 --- a/src/test/run-pass/signal-exit-status.rs +++ b/src/test/run-pass/signal-exit-status.rs @@ -10,8 +10,6 @@ // ignore-windows -extern crate debug; - use std::os; use std::io::process::{Command, ExitSignal, ExitStatus}; @@ -27,7 +25,7 @@ pub fn main() { match status { ExitSignal(_) if cfg!(unix) => {}, ExitStatus(0xC0000028) if cfg!(windows) => {}, - _ => fail!("invalid termination (was not signalled): {:?}", status) + _ => fail!("invalid termination (was not signalled): {}", status) } } } diff --git a/src/test/run-pass/size-and-align.rs b/src/test/run-pass/size-and-align.rs index 5d07ca56041..1078359dc14 100644 --- a/src/test/run-pass/size-and-align.rs +++ b/src/test/run-pass/size-and-align.rs @@ -8,15 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - enum clam { a(T, int), b, } fn uhoh(v: Vec> ) { match *v.get(1) { a::(ref _t, ref u) => { println!("incorrect"); - println!("{:?}", u); + println!("{}", u); fail!(); } b:: => { println!("correct"); } diff --git a/src/test/run-pass/small-enums-with-fields.rs b/src/test/run-pass/small-enums-with-fields.rs index 7cc6725a509..69d574152fa 100644 --- a/src/test/run-pass/small-enums-with-fields.rs +++ b/src/test/run-pass/small-enums-with-fields.rs @@ -10,8 +10,6 @@ #![feature(macro_rules)] -extern crate debug; - use std::mem::size_of; #[deriving(PartialEq, Show)] @@ -24,8 +22,8 @@ macro_rules! check { static S: $t = $e; let v: $t = $e; assert_eq!(S, v); - assert_eq!(format!("{:?}", v).as_slice(), $s); - assert_eq!(format!("{:?}", S).as_slice(), $s); + assert_eq!(format!("{}", v).as_slice(), $s); + assert_eq!(format!("{}", S).as_slice(), $s); });* }} } @@ -33,14 +31,14 @@ macro_rules! check { pub fn main() { check!(Option, 2, None, "None", - Some(129u8), "Some(129u8)"); + Some(129u8), "Some(129)"); check!(Option, 4, None, "None", - Some(-20000i16), "Some(-20000i16)"); + Some(-20000i16), "Some(-20000)"); check!(Either, 2, - Left(132u8), "Left(132u8)", - Right(-32i8), "Right(-32i8)"); + Left(132u8), "Left(132)", + Right(-32i8), "Right(-32)"); check!(Either, 4, - Left(132u8), "Left(132u8)", - Right(-20000i16), "Right(-20000i16)"); + Left(132u8), "Left(132)", + Right(-20000i16), "Right(-20000)"); } diff --git a/src/test/run-pass/spawn-fn.rs b/src/test/run-pass/spawn-fn.rs index 15301e96e69..dba3fe325fa 100644 --- a/src/test/run-pass/spawn-fn.rs +++ b/src/test/run-pass/spawn-fn.rs @@ -8,13 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - use std::task; fn x(s: String, n: int) { - println!("{:?}", s); - println!("{:?}", n); + println!("{}", s); + println!("{}", n); } pub fn main() { diff --git a/src/test/run-pass/tag-align-shape.rs b/src/test/run-pass/tag-align-shape.rs index e032a5e4156..10317c1dd02 100644 --- a/src/test/run-pass/tag-align-shape.rs +++ b/src/test/run-pass/tag-align-shape.rs @@ -8,12 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - +#[deriving(Show)] enum a_tag { a_tag_var(u64) } +#[deriving(Show)] struct t_rec { c8: u8, t: a_tag @@ -21,7 +21,7 @@ struct t_rec { pub fn main() { let x = t_rec {c8: 22u8, t: a_tag_var(44u64)}; - let y = format!("{:?}", x); + 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()); } diff --git a/src/test/run-pass/tag-disr-val-shape.rs b/src/test/run-pass/tag-disr-val-shape.rs index 57f0f862fbf..75345555554 100644 --- a/src/test/run-pass/tag-disr-val-shape.rs +++ b/src/test/run-pass/tag-disr-val-shape.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - +#[deriving(Show)] enum color { red = 0xff0000, green = 0x00ff00, @@ -19,9 +18,9 @@ enum color { } pub fn main() { - let act = format!("{:?}", red); + let act = format!("{}", red); println!("{}", act); assert_eq!("red".to_string(), act); - assert_eq!("green".to_string(), format!("{:?}", green)); - assert_eq!("white".to_string(), format!("{:?}", white)); + assert_eq!("green".to_string(), format!("{}", green)); + assert_eq!("white".to_string(), format!("{}", white)); } diff --git a/src/test/run-pass/tail-cps.rs b/src/test/run-pass/tail-cps.rs index 13a2ab47bf3..6f03f385a83 100644 --- a/src/test/run-pass/tail-cps.rs +++ b/src/test/run-pass/tail-cps.rs @@ -8,20 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn checktrue(rs: bool) -> bool { assert!((rs)); return true; } pub fn main() { let k = checktrue; evenk(42, k); oddk(45, k); } fn evenk(n: int, k: fn(bool) -> bool) -> bool { println!("evenk"); - println!("{:?}", n); + println!("{}", n); if n == 0 { return k(true); } else { return oddk(n - 1, k); } } fn oddk(n: int, k: fn(bool) -> bool) -> bool { println!("oddk"); - println!("{:?}", n); + println!("{}", n); if n == 0 { return k(false); } else { return evenk(n - 1, k); } } diff --git a/src/test/run-pass/task-comm-3.rs b/src/test/run-pass/task-comm-3.rs index eb0449efa6a..583840ede5f 100644 --- a/src/test/run-pass/task-comm-3.rs +++ b/src/test/run-pass/task-comm-3.rs @@ -10,8 +10,6 @@ // no-pretty-expanded FIXME #15189 -extern crate debug; - use std::task; pub fn main() { println!("===== WITHOUT THREADS ====="); test00(); } @@ -65,7 +63,7 @@ fn test00() { for r in results.iter_mut() { r.get_ref(); } println!("Completed: Final number is: "); - println!("{:?}", sum); + println!("{}", sum); // assert (sum == (((number_of_tasks * (number_of_tasks - 1)) / 2) * // number_of_messages)); assert_eq!(sum, 480); diff --git a/src/test/run-pass/task-comm-9.rs b/src/test/run-pass/task-comm-9.rs index a46b4513c5d..cc71ccdfa19 100644 --- a/src/test/run-pass/task-comm-9.rs +++ b/src/test/run-pass/task-comm-9.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - use std::task; pub fn main() { test00(); } @@ -32,7 +30,7 @@ fn test00() { let mut i: int = 0; while i < number_of_messages { sum += rx.recv(); - println!("{:?}", r); + println!("{}", r); i += 1; } diff --git a/src/test/run-pass/tcp-stress.rs b/src/test/run-pass/tcp-stress.rs index 506e1a9bbe7..91c07c259a2 100644 --- a/src/test/run-pass/tcp-stress.rs +++ b/src/test/run-pass/tcp-stress.rs @@ -16,7 +16,6 @@ #[phase(plugin, link)] extern crate log; extern crate libc; -extern crate debug; use std::io::net::tcp::{TcpListener, TcpStream}; use std::io::{Acceptor, Listener}; @@ -41,7 +40,7 @@ fn main() { let mut stream = match acceptor.accept() { Ok(stream) => stream, Err(error) => { - debug!("accept failed: {:?}", error); + debug!("accept failed: {}", error); continue; } }; @@ -64,7 +63,7 @@ fn main() { let mut buf = [0]; stream.read(buf); }, - Err(e) => debug!("{:?}", e) + Err(e) => debug!("{}", e) } tx.send(()); }); diff --git a/src/test/run-pass/tempfile.rs b/src/test/run-pass/tempfile.rs index 64fd96bd924..eceafa40265 100644 --- a/src/test/run-pass/tempfile.rs +++ b/src/test/run-pass/tempfile.rs @@ -18,8 +18,6 @@ // they're in a different location than before. Hence, these tests are all run // serially here. -extern crate debug; - use std::io::fs::PathExtensions; use std::io::{fs, TempDir}; use std::io; @@ -126,7 +124,7 @@ fn test_rm_tempdir_close() { fn recursive_mkdir_rel() { let path = Path::new("frob"); let cwd = os::getcwd(); - println!("recursive_mkdir_rel: Making: {} in cwd {} [{:?}]", path.display(), + println!("recursive_mkdir_rel: Making: {} in cwd {} [{}]", path.display(), cwd.display(), path.exists()); fs::mkdir_recursive(&path, io::USER_RWX); assert!(path.is_dir()); @@ -144,7 +142,7 @@ fn recursive_mkdir_dot() { fn recursive_mkdir_rel_2() { let path = Path::new("./frob/baz"); let cwd = os::getcwd(); - println!("recursive_mkdir_rel_2: Making: {} in cwd {} [{:?}]", path.display(), + println!("recursive_mkdir_rel_2: Making: {} in cwd {} [{}]", path.display(), cwd.display(), path.exists()); fs::mkdir_recursive(&path, io::USER_RWX); assert!(path.is_dir()); diff --git a/src/test/run-pass/trivial-message.rs b/src/test/run-pass/trivial-message.rs index 964d6ca317e..464ab135228 100644 --- a/src/test/run-pass/trivial-message.rs +++ b/src/test/run-pass/trivial-message.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - /* This is about the simplest program that can successfully send a message. @@ -19,5 +17,5 @@ pub fn main() { let (tx, rx) = channel(); tx.send(42i); let r = rx.recv(); - println!("{:?}", r); + println!("{}", r); } diff --git a/src/test/run-pass/tuple-struct-construct.rs b/src/test/run-pass/tuple-struct-construct.rs index 0c2dc121828..af8b203d951 100644 --- a/src/test/run-pass/tuple-struct-construct.rs +++ b/src/test/run-pass/tuple-struct-construct.rs @@ -8,11 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - +#[deriving(Show)] struct Foo(int, int); pub fn main() { let x = Foo(1, 2); - println!("{:?}", x); + println!("{}", x); } diff --git a/src/test/run-pass/unique-in-tag.rs b/src/test/run-pass/unique-in-tag.rs index 42ed47ebbb7..b1d351ef7b4 100644 --- a/src/test/run-pass/unique-in-tag.rs +++ b/src/test/run-pass/unique-in-tag.rs @@ -8,15 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - fn test1() { enum bar { u(Box), w(int), } let x = u(box 10); assert!(match x { u(a) => { - println!("{:?}", a); + println!("{}", a); *a } _ => { 66 } diff --git a/src/test/run-pass/unique-log.rs b/src/test/run-pass/unique-log.rs index 108b0f43962..bae87230ba0 100644 --- a/src/test/run-pass/unique-log.rs +++ b/src/test/run-pass/unique-log.rs @@ -8,9 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - pub fn main() { let i = box 100i; - println!("{:?}", i); + println!("{}", i); } diff --git a/src/test/run-pass/unique-pat-3.rs b/src/test/run-pass/unique-pat-3.rs index 13416c5acbb..f031f779085 100644 --- a/src/test/run-pass/unique-pat-3.rs +++ b/src/test/run-pass/unique-pat-3.rs @@ -8,14 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - enum bar { u(Box), w(int), } pub fn main() { assert!(match u(box 10) { u(a) => { - println!("{:?}", a); + println!("{}", a); *a } _ => { 66 } diff --git a/src/test/run-pass/vec-dst.rs b/src/test/run-pass/vec-dst.rs index 40c77850adc..2fe8f4bdf01 100644 --- a/src/test/run-pass/vec-dst.rs +++ b/src/test/run-pass/vec-dst.rs @@ -8,73 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate debug; - -fn reflect() { - // Tests for reflective printing. - // Also tests drop glue. - let x = [1, 2, 3, 4]; - let x2 = [(), (), ()]; - let e1: [uint, ..0] = []; - let e2: [&'static str, ..0] = []; - let e3: [(), ..0] = []; - assert!(format!("{:?}", x) == "[1u, 2u, 3u, 4u]".to_string()); - assert!(format!("{:?}", x2) == "[(), (), ()]".to_string()); - assert!(format!("{:?}", e1) == "[]".to_string()); - assert!(format!("{:?}", e2) == "[]".to_string()); - assert!(format!("{:?}", e3) == "[]".to_string()); - - let rx: &[uint, ..4] = &x; - let rx2: &[(), ..3] = &x2; - let re1: &[uint, ..0] = &e1; - let re2: &[&'static str, ..0] = &e2; - let re3: &[(), ..0] = &e3; - assert!(format!("{:?}", rx) == "&[1u, 2u, 3u, 4u]".to_string()); - assert!(format!("{:?}", rx2) == "&[(), (), ()]".to_string()); - assert!(format!("{:?}", re1) == "&[]".to_string()); - assert!(format!("{:?}", re2) == "&[]".to_string()); - assert!(format!("{:?}", re3) == "&[]".to_string()); - - let rx: &[uint] = &x; - let rx2: &[()] = &x2; - let re1: &[uint] = &e1; - let re2: &[&'static str] = &e2; - let re3: &[()] = &e3; - assert!(format!("{:?}", rx) == "&[1u, 2u, 3u, 4u]".to_string()); - assert!(format!("{:?}", rx2) == "&[(), (), ()]".to_string()); - assert!(format!("{:?}", re1) == "&[]".to_string()); - assert!(format!("{:?}", re2) == "&[]".to_string()); - assert!(format!("{:?}", re3) == "&[]".to_string()); - - // FIXME(15049) These should all work some day. - /*let rx: Box<[uint, ..4]> = box x; - let rx2: Box<[(), ..3]> = box x2; - let re1: Box<[uint, ..0]> = box e1; - let re2: Box<[&'static str, ..0]> = box e2; - let re3: Box<[(), ..0]> = box e3; - assert!(format!("{:?}", rx) == "box [1u, 2u, 3u, 4u]".to_string()); - assert!(format!("{:?}", rx2) == "box [(), (), ()]".to_string()); - assert!(format!("{:?}", re1) == "box []".to_string()); - assert!(format!("{:?}", re2) == "box []".to_string()); - assert!(format!("{:?}", re3) == "box []".to_string()); - - let x = [1, 2, 3, 4]; - let x2 = [(), (), ()]; - let e1: [uint, ..0] = []; - let e2: [&'static str, ..0] = []; - let e3: [(), ..0] = []; - let rx: Box<[uint]> = box x; - let rx2: Box<[()]> = box x2; - let re1: Box<[uint]> = box e1; - let re2: Box<[&'static str]> = box e2; - let re3: Box<[()]> = box e3; - assert!(format!("{:?}", rx) == "box [1u, 2u, 3u, 4u]".to_string()); - assert!(format!("{:?}", rx2) == "box [(), (), ()]".to_string()); - assert!(format!("{:?}", re1) == "box []".to_string()); - assert!(format!("{:?}", re2) == "box []".to_string()); - assert!(format!("{:?}", re3) == "box []".to_string());*/ -} - fn sub_expr() { // Test for a &[T] => &&[T] coercion in sub-expression position // (surpisingly, this can cause errors which are not caused by either of: @@ -109,7 +42,6 @@ fn index() { } pub fn main() { - reflect(); sub_expr(); index(); }