diff options
| author | bors <bors@rust-lang.org> | 2014-10-16 17:52:25 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-10-16 17:52:25 +0000 |
| commit | 8b979739713f54eb9315ed5f88b8f06d43d0bbb5 (patch) | |
| tree | aa374aaa783ed319e49592dcd40cf7b6416d53b8 | |
| parent | b6e0d3a5bf4c88650a22f605f822e02c6b163580 (diff) | |
| parent | 78992485047f7600a0d34c5f573b30be262b2e4b (diff) | |
| download | rust-8b979739713f54eb9315ed5f88b8f06d43d0bbb5.tar.gz rust-8b979739713f54eb9315ed5f88b8f06d43d0bbb5.zip | |
auto merge of #18064 : luqmana/rust/remove-reflection, r=nick29581
Out goes reflection! This means your code will break if you used the `:?` format specifier, anything else from libdebug, or the `visit_tydesc` intrinsic directly. Closes #18046. [breaking-change]
239 files changed, 709 insertions, 2926 deletions
diff --git a/mk/crates.mk b/mk/crates.mk index 03716f5d7f6..fd41666275b 100644 --- a/mk/crates.mk +++ b/mk/crates.mk @@ -51,7 +51,7 @@ TARGET_CRATES := libc std green native flate arena glob term semver \ uuid serialize sync getopts collections num test time rand \ - url log regex graphviz core rbml rlibc alloc debug rustrt \ + url log regex graphviz core rbml rlibc alloc rustrt \ unicode HOST_CRATES := syntax rustc rustdoc fourcc hexfloat regex_macros fmt_macros \ rustc_llvm rustc_back @@ -63,20 +63,19 @@ DEPS_libc := core DEPS_rlibc := core DEPS_unicode := core DEPS_alloc := core libc native:jemalloc -DEPS_debug := std DEPS_rustrt := alloc core libc collections native:rustrt_native DEPS_std := core libc rand alloc collections rustrt sync unicode \ native:rust_builtin native:backtrace DEPS_graphviz := std DEPS_green := std native:context_switch DEPS_native := std -DEPS_syntax := std term serialize log fmt_macros debug arena libc +DEPS_syntax := std term serialize log fmt_macros arena libc DEPS_rustc := syntax flate arena serialize getopts rbml \ - time log graphviz debug rustc_llvm rustc_back + time log graphviz rustc_llvm rustc_back DEPS_rustc_llvm := native:rustllvm libc std DEPS_rustc_back := std syntax rustc_llvm flate log libc DEPS_rustdoc := rustc native:hoedown serialize getopts \ - test time debug + test time DEPS_flate := std native:miniz DEPS_arena := std DEPS_graphviz := std diff --git a/src/doc/reference.md b/src/doc/reference.md index 3c4b973002e..dfdadb3546b 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 @@ -2279,8 +2279,6 @@ These types help drive the compiler's analysis : The lifetime parameter should be considered invariant * `malloc` : Allocate memory on the managed heap. -* `opaque` - : ___Needs filling in___ * `owned_box` : ___Needs filling in___ * `stack_exhausted` @@ -2295,8 +2293,6 @@ These types help drive the compiler's analysis : The type parameter should be considered invariant * `ty_desc` : ___Needs filling in___ -* `ty_visitor` - : ___Needs filling in___ > **Note:** This list is likely to become out of date. We should auto-generate > it from `librustc/middle/lang_items.rs`. diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index a2483f23534..c447cb46c53 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -317,8 +317,6 @@ mod tests { assert_eq!((*arc_v)[2], 3); assert_eq!((*arc_v)[4], 5); - - info!("{:?}", arc_v); } #[test] 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/hash/sip.rs b/src/libcollections/hash/sip.rs index ab182bd5602..4ac06a884a6 100644 --- a/src/libcollections/hash/sip.rs +++ b/src/libcollections/hash/sip.rs @@ -402,7 +402,7 @@ mod tests { debug!("siphash test {}: {}", t, buf); let vec = u8to64_le!(vecs[t], 0); let out = hash_with_keys(k0, k1, &Bytes(buf.as_slice())); - debug!("got {:?}, expected {:?}", out, vec); + debug!("got {}, expected {}", out, vec); assert_eq!(vec, out); state_full.reset(); @@ -412,9 +412,6 @@ mod tests { let v = to_hex_str(&vecs[t]); debug!("{}: ({}) => inc={} full={}", t, v, i, f); - debug!("full state {:?}", state_full); - debug!("inc state {:?}", state_inc); - assert_eq!(f, i); assert_eq!(f, v); 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/libcollections/ringbuf.rs b/src/libcollections/ringbuf.rs index 4d8e67f6ac8..1ae63d11fbe 100644 --- a/src/libcollections/ringbuf.rs +++ b/src/libcollections/ringbuf.rs @@ -551,21 +551,21 @@ mod tests { assert_eq!(d.len(), 3u); d.push(137); assert_eq!(d.len(), 4u); - debug!("{:?}", d.front()); + debug!("{}", d.front()); assert_eq!(*d.front().unwrap(), 42); - debug!("{:?}", d.back()); + debug!("{}", d.back()); assert_eq!(*d.back().unwrap(), 137); let mut i = d.pop_front(); - debug!("{:?}", i); + debug!("{}", i); assert_eq!(i, Some(42)); i = d.pop(); - debug!("{:?}", i); + debug!("{}", i); assert_eq!(i, Some(137)); i = d.pop(); - debug!("{:?}", i); + debug!("{}", i); assert_eq!(i, Some(137)); i = d.pop(); - debug!("{:?}", i); + debug!("{}", i); assert_eq!(i, Some(17)); assert_eq!(d.len(), 0u); d.push(3); @@ -576,10 +576,10 @@ mod tests { assert_eq!(d.len(), 3u); d.push_front(1); assert_eq!(d.len(), 4u); - debug!("{:?}", d.get(0)); - debug!("{:?}", d.get(1)); - debug!("{:?}", d.get(2)); - debug!("{:?}", d.get(3)); + debug!("{}", d.get(0)); + debug!("{}", d.get(1)); + debug!("{}", d.get(2)); + debug!("{}", d.get(3)); assert_eq!(*d.get(0), 1); assert_eq!(*d.get(1), 2); assert_eq!(*d.get(2), 3); diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 3f7dcb36cf6..3d593a0d026 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -58,17 +58,21 @@ pub struct TyDesc { pub drop_glue: GlueFn, // Called by reflection visitor to visit a value of type `T` + #[cfg(stage0)] pub visit_glue: GlueFn, // Name corresponding to the type pub name: &'static str, } +#[cfg(stage0)] #[lang="opaque"] pub enum Opaque { } +#[cfg(stage0)] pub type Disr = u64; +#[cfg(stage0)] #[lang="ty_visitor"] pub trait TyVisitor { fn visit_bot(&mut self) -> bool; @@ -327,8 +331,6 @@ extern "rust-intrinsic" { /// Returns `true` if a type is managed (will be allocated on the local heap) pub fn owns_managed<T>() -> bool; - pub fn visit_tydesc(td: *const TyDesc, tv: &mut TyVisitor); - /// Calculates the offset from a pointer. The offset *must* be in-bounds of /// the object, or one-byte-past-the-end. An arithmetic overflow is also /// undefined behaviour. 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 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! 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<T: 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<T> 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 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! 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 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/*! - -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<V> { - inner: V -} - -impl<V:TyVisitor + MovePtr> MovePtrAdaptor<V> { - pub fn new(v: V) -> MovePtrAdaptor<V> { - 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<T>(&mut self) { - self.align(mem::min_align_of::<T>()); - } - - #[inline] - pub fn bump_past<T>(&mut self) { - self.bump(mem::size_of::<T>()); - } - - pub fn unwrap(self) -> V { self.inner } -} - -/// Abstract type-directed pointer-movement using the MovePtr trait -impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> { - 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::<bool>(); - if ! self.inner.visit_bool() { return false; } - self.bump_past::<bool>(); - true - } - - fn visit_int(&mut self) -> bool { - self.align_to::<int>(); - if ! self.inner.visit_int() { return false; } - self.bump_past::<int>(); - true - } - - fn visit_i8(&mut self) -> bool { - self.align_to::<i8>(); - if ! self.inner.visit_i8() { return false; } - self.bump_past::<i8>(); - true - } - - fn visit_i16(&mut self) -> bool { - self.align_to::<i16>(); - if ! self.inner.visit_i16() { return false; } - self.bump_past::<i16>(); - true - } - - fn visit_i32(&mut self) -> bool { - self.align_to::<i32>(); - if ! self.inner.visit_i32() { return false; } - self.bump_past::<i32>(); - true - } - - fn visit_i64(&mut self) -> bool { - self.align_to::<i64>(); - if ! self.inner.visit_i64() { return false; } - self.bump_past::<i64>(); - true - } - - fn visit_uint(&mut self) -> bool { - self.align_to::<uint>(); - if ! self.inner.visit_uint() { return false; } - self.bump_past::<uint>(); - true - } - - fn visit_u8(&mut self) -> bool { - self.align_to::<u8>(); - if ! self.inner.visit_u8() { return false; } - self.bump_past::<u8>(); - true - } - - fn visit_u16(&mut self) -> bool { - self.align_to::<u16>(); - if ! self.inner.visit_u16() { return false; } - self.bump_past::<u16>(); - true - } - - fn visit_u32(&mut self) -> bool { - self.align_to::<u32>(); - if ! self.inner.visit_u32() { return false; } - self.bump_past::<u32>(); - true - } - - fn visit_u64(&mut self) -> bool { - self.align_to::<u64>(); - if ! self.inner.visit_u64() { return false; } - self.bump_past::<u64>(); - true - } - - fn visit_f32(&mut self) -> bool { - self.align_to::<f32>(); - if ! self.inner.visit_f32() { return false; } - self.bump_past::<f32>(); - true - } - - fn visit_f64(&mut self) -> bool { - self.align_to::<f64>(); - if ! self.inner.visit_f64() { return false; } - self.bump_past::<f64>(); - true - } - - fn visit_char(&mut self) -> bool { - self.align_to::<char>(); - if ! self.inner.visit_char() { return false; } - self.bump_past::<char>(); - 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::<Box<u8>>(); - if ! self.inner.visit_box(mtbl, inner) { return false; } - self.bump_past::<Box<u8>>(); - true - } - - fn visit_uniq(&mut self, mtbl: uint, inner: *const TyDesc) -> bool { - self.align_to::<Box<u8>>(); - if ! self.inner.visit_uniq(mtbl, inner) { return false; } - self.bump_past::<Box<u8>>(); - 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::<Box<TyVisitor>>(); - if ! self.inner.visit_trait(name) { return false; } - self.bump_past::<Box<TyVisitor>>(); - 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 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/*! - -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<VariantState>, - writer: &'a mut io::Writer+'a, - last_err: Option<io::IoError>, -} - -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<T>(&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<T:Repr>(&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::<bool>() } - fn visit_int(&mut self) -> bool { self.write::<int>() } - fn visit_i8(&mut self) -> bool { self.write::<i8>() } - fn visit_i16(&mut self) -> bool { self.write::<i16>() } - fn visit_i32(&mut self) -> bool { self.write::<i32>() } - fn visit_i64(&mut self) -> bool { self.write::<i64>() } - - fn visit_uint(&mut self) -> bool { self.write::<uint>() } - fn visit_u8(&mut self) -> bool { self.write::<u8>() } - fn visit_u16(&mut self) -> bool { self.write::<u16>() } - fn visit_u32(&mut self) -> bool { self.write::<u32>() } - fn visit_u64(&mut self) -> bool { self.write::<u64>() } - - fn visit_f32(&mut self) -> bool { self.write::<f32>() } - fn visit_f64(&mut self) -> bool { self.write::<f64>() } - - fn visit_char(&mut self) -> bool { - self.get::<char>(|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::<raw::Slice<()>>(|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<T>(writer: &mut io::Writer, object: &T) -> io::IoResult<()> { - unsafe { - let ptr = object as *const T as *const u8; - let tydesc = get_tydesc::<T>(); - 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: &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: &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::<int>, "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/io/file_unix.rs b/src/libnative/io/file_unix.rs index 67aad1904b9..88f5061bbef 100644 --- a/src/libnative/io/file_unix.rs +++ b/src/libnative/io/file_unix.rs @@ -523,7 +523,7 @@ mod tests { assert_eq!(buf[2], 's' as u8); assert_eq!(buf[3], 't' as u8); } - r => fail!("invalid read: {:?}", r) + r => fail!("invalid read: {}", r) } assert!(writer.inner_read(buf).is_err()); @@ -547,7 +547,7 @@ mod tests { assert_eq!(buf[2], 's' as u8); assert_eq!(buf[3], 't' as u8); } - r => fail!("invalid read: {:?}", r) + r => fail!("invalid read: {}", r) } } } 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/driver/pretty.rs b/src/librustc/driver/pretty.rs index 9b6d6d4620d..75171af7411 100644 --- a/src/librustc/driver/pretty.rs +++ b/src/librustc/driver/pretty.rs @@ -518,7 +518,7 @@ pub fn pretty_print_input(sess: Session, } None => { let message = format!("--pretty=flowgraph needs \ - block, fn, or method; got {:?}", + block, fn, or method; got {}", node); // point to what was found, if there's an @@ -542,7 +542,6 @@ fn print_flowgraph<W:io::Writer>(variants: Vec<borrowck_dot::Variant>, blocks::BlockCode(block) => cfg::CFG::new(ty_cx, &*block), blocks::FnLikeCode(fn_like) => cfg::CFG::new(ty_cx, &*fn_like.body()), }; - debug!("cfg: {:?}", cfg); match code { _ if variants.len() == 0 => { 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/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index f0ec5beec46..b7bd97e0219 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -226,13 +226,13 @@ pub fn get_field_type(tcx: &ty::ctxt, class_id: ast::DefId, let class_doc = expect(tcx.sess.diagnostic(), decoder::maybe_find_item(class_id.node, all_items), || { - (format!("get_field_type: class ID {:?} not found", + (format!("get_field_type: class ID {} not found", class_id)).to_string() }); let the_field = expect(tcx.sess.diagnostic(), decoder::maybe_find_item(def.node, class_doc), || { - (format!("get_field_type: in class {:?}, field ID {:?} not found", + (format!("get_field_type: in class {}, field ID {} not found", class_id, def)).to_string() }); diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 009a06f5290..b9135e974c5 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -256,7 +256,7 @@ fn encode_symbol(ecx: &EncodeContext, rbml_w.start_tag(tag_items_data_item_symbol); match ecx.item_symbols.borrow().find(&id) { Some(x) => { - debug!("encode_symbol(id={:?}, str={})", id, *x); + debug!("encode_symbol(id={}, str={})", id, *x); rbml_w.writer.write(x.as_bytes()); } None => { @@ -308,7 +308,7 @@ fn encode_enum_variant_info(ecx: &EncodeContext, id: NodeId, variants: &[P<Variant>], index: &mut Vec<entry<i64>>) { - debug!("encode_enum_variant_info(id={:?})", id); + debug!("encode_enum_variant_info(id={})", id); let mut disr_val = 0; let mut i = 0; @@ -592,7 +592,7 @@ fn encode_info_for_mod(ecx: &EncodeContext, ItemImpl(..) => { let (ident, did) = (item.ident, item.id); debug!("(encoding info for module) ... encoding impl {} \ - ({:?}/{:?})", + ({}/{})", token::get_ident(ident), did, ecx.tcx.map.node_to_string(did)); @@ -853,7 +853,7 @@ fn encode_info_for_method(ecx: &EncodeContext, parent_id: NodeId, ast_item_opt: Option<&ImplItem>) { - debug!("encode_info_for_method: {:?} {}", m.def_id, + debug!("encode_info_for_method: {} {}", m.def_id, token::get_ident(m.ident)); rbml_w.start_tag(tag_items_data_item); diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index 553ec096521..34aa9310ef2 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -39,7 +39,7 @@ impl<'a> FileSearch<'a> { let mut visited_dirs = HashSet::new(); let mut found = false; - debug!("filesearch: searching additional lib search paths [{:?}]", + debug!("filesearch: searching additional lib search paths [{}]", self.addl_lib_search_paths.borrow().len()); for path in self.addl_lib_search_paths.borrow().iter() { match f(path) { @@ -66,7 +66,7 @@ impl<'a> FileSearch<'a> { for path in rustpath.iter() { let tlib_path = make_rustpkg_lib_path( self.sysroot, path, self.triple); - debug!("is {} in visited_dirs? {:?}", tlib_path.display(), + debug!("is {} in visited_dirs? {}", tlib_path.display(), visited_dirs.contains_equiv(&tlib_path.as_vec().to_vec())); if !visited_dirs.contains_equiv(&tlib_path.as_vec()) { diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index a07518cf3f2..c8d56c61d2b 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -43,6 +43,7 @@ use syntax::parse::token; // def-id will depend on where it originated from. Therefore, the conversion // function is given an indicator of the source of the def-id. See // astencode.rs for more information. +#[deriving(Show)] pub enum DefIdSource { // Identifies a struct, trait, enum, etc. NominalType, @@ -390,7 +391,7 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t { } 'p' => { let did = parse_def(st, TypeParameter, |x,y| conv(x,y)); - debug!("parsed ty_param: did={:?}", did); + debug!("parsed ty_param: did={}", did); let index = parse_uint(st); assert_eq!(next(st), '|'); let space = parse_param_space(st); @@ -603,12 +604,12 @@ pub fn parse_def_id(buf: &[u8]) -> ast::DefId { let crate_num = match uint::parse_bytes(crate_part, 10u) { Some(cn) => cn as ast::CrateNum, - None => fail!("internal error: parse_def_id: crate number expected, found {:?}", + None => fail!("internal error: parse_def_id: crate number expected, found {}", crate_part) }; let def_num = match uint::parse_bytes(def_part, 10u) { Some(dn) => dn as ast::NodeId, - None => fail!("internal error: parse_def_id: id expected, found {:?}", + None => fail!("internal error: parse_def_id: id expected, found {}", def_part) }; ast::DefId { krate: crate_num, node: def_num } diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 7cadcb745ca..ec693679b15 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -1807,7 +1807,7 @@ impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> { NominalType | TypeWithId | RegionParameter => dcx.tr_def_id(did), TypeParameter => dcx.tr_intern_def_id(did) }; - debug!("convert_def_id(source={:?}, did={:?})={:?}", source, did, r); + debug!("convert_def_id(source={}, did={})={}", source, did, r); return r; } } @@ -1841,7 +1841,7 @@ fn decode_side_tables(dcx: &DecodeContext, } c::tag_table_node_type => { let ty = val_dsr.read_ty(dcx); - debug!("inserting ty for node {:?}: {}", + debug!("inserting ty for node {}: {}", id, ty_to_string(dcx.tcx, ty)); dcx.tcx.node_types.borrow_mut().insert(id as uint, ty); } diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index df18ec30f0e..4eba46b469c 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -119,7 +119,7 @@ impl<'a, 'tcx> euv::Delegate for CheckLoanCtxt<'a, 'tcx> { loan_cause: euv::LoanCause) { debug!("borrow(borrow_id={}, cmt={}, loan_region={}, \ - bk={}, loan_cause={:?})", + bk={}, loan_cause={})", borrow_id, cmt.repr(self.tcx()), loan_region, bk, loan_cause); @@ -185,7 +185,7 @@ pub fn check_loans<'a, 'b, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, all_loans: &[Loan], decl: &ast::FnDecl, body: &ast::Block) { - debug!("check_loans(body id={:?})", body.id); + debug!("check_loans(body id={})", body.id); let mut clcx = CheckLoanCtxt { bccx: bccx, @@ -336,10 +336,10 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { //! issued when we enter `scope_id` (for example, we do not //! permit two `&mut` borrows of the same variable). - debug!("check_for_conflicting_loans(scope_id={:?})", scope_id); + debug!("check_for_conflicting_loans(scope_id={})", scope_id); let new_loan_indices = self.loans_generated_by(scope_id); - debug!("new_loan_indices = {:?}", new_loan_indices); + debug!("new_loan_indices = {}", new_loan_indices); self.each_issued_loan(scope_id, |issued_loan| { for &new_loan_index in new_loan_indices.iter() { @@ -651,7 +651,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { use_path: &LoanPath, borrow_kind: ty::BorrowKind) -> UseError { - debug!("analyze_restrictions_on_use(expr_id={:?}, use_path={})", + debug!("analyze_restrictions_on_use(expr_id={}, use_path={})", self.tcx().map.node_to_string(expr_id), use_path.repr(self.tcx())); @@ -679,7 +679,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { * is using a moved/uninitialized value */ - debug!("check_if_path_is_moved(id={:?}, use_kind={:?}, lp={})", + debug!("check_if_path_is_moved(id={}, use_kind={}, lp={})", id, use_kind, lp.repr(self.bccx.tcx)); let base_lp = owned_ptr_base_path_rc(lp); self.move_data.each_move_of(id, &base_lp, |the_move, moved_lp| { diff --git a/src/librustc/middle/borrowck/gather_loans/mod.rs b/src/librustc/middle/borrowck/gather_loans/mod.rs index f2ff104ba1d..d28baf48ddc 100644 --- a/src/librustc/middle/borrowck/gather_loans/mod.rs +++ b/src/librustc/middle/borrowck/gather_loans/mod.rs @@ -112,7 +112,7 @@ impl<'a, 'tcx> euv::Delegate for GatherLoanCtxt<'a, 'tcx> { loan_cause: euv::LoanCause) { debug!("borrow(borrow_id={}, cmt={}, loan_region={}, \ - bk={}, loan_cause={:?})", + bk={}, loan_cause={})", borrow_id, cmt.repr(self.tcx()), loan_region, bk, loan_cause); @@ -218,8 +218,8 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { * dynamically that they are not freed. */ - debug!("guarantee_valid(borrow_id={:?}, cmt={}, \ - req_mutbl={:?}, loan_region={:?})", + debug!("guarantee_valid(borrow_id={}, cmt={}, \ + req_mutbl={}, loan_region={})", borrow_id, cmt.repr(self.tcx()), req_kind, @@ -257,7 +257,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { self.bccx, borrow_span, cause, cmt.clone(), loan_region); - debug!("guarantee_valid(): restrictions={:?}", restr); + debug!("guarantee_valid(): restrictions={}", restr); // Create the loan record (if needed). let loan = match restr { @@ -289,17 +289,17 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { ty::ReInfer(..) => { self.tcx().sess.span_bug( cmt.span, - format!("invalid borrow lifetime: {:?}", + format!("invalid borrow lifetime: {}", loan_region).as_slice()); } }; - debug!("loan_scope = {:?}", loan_scope); + debug!("loan_scope = {}", loan_scope); let gen_scope = self.compute_gen_scope(borrow_id, loan_scope); - debug!("gen_scope = {:?}", gen_scope); + debug!("gen_scope = {}", gen_scope); let kill_scope = self.compute_kill_scope(loan_scope, &*loan_path); - debug!("kill_scope = {:?}", kill_scope); + debug!("kill_scope = {}", kill_scope); if req_kind == ty::MutBorrow { self.mark_loan_path_as_mutated(&*loan_path); @@ -318,7 +318,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { } }; - debug!("guarantee_valid(borrow_id={:?}), loan={}", + debug!("guarantee_valid(borrow_id={}), loan={}", borrow_id, loan.repr(self.tcx())); // let loan_path = loan.loan_path; diff --git a/src/librustc/middle/borrowck/gather_loans/restrictions.rs b/src/librustc/middle/borrowck/gather_loans/restrictions.rs index f30a370d068..bf1b4b7e476 100644 --- a/src/librustc/middle/borrowck/gather_loans/restrictions.rs +++ b/src/librustc/middle/borrowck/gather_loans/restrictions.rs @@ -21,6 +21,7 @@ use util::ppaux::Repr; use std::rc::Rc; +#[deriving(Show)] pub enum RestrictionResult { Safe, SafeIf(Rc<LoanPath>, Vec<Rc<LoanPath>>) diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index 7d0d99443b0..ec09e9e72d7 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -264,14 +264,14 @@ impl Loan { } } -#[deriving(PartialEq, Eq, Hash)] +#[deriving(PartialEq, Eq, Hash, Show)] pub enum LoanPath { LpVar(ast::NodeId), // `x` in doc.rs LpUpvar(ty::UpvarId), // `x` captured by-value into closure LpExtend(Rc<LoanPath>, mc::MutabilityCategory, LoanPathElem) } -#[deriving(PartialEq, Eq, Hash)] +#[deriving(PartialEq, Eq, Hash, Show)] pub enum LoanPathElem { LpDeref(mc::PointerKind), // `*LV` in doc.rs LpInterior(mc::InteriorKind) // `LV.f` in doc.rs @@ -421,6 +421,7 @@ pub enum AliasableViolationKind { BorrowViolation(euv::LoanCause) } +#[deriving(Show)] pub enum MovedValueUseKind { MovedInUse, MovedInCapture, @@ -530,8 +531,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { (ty::expr_ty_adjusted(self.tcx, &*expr), expr.span) } r => { - self.tcx.sess.bug(format!("MoveExpr({:?}) maps to \ - {:?}, not Expr", + self.tcx.sess.bug(format!("MoveExpr({}) maps to \ + {}, not Expr", the_move.id, r).as_slice()) } @@ -566,8 +567,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { (ty::expr_ty_adjusted(self.tcx, &*expr), expr.span) } r => { - self.tcx.sess.bug(format!("Captured({:?}) maps to \ - {:?}, not Expr", + self.tcx.sess.bug(format!("Captured({}) maps to \ + {}, not Expr", the_move.id, r).as_slice()) } @@ -892,7 +893,7 @@ impl DataFlowOperator for LoanDataFlowOperator { impl Repr for Loan { fn repr(&self, tcx: &ty::ctxt) -> String { - format!("Loan_{:?}({}, {:?}, {:?}-{:?}, {})", + format!("Loan_{}({}, {}, {}-{}, {})", self.index, self.loan_path.repr(tcx), self.kind, diff --git a/src/librustc/middle/borrowck/move_data.rs b/src/librustc/middle/borrowck/move_data.rs index eda14541961..4c2ee9fe551 100644 --- a/src/librustc/middle/borrowck/move_data.rs +++ b/src/librustc/middle/borrowck/move_data.rs @@ -68,7 +68,7 @@ pub struct FlowedMoveData<'a, 'tcx: 'a> { } /// Index into `MoveData.paths`, used like a pointer -#[deriving(PartialEq)] +#[deriving(PartialEq, Show)] pub struct MovePathIndex(uint); impl MovePathIndex { @@ -120,7 +120,7 @@ pub struct MovePath { pub next_sibling: MovePathIndex, } -#[deriving(PartialEq)] +#[deriving(PartialEq, Show)] pub enum MoveKind { Declared, // When declared, variables start out "moved". MoveExpr, // Expression or binding that moves a variable @@ -284,7 +284,7 @@ impl MoveData { } }; - debug!("move_path(lp={}, index={:?})", + debug!("move_path(lp={}, index={})", lp.repr(tcx), index); @@ -341,7 +341,7 @@ impl MoveData { * location `id` with kind `kind`. */ - debug!("add_move(lp={}, id={:?}, kind={:?})", + debug!("add_move(lp={}, id={}, kind={})", lp.repr(tcx), id, kind); @@ -372,7 +372,7 @@ impl MoveData { * location `id` with the given `span`. */ - debug!("add_assignment(lp={}, assign_id={:?}, assignee_id={:?}", + debug!("add_assignment(lp={}, assign_id={}, assignee_id={}", lp.repr(tcx), assign_id, assignee_id); let path_index = self.move_path(tcx, lp.clone()); @@ -391,12 +391,12 @@ impl MoveData { }; if self.is_var_path(path_index) { - debug!("add_assignment[var](lp={}, assignment={}, path_index={:?})", + debug!("add_assignment[var](lp={}, assignment={}, path_index={})", lp.repr(tcx), self.var_assignments.borrow().len(), path_index); self.var_assignments.borrow_mut().push(assignment); } else { - debug!("add_assignment[path](lp={}, path_index={:?})", + debug!("add_assignment[path](lp={}, path_index={})", lp.repr(tcx), path_index); self.path_assignments.borrow_mut().push(assignment); diff --git a/src/librustc/middle/cfg/construct.rs b/src/librustc/middle/cfg/construct.rs index b573c4e5948..fa5a6a2e54a 100644 --- a/src/librustc/middle/cfg/construct.rs +++ b/src/librustc/middle/cfg/construct.rs @@ -483,12 +483,12 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { let inputs = inline_asm.inputs.iter(); let outputs = inline_asm.outputs.iter(); let post_inputs = self.exprs(inputs.map(|a| { - debug!("cfg::construct InlineAsm id:{} input:{:?}", expr.id, a); + debug!("cfg::construct InlineAsm id:{} input:{}", expr.id, a); let &(_, ref expr) = a; &**expr }), pred); let post_outputs = self.exprs(outputs.map(|a| { - debug!("cfg::construct InlineAsm id:{} output:{:?}", expr.id, a); + debug!("cfg::construct InlineAsm id:{} output:{}", expr.id, a); let &(_, ref expr, _) = a; &**expr }), post_inputs); @@ -616,14 +616,14 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { } self.tcx.sess.span_bug( expr.span, - format!("no loop scope for id {:?}", + format!("no loop scope for id {}", loop_id).as_slice()); } r => { self.tcx.sess.span_bug( expr.span, - format!("bad entry `{:?}` in def_map for label", + format!("bad entry `{}` in def_map for label", r).as_slice()); } } diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index f0455db6e3b..d6b9bbded4f 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -145,7 +145,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr) -> bool { Some(&DefStruct(_)) => { } Some(&def) => { - debug!("(checking const) found bad def: {:?}", def); + debug!("(checking const) found bad def: {}", def); span_err!(v.tcx.sess, e.span, E0014, "paths in constants may only refer to constants \ or functions"); diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 3f725b86420..abccc7623a7 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -987,7 +987,7 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt, cx.tcx.sess.span_bug( p.span, format!("binding pattern {} is not an \ - identifier: {:?}", + identifier: {}", p.id, p.node).as_slice()); } diff --git a/src/librustc/middle/check_rvalues.rs b/src/librustc/middle/check_rvalues.rs index 2a2655cc49c..cd7c4b15494 100644 --- a/src/librustc/middle/check_rvalues.rs +++ b/src/librustc/middle/check_rvalues.rs @@ -51,7 +51,7 @@ impl<'a, 'tcx> euv::Delegate for RvalueContext<'a, 'tcx> { span: Span, cmt: mc::cmt, _: euv::ConsumeMode) { - debug!("consume; cmt: {:?}; type: {}", *cmt, ty_to_string(self.tcx, cmt.ty)); + debug!("consume; cmt: {}; type: {}", *cmt, ty_to_string(self.tcx, cmt.ty)); if !ty::type_is_sized(self.tcx, cmt.ty) { span_err!(self.tcx.sess, span, E0161, "cannot move a value of type {0}: the size of {0} cannot be statically determined", diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index cc1789ec642..a8b8eb2e339 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -193,8 +193,8 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { let words_per_id = (bits_per_id + uint::BITS - 1) / uint::BITS; let num_nodes = cfg.graph.all_nodes().len(); - debug!("DataFlowContext::new(analysis_name: {:s}, id_range={:?}, \ - bits_per_id={:?}, words_per_id={:?}) \ + debug!("DataFlowContext::new(analysis_name: {:s}, id_range={}, \ + bits_per_id={}, words_per_id={}) \ num_nodes: {}", analysis_name, id_range, bits_per_id, words_per_id, num_nodes); @@ -222,7 +222,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { pub fn add_gen(&mut self, id: ast::NodeId, bit: uint) { //! Indicates that `id` generates `bit` - debug!("{:s} add_gen(id={:?}, bit={:?})", + debug!("{:s} add_gen(id={}, bit={})", self.analysis_name, id, bit); assert!(self.nodeid_to_index.contains_key(&id)); assert!(self.bits_per_id > 0); @@ -235,7 +235,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { pub fn add_kill(&mut self, id: ast::NodeId, bit: uint) { //! Indicates that `id` kills `bit` - debug!("{:s} add_kill(id={:?}, bit={:?})", + debug!("{:s} add_kill(id={}, bit={})", self.analysis_name, id, bit); assert!(self.nodeid_to_index.contains_key(&id)); assert!(self.bits_per_id > 0); @@ -336,7 +336,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { let cfgidx = to_cfgidx_or_die(id, &self.nodeid_to_index); let (start, end) = self.compute_id_range(cfgidx); let gens = self.gens.slice(start, end); - debug!("{:s} each_gen_bit(id={:?}, gens={})", + debug!("{:s} each_gen_bit(id={}, gens={})", self.analysis_name, id, bits_to_string(gens)); self.each_bit(gens, f) } @@ -408,7 +408,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { } None => { debug!("{:s} add_kills_from_flow_exits flow_exit={} \ - no cfg_idx for exiting_scope={:?}", + no cfg_idx for exiting_scope={}", self.analysis_name, flow_exit, node_id); } } @@ -529,7 +529,7 @@ impl<'a, 'b, 'tcx, O:DataFlowOperator> PropagationContext<'a, 'b, 'tcx, O> { bitwise(on_entry, pred_bits, &self.dfcx.oper) }; if changed { - debug!("{:s} changed entry set for {:?} to {}", + debug!("{:s} changed entry set for {} to {}", self.dfcx.analysis_name, cfgidx, bits_to_string(self.dfcx.on_entry.slice(start, end))); self.changed = true; diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index b492203b352..bde868cdf6d 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -55,7 +55,7 @@ impl<'a, 'tcx> EffectCheckVisitor<'a, 'tcx> { } UnsafeBlock(block_id) => { // OK, but record this. - debug!("effect: recording unsafe block as used: {:?}", block_id); + debug!("effect: recording unsafe block as used: {}", block_id); self.tcx.used_unsafe.borrow_mut().insert(block_id); } UnsafeFn => {} diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 6f179e0624f..65633cfb34c 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -73,7 +73,7 @@ pub trait Delegate { mode: MutateMode); } -#[deriving(PartialEq)] +#[deriving(PartialEq, Show)] pub enum LoanCause { ClosureCapture(Span), AddrOf, @@ -85,7 +85,7 @@ pub enum LoanCause { MatchDiscriminant } -#[deriving(PartialEq,Show)] +#[deriving(PartialEq, Show)] pub enum ConsumeMode { Copy, // reference to x where x has a type that copies Move(MoveReason), // reference to x where x has a type that moves @@ -625,7 +625,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,TYPER> { * meaning either copied or moved depending on its type. */ - debug!("walk_block(blk.id={:?})", blk.id); + debug!("walk_block(blk.id={})", blk.id); for stmt in blk.stmts.iter() { self.walk_stmt(&**stmt); diff --git a/src/librustc/middle/graph.rs b/src/librustc/middle/graph.rs index 8484ec92934..463eaa40ae0 100644 --- a/src/librustc/middle/graph.rs +++ b/src/librustc/middle/graph.rs @@ -36,6 +36,7 @@ be indexed by the direction (see the type `Direction`). #![allow(dead_code)] // still WIP +use std::fmt::{Formatter, FormatError, Show}; use std::uint; pub struct Graph<N,E> { @@ -55,12 +56,20 @@ pub struct Edge<E> { pub data: E, } +impl<E: Show> Show for Edge<E> { + fn fmt(&self, f: &mut Formatter) -> Result<(), FormatError> { + write!(f, "Edge {{ next_edge: [{}, {}], source: {}, target: {}, data: {} }}", + self.next_edge[0], self.next_edge[1], self.source, + self.target, self.data) + } +} + #[deriving(Clone, PartialEq, Show)] pub struct NodeIndex(pub uint); #[allow(non_uppercase_statics)] pub const InvalidNodeIndex: NodeIndex = NodeIndex(uint::MAX); -#[deriving(PartialEq)] +#[deriving(PartialEq, Show)] pub struct EdgeIndex(pub uint); #[allow(non_uppercase_statics)] pub const InvalidEdgeIndex: EdgeIndex = EdgeIndex(uint::MAX); @@ -307,6 +316,7 @@ impl<E> Edge<E> { #[cfg(test)] mod test { use middle::graph::*; + use std::fmt::Show; type TestNode = Node<&'static str>; type TestEdge = Edge<&'static str>; @@ -361,7 +371,7 @@ mod test { }); } - fn test_adjacent_edges<N:PartialEq,E:PartialEq>(graph: &Graph<N,E>, + fn test_adjacent_edges<N:PartialEq+Show,E:PartialEq+Show>(graph: &Graph<N,E>, start_index: NodeIndex, start_data: N, expected_incoming: &[(E,N)], @@ -372,7 +382,7 @@ mod test { graph.each_incoming_edge(start_index, |edge_index, edge| { assert!(graph.edge_data(edge_index) == &edge.data); assert!(counter < expected_incoming.len()); - debug!("counter={:?} expected={:?} edge_index={:?} edge={:?}", + debug!("counter={} expected={} edge_index={} edge={}", counter, expected_incoming[counter], edge_index, edge); match expected_incoming[counter] { (ref e, ref n) => { @@ -390,7 +400,7 @@ mod test { graph.each_outgoing_edge(start_index, |edge_index, edge| { assert!(graph.edge_data(edge_index) == &edge.data); assert!(counter < expected_outgoing.len()); - debug!("counter={:?} expected={:?} edge_index={:?} edge={:?}", + debug!("counter={} expected={} edge_index={} edge={}", counter, expected_outgoing[counter], edge_index, edge); match expected_outgoing[counter] { (ref e, ref n) => { diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 3c9ebd86b94..68411549c3c 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -284,7 +284,6 @@ lets_do_this! { StartFnLangItem, "start", start_fn; TyDescStructLangItem, "ty_desc", ty_desc; - TyVisitorTraitLangItem, "ty_visitor", ty_visitor; OpaqueStructLangItem, "opaque", opaque; TypeIdLangItem, "type_id", type_id; diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index ac9df359770..490e49d051e 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -154,7 +154,7 @@ impl Clone for LiveNode { } } -#[deriving(PartialEq)] +#[deriving(PartialEq, Show)] enum LiveNodeKind { FreeVarNode(Span), ExprNode(Span), @@ -240,11 +240,13 @@ struct CaptureInfo { var_nid: NodeId } +#[deriving(Show)] struct LocalInfo { id: NodeId, ident: Ident } +#[deriving(Show)] enum VarKind { Arg(NodeId, Ident), Local(LocalInfo), @@ -307,7 +309,7 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> { ImplicitRet => {} } - debug!("{} is {:?}", v.to_string(), vk); + debug!("{} is {}", v.to_string(), vk); v } @@ -424,7 +426,7 @@ fn visit_local(ir: &mut IrMaps, local: &ast::Local) { fn visit_arm(ir: &mut IrMaps, arm: &Arm) { for pat in arm.pats.iter() { pat_util::pat_bindings(&ir.tcx.def_map, &**pat, |bm, p_id, sp, path1| { - debug!("adding local variable {} from match with bm {:?}", + debug!("adding local variable {} from match with bm {}", p_id, bm); let name = path1.node; ir.add_live_node_for_node(p_id, VarDefNode(sp)); @@ -442,7 +444,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) { // live nodes required for uses or definitions of variables: ExprPath(_) => { let def = ir.tcx.def_map.borrow().get_copy(&expr.id); - debug!("expr {}: path that leads to {:?}", expr.id, def); + debug!("expr {}: path that leads to {}", expr.id, def); match def { DefLocal(..) => ir.add_live_node_for_node(expr.id, ExprNode(expr.span)), _ => {} @@ -489,7 +491,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) { } ExprForLoop(ref pat, _, _, _) => { pat_util::pat_bindings(&ir.tcx.def_map, &**pat, |bm, p_id, sp, path1| { - debug!("adding local variable {} from for loop with bm {:?}", + debug!("adding local variable {} from for loop with bm {}", p_id, bm); let name = path1.node; ir.add_live_node_for_node(p_id, VarDefNode(sp)); @@ -733,7 +735,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { let mut wr = io::MemWriter::new(); { let wr = &mut wr as &mut io::Writer; - write!(wr, "[ln({}) of kind {:?} reads", ln.get(), self.ir.lnk(ln)); + write!(wr, "[ln({}) of kind {} reads", ln.get(), self.ir.lnk(ln)); self.write_vars(wr, ln, |idx| self.users.get(idx).reader); write!(wr, " writes"); self.write_vars(wr, ln, |idx| self.users.get(idx).writer); diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 4a1c4aaa895..c5993dcb39d 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -78,7 +78,7 @@ use syntax::parse::token; use std::cell::RefCell; use std::rc::Rc; -#[deriving(Clone, PartialEq)] +#[deriving(Clone, PartialEq, Show)] pub enum categorization { cat_rvalue(ty::Region), // temporary val, argument is its scope cat_static_item, @@ -94,7 +94,7 @@ pub enum categorization { // (*1) downcast is only required if the enum has more than one variant } -#[deriving(Clone, PartialEq)] +#[deriving(Clone, PartialEq, Show)] pub enum CopiedUpvarKind { Boxed(ast::Onceness), Unboxed(ty::UnboxedClosureKind) @@ -111,7 +111,7 @@ impl CopiedUpvarKind { } } -#[deriving(Clone, PartialEq)] +#[deriving(Clone, PartialEq, Show)] pub struct CopiedUpvar { pub upvar_id: ast::NodeId, pub kind: CopiedUpvarKind, @@ -119,7 +119,7 @@ pub struct CopiedUpvar { } // different kinds of pointers: -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, PartialEq, Eq, Hash, Show)] pub enum PointerKind { OwnedPtr, BorrowedPtr(ty::BorrowKind, ty::Region), @@ -129,19 +129,19 @@ pub enum PointerKind { // We use the term "interior" to mean "something reachable from the // base without a pointer dereference", e.g. a field -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, PartialEq, Eq, Hash, Show)] pub enum InteriorKind { InteriorField(FieldName), InteriorElement(ElementKind), } -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, PartialEq, Eq, Hash, Show)] pub enum FieldName { NamedField(ast::Name), PositionalField(uint) } -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, PartialEq, Eq, Hash, Show)] pub enum ElementKind { VecElement, OtherElement, @@ -168,7 +168,7 @@ pub enum MutabilityCategory { // dereference, but its type is the type *before* the dereference // (`@T`). So use `cmt.ty` to find the type of the value in a consistent // fashion. For more details, see the method `cat_pattern` -#[deriving(Clone, PartialEq)] +#[deriving(Clone, PartialEq, Show)] pub struct cmt_ { pub id: ast::NodeId, // id of expr/pat producing this value pub span: Span, // span of same expr/pat @@ -542,7 +542,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { expr_ty: ty::t, def: def::Def) -> McResult<cmt> { - debug!("cat_def: id={} expr={} def={:?}", + debug!("cat_def: id={} expr={} def={}", id, expr_ty.repr(self.tcx()), def); match def { @@ -781,7 +781,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { }; let method_ty = self.typer.node_method_ty(method_call); - debug!("cat_deref: method_call={:?} method_ty={}", + debug!("cat_deref: method_call={} method_ty={}", method_call, method_ty.map(|ty| ty.repr(self.tcx()))); let base_cmt = match method_ty { @@ -1352,7 +1352,7 @@ impl cmt_ { impl Repr for cmt_ { fn repr(&self, tcx: &ty::ctxt) -> String { - format!("{{{} id:{} m:{:?} ty:{}}}", + format!("{{{} id:{} m:{} ty:{}}}", self.cat.repr(tcx), self.id, self.mutbl, @@ -1368,7 +1368,7 @@ impl Repr for categorization { cat_copied_upvar(..) | cat_local(..) | cat_upvar(..) => { - format!("{:?}", *self) + format!("{}", *self) } cat_deref(ref cmt, derefs, ptr) => { format!("{}-{}{}->", cmt.cat.repr(tcx), ptr_sigil(ptr), derefs) @@ -1405,7 +1405,7 @@ impl Repr for InteriorKind { InteriorField(NamedField(fld)) => { token::get_name(fld).get().to_string() } - InteriorField(PositionalField(i)) => format!("#{:?}", i), + InteriorField(PositionalField(i)) => format!("#{}", i), InteriorElement(_) => "[]".to_string(), } } diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 8b9207134ea..6e430760e36 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -347,7 +347,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> { // This code is here instead of in visit_item so that the // crate module gets processed as well. if self.prev_exported { - assert!(self.exp_map2.contains_key(&id), "wut {:?}", id); + assert!(self.exp_map2.contains_key(&id), "wut {}", id); for export in self.exp_map2.get(&id).iter() { if is_local(export.def_id) { self.reexports.insert(export.def_id.node); @@ -394,28 +394,28 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> { fn def_privacy(&self, did: ast::DefId) -> PrivacyResult { if !is_local(did) { if self.external_exports.contains(&did) { - debug!("privacy - {:?} was externally exported", did); + debug!("privacy - {} was externally exported", did); return Allowable; } - debug!("privacy - is {:?} a public method", did); + debug!("privacy - is {} a public method", did); return match self.tcx.impl_or_trait_items.borrow().find(&did) { Some(&ty::MethodTraitItem(ref meth)) => { - debug!("privacy - well at least it's a method: {:?}", + debug!("privacy - well at least it's a method: {}", *meth); match meth.container { ty::TraitContainer(id) => { - debug!("privacy - recursing on trait {:?}", id); + debug!("privacy - recursing on trait {}", id); self.def_privacy(id) } ty::ImplContainer(id) => { match ty::impl_trait_ref(self.tcx, id) { Some(t) => { - debug!("privacy - impl of trait {:?}", id); + debug!("privacy - impl of trait {}", id); self.def_privacy(t.def_id) } None => { - debug!("privacy - found a method {:?}", + debug!("privacy - found a method {}", meth.vis); if meth.vis == ast::Public { Allowable @@ -430,17 +430,17 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> { Some(&ty::TypeTraitItem(ref typedef)) => { match typedef.container { ty::TraitContainer(id) => { - debug!("privacy - recursing on trait {:?}", id); + debug!("privacy - recursing on trait {}", id); self.def_privacy(id) } ty::ImplContainer(id) => { match ty::impl_trait_ref(self.tcx, id) { Some(t) => { - debug!("privacy - impl of trait {:?}", id); + debug!("privacy - impl of trait {}", id); self.def_privacy(t.def_id) } None => { - debug!("privacy - found a typedef {:?}", + debug!("privacy - found a typedef {}", typedef.vis); if typedef.vis == ast::Public { Allowable @@ -551,7 +551,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> { // members, so that's why we test the parent, and not the did itself. let mut cur = self.curitem; loop { - debug!("privacy - questioning {}, {:?}", self.nodestr(cur), cur); + debug!("privacy - questioning {}, {}", self.nodestr(cur), cur); match cur { // If the relevant parent is in our history, then we're allowed // to look inside any of our ancestor's immediate private items, diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 4f81aac5eb0..cf48e1899d1 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -113,7 +113,7 @@ impl RegionMaps { None => {} } - debug!("relate_free_regions(sub={:?}, sup={:?})", sub, sup); + debug!("relate_free_regions(sub={}, sup={})", sub, sup); self.free_region_map.borrow_mut().insert(sub, vec!(sup)); } @@ -211,7 +211,7 @@ impl RegionMaps { //! Returns the lifetime of the variable `id`. let scope = ty::ReScope(self.var_scope(id)); - debug!("var_region({}) = {:?}", id, scope); + debug!("var_region({}) = {}", id, scope); scope } @@ -270,7 +270,7 @@ impl RegionMaps { * duplicated with the code in infer.rs. */ - debug!("is_subregion_of(sub_region={:?}, super_region={:?})", + debug!("is_subregion_of(sub_region={}, super_region={})", sub_region, super_region); sub_region == super_region || { @@ -802,7 +802,7 @@ fn resolve_fn(visitor: &mut RegionResolutionVisitor, sp: Span, id: ast::NodeId) { debug!("region::resolve_fn(id={}, \ - span={:?}, \ + span={}, \ body.id={}, \ cx.parent={})", id, diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index a53cd52ca84..0aff56ba3cf 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -94,6 +94,7 @@ pub type ExternalExports = DefIdSet; // FIXME: dox pub type LastPrivateMap = NodeMap<LastPrivate>; +#[deriving(Show)] pub enum LastPrivate { LastMod(PrivateDep), // `use` directives (imports) can refer to two separate definitions in the @@ -107,13 +108,14 @@ pub enum LastPrivate { pub type_used: ImportUse}, } +#[deriving(Show)] pub enum PrivateDep { AllPublic, DependsOn(DefId), } // How an import is used. -#[deriving(PartialEq)] +#[deriving(PartialEq, Show)] pub enum ImportUse { Unused, // The import is not used. Used, // The import is used. @@ -135,7 +137,7 @@ enum PatternBindingMode { ArgumentIrrefutableMode, } -#[deriving(PartialEq, Eq, Hash)] +#[deriving(PartialEq, Eq, Hash, Show)] enum Namespace { TypeNS, ValueNS @@ -576,7 +578,7 @@ struct TypeNsDef { } // Records a possibly-private value definition. -#[deriving(Clone)] +#[deriving(Clone, Show)] struct ValueNsDef { is_public: bool, // see note in ImportResolution about how to use this def: Def, @@ -1761,7 +1763,7 @@ impl<'a> Resolver<'a> { ident: Ident, new_parent: ReducedGraphParent) { debug!("(building reduced graph for \ - external crate) building external def, priv {:?}", + external crate) building external def, priv {}", vis); let is_public = vis == ast::Public; let is_exported = is_public && match new_parent { @@ -1900,13 +1902,13 @@ impl<'a> Resolver<'a> { } DefMethod(..) => { debug!("(building reduced graph for external crate) \ - ignoring {:?}", def); + ignoring {}", def); // Ignored; handled elsewhere. } DefLocal(..) | DefPrimTy(..) | DefTyParam(..) | DefUse(..) | DefUpvar(..) | DefRegion(..) | DefTyParamBinder(..) | DefLabel(..) | DefSelfTy(..) => { - fail!("didn't expect `{:?}`", def); + fail!("didn't expect `{}`", def); } } } @@ -2420,7 +2422,7 @@ impl<'a> Resolver<'a> { lp: LastPrivate) -> ResolveResult<()> { debug!("(resolving single import) resolving `{}` = `{}::{}` from \ - `{}` id {}, last private {:?}", + `{}` id {}, last private {}", token::get_ident(target), self.module_to_string(&*containing_module), token::get_ident(source), @@ -2522,7 +2524,7 @@ impl<'a> Resolver<'a> { shadowable: _ }) => { debug!("(resolving single import) found \ - import in ns {:?}", namespace); + import in ns {}", namespace); let id = import_resolution.id(namespace); // track used imports and extern crates as well this.used_imports.insert((id, namespace)); @@ -2596,7 +2598,7 @@ impl<'a> Resolver<'a> { match value_result { BoundResult(ref target_module, ref name_bindings) => { - debug!("(resolving single import) found value target: {:?}", + debug!("(resolving single import) found value target: {}", { name_bindings.value_def.borrow().clone().unwrap().def }); self.check_for_conflicting_import( &import_resolution.value_target, @@ -2619,7 +2621,7 @@ impl<'a> Resolver<'a> { } match type_result { BoundResult(ref target_module, ref name_bindings) => { - debug!("(resolving single import) found type target: {:?}", + debug!("(resolving single import) found type target: {}", { name_bindings.type_def.borrow().clone().unwrap().type_def }); self.check_for_conflicting_import( &import_resolution.type_target, @@ -2724,7 +2726,7 @@ impl<'a> Resolver<'a> { .borrow(); for (ident, target_import_resolution) in import_resolutions.iter() { debug!("(resolving glob import) writing module resolution \ - {:?} into `{}`", + {} into `{}`", target_import_resolution.type_target.is_none(), self.module_to_string(module_)); @@ -3305,7 +3307,7 @@ impl<'a> Resolver<'a> { namespace: Namespace) -> ResolveResult<(Target, bool)> { debug!("(resolving item in lexical scope) resolving `{}` in \ - namespace {:?} in `{}`", + namespace {} in `{}`", token::get_ident(name), namespace, self.module_to_string(&*module_)); @@ -3339,7 +3341,7 @@ impl<'a> Resolver<'a> { None => { // Not found; continue. debug!("(resolving item in lexical scope) found \ - import resolution, but not in namespace {:?}", + import resolution, but not in namespace {}", namespace); } Some(target) => { @@ -3620,7 +3622,7 @@ impl<'a> Resolver<'a> { match import_resolution.target_for_namespace(namespace) { None => { debug!("(resolving name in module) name found, \ - but not in namespace {:?}", + but not in namespace {}", namespace); } Some(target) => { @@ -3780,7 +3782,7 @@ impl<'a> Resolver<'a> { match namebindings.def_for_namespace(ns) { Some(d) => { let name = token::get_name(name); - debug!("(computing exports) YES: export '{}' => {:?}", + debug!("(computing exports) YES: export '{}' => {}", name, d.def_id()); exports2.push(Export2 { name: name.get().to_string(), @@ -3788,7 +3790,7 @@ impl<'a> Resolver<'a> { }); } d_opt => { - debug!("(computing exports) NO: {:?}", d_opt); + debug!("(computing exports) NO: {}", d_opt); } } } @@ -4447,7 +4449,7 @@ impl<'a> Resolver<'a> { Some(def) => { match def { (DefTrait(_), _) => { - debug!("(resolving trait) found trait def: {:?}", def); + debug!("(resolving trait) found trait def: {}", def); self.record_def(trait_reference.ref_id, def); } (def, _) => { @@ -4840,7 +4842,7 @@ impl<'a> Resolver<'a> { match self.resolve_path(ty.id, path, TypeNS, true) { Some(def) => { debug!("(resolving type) resolved `{}` to \ - type {:?}", + type {}", token::get_ident(path.segments .last().unwrap() .identifier), @@ -5124,7 +5126,7 @@ impl<'a> Resolver<'a> { } result => { debug!("(resolving pattern) didn't find struct \ - def: {:?}", result); + def: {}", result); let msg = format!("`{}` does not name a structure", self.path_idents_to_string(path)); self.resolve_error(path.span, msg.as_slice()); @@ -5148,7 +5150,7 @@ impl<'a> Resolver<'a> { ValueNS) { Success((target, _)) => { debug!("(resolve bare identifier pattern) succeeded in \ - finding {} at {:?}", + finding {} at {}", token::get_ident(name), target.bindings.value_def.borrow()); match *target.bindings.value_def.borrow() { @@ -5489,7 +5491,7 @@ impl<'a> Resolver<'a> { match search_result { Some(DlDef(def)) => { debug!("(resolving path in local ribs) resolved `{}` to \ - local: {:?}", + local: {}", token::get_ident(ident), def); return Some(def); @@ -5840,7 +5842,7 @@ impl<'a> Resolver<'a> { Some(definition) => self.record_def(expr.id, definition), result => { debug!("(resolving expression) didn't find struct \ - def: {:?}", result); + def: {}", result); let msg = format!("`{}` does not name a structure", self.path_idents_to_string(path)); self.resolve_error(path.span, msg.as_slice()); @@ -6026,7 +6028,7 @@ impl<'a> Resolver<'a> { } fn record_def(&mut self, node_id: NodeId, (def, lp): (Def, LastPrivate)) { - debug!("(recording def) recording {:?} for {:?}, last private {:?}", + debug!("(recording def) recording {} for {}, last private {}", def, node_id, lp); assert!(match lp {LastImport{..} => false, _ => true}, "Import should only be used for `use` directives"); @@ -6038,8 +6040,8 @@ impl<'a> Resolver<'a> { // the same conclusion! - nmatsakis Occupied(entry) => if def != *entry.get() { self.session - .bug(format!("node_id {:?} resolved first to {:?} and \ - then {:?}", + .bug(format!("node_id {} resolved first to {} and \ + then {}", node_id, *entry.get(), def).as_slice()); diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 6d84b8cb49d..6f517f1f166 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -57,6 +57,7 @@ struct LifetimeContext<'a> { scope: Scope<'a> } +#[deriving(Show)] enum ScopeChain<'a> { /// EarlyScope(i, ['a, 'b, ...], s) extends s with early-bound /// lifetimes, assigning indexes 'a => i, 'b => i+1, ... etc. @@ -118,10 +119,10 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> { }; self.with(|_, f| f(EarlyScope(subst::TypeSpace, lifetimes, &ROOT_SCOPE)), |v| { - debug!("entering scope {:?}", v.scope); + debug!("entering scope {}", v.scope); v.check_lifetime_defs(lifetimes); visit::walk_item(v, item); - debug!("exiting scope {:?}", v.scope); + debug!("exiting scope {}", v.scope); }); } @@ -268,7 +269,7 @@ impl<'a> LifetimeContext<'a> { let referenced_idents = early_bound_lifetime_names(generics); debug!("pushing fn scope id={} due to fn item/method\ - referenced_idents={:?}", + referenced_idents={}", n, referenced_idents.iter().map(lifetime_show).collect::<Vec<token::InternedString>>()); let lifetimes = &generics.lifetimes; @@ -439,7 +440,7 @@ impl<'a> LifetimeContext<'a> { probably a bug in syntax::fold"); } - debug!("lifetime_ref={} id={} resolved to {:?}", + debug!("lifetime_ref={} id={} resolved to {}", lifetime_to_string(lifetime_ref), lifetime_ref.id, def); diff --git a/src/librustc/middle/save/mod.rs b/src/librustc/middle/save/mod.rs index 21810b608b4..9dfde7ec084 100644 --- a/src/librustc/middle/save/mod.rs +++ b/src/librustc/middle/save/mod.rs @@ -246,7 +246,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> { def::DefUse(_) | def::DefMethod(..) | def::DefPrimTy(_) => { - self.sess.span_bug(span, format!("lookup_def_kind for unexpected item: {:?}", + self.sess.span_bug(span, format!("lookup_def_kind for unexpected item: {}", def).as_slice()); }, } @@ -313,7 +313,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> { }, _ => { self.sess.span_bug(method.span, - format!("Container {} for method {} is not a node item {:?}", + format!("Container {} for method {} is not a node item {}", impl_id.node, method.id, self.analysis.ty_cx.map.get(impl_id.node) @@ -1415,7 +1415,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> { // FIXME(nrc) what is this doing here? def::DefStatic(_, _) => {} def::DefConst(..) => {} - _ => error!("unexpected definition kind when processing collected paths: {:?}", + _ => error!("unexpected definition kind when processing collected paths: {}", *def) } } diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 3a1058c009f..c31a3730a7c 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -226,6 +226,7 @@ use syntax::codemap::Span; use syntax::fold::Folder; use syntax::ptr::P; +#[deriving(Show)] struct ConstantExpr<'a>(&'a ast::Expr); impl<'a> ConstantExpr<'a> { @@ -240,6 +241,7 @@ impl<'a> ConstantExpr<'a> { } // An option identifying a branch (either a literal, an enum variant or a range) +#[deriving(Show)] enum Opt<'a> { ConstantValue(ConstantExpr<'a>), ConstantRange(ConstantExpr<'a>, ConstantExpr<'a>), @@ -519,7 +521,7 @@ fn enter_opt<'a, 'p, 'blk, 'tcx>( variant_size: uint, val: ValueRef) -> Vec<Match<'a, 'p, 'blk, 'tcx>> { - debug!("enter_opt(bcx={}, m={}, opt={:?}, col={}, val={})", + debug!("enter_opt(bcx={}, m={}, opt={}, col={}, val={})", bcx.to_str(), m.repr(bcx.tcx()), *opt, @@ -863,7 +865,7 @@ fn insert_lllocals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, _ => {} } - debug!("binding {:?} to {}", + debug!("binding {} to {}", binding_info.id, bcx.val_to_string(llval)); bcx.fcx.lllocals.borrow_mut().insert(binding_info.id, datum); @@ -1048,7 +1050,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, // Decide what kind of branch we need let opts = get_branches(bcx, m, col); - debug!("options={:?}", opts); + debug!("options={}", opts); let mut kind = NoBranch; let mut test_val = val; debug!("test_val={}", bcx.val_to_string(test_val)); diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs index f88b010c28a..2f06f16ace1 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc/middle/trans/adt.rs @@ -74,7 +74,7 @@ type Hint = attr::ReprAttr; /// Representations. -#[deriving(Eq, PartialEq)] +#[deriving(Eq, PartialEq, Show)] pub enum Repr { /// C-like enums; basically an int. CEnum(IntType, Disr, Disr), // discriminant range (signedness based on the IntType) @@ -127,7 +127,7 @@ pub enum Repr { } /// For structs, and struct-like parts of anything fancier. -#[deriving(Eq, PartialEq)] +#[deriving(Eq, PartialEq, Show)] pub struct Struct { // If the struct is DST, then the size and alignment do not take into // account the unsized fields of the struct. @@ -156,7 +156,7 @@ pub fn represent_type(cx: &CrateContext, t: ty::t) -> Rc<Repr> { } let repr = Rc::new(represent_type_uncached(cx, t)); - debug!("Represented as: {:?}", repr) + debug!("Represented as: {}", repr) cx.adt_reprs().borrow_mut().insert(t, repr.clone()); repr } @@ -371,6 +371,7 @@ fn mk_struct(cx: &CrateContext, tys: &[ty::t], packed: bool) -> Struct { } } +#[deriving(Show)] struct IntBounds { slo: i64, shi: i64, @@ -387,7 +388,7 @@ fn mk_cenum(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> Repr { } fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntType { - debug!("range_to_inttype: {:?} {:?}", hint, bounds); + debug!("range_to_inttype: {} {}", hint, bounds); // Lists of sizes to try. u64 is always allowed as a fallback. #[allow(non_uppercase_statics)] static choose_shortest: &'static[IntType] = &[ @@ -440,7 +441,7 @@ pub fn ll_inttype(cx: &CrateContext, ity: IntType) -> Type { } fn bounds_usable(cx: &CrateContext, ity: IntType, bounds: &IntBounds) -> bool { - debug!("bounds_usable: {:?} {:?}", ity, bounds); + debug!("bounds_usable: {} {}", ity, bounds); match ity { attr::SignedInt(_) => { let lllo = C_integral(ll_inttype(cx, ity), bounds.slo as u64, true); @@ -538,7 +539,7 @@ fn generic_type_of(cx: &CrateContext, Type::array(&Type::i64(cx), align_units), a if a.count_ones() == 1 => Type::array(&Type::vector(&Type::i32(cx), a / 4), align_units), - _ => fail!("unsupported enum alignment: {:?}", align) + _ => fail!("unsupported enum alignment: {}", align) }; assert_eq!(machine::llalign_of_min(cx, pad_ty) as u64, align); assert_eq!(align % discr_size, 0); diff --git a/src/librustc/middle/trans/asm.rs b/src/librustc/middle/trans/asm.rs index d898931cb33..f4586fca52f 100644 --- a/src/librustc/middle/trans/asm.rs +++ b/src/librustc/middle/trans/asm.rs @@ -101,7 +101,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm) constraints.push_str(clobbers.as_slice()); } - debug!("Asm Constraints: {:?}", constraints.as_slice()); + debug!("Asm Constraints: {}", constraints.as_slice()); let num_outputs = outputs.len(); diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index ebc46bb2bfc..c7809690344 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -1088,7 +1088,7 @@ pub fn ignore_lhs(_bcx: Block, local: &ast::Local) -> bool { pub fn init_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, local: &ast::Local) -> Block<'blk, 'tcx> { - debug!("init_local(bcx={}, local.id={:?})", bcx.to_str(), local.id); + debug!("init_local(bcx={}, local.id={})", bcx.to_str(), local.id); let _indenter = indenter(); let _icx = push_ctxt("init_local"); _match::store_local(bcx, local) @@ -2468,24 +2468,6 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t) .arg(idx, llvm::DereferenceableAttribute(llsz)); } - // The visit glue deals only with opaque pointers so we don't - // actually know the concrete type of Self thus we don't know how - // many bytes to mark as dereferenceable so instead we just mark - // it as nonnull which still holds true - ty::ty_rptr(b, ty::mt { ty: it, mutbl }) if match ty::get(it).sty { - ty::ty_param(_) => true, _ => false - } && mutbl == ast::MutMutable => { - attrs.arg(idx, llvm::NoAliasAttribute) - .arg(idx, llvm::NonNullAttribute); - - match b { - ReLateBound(_, BrAnon(_)) => { - attrs.arg(idx, llvm::NoCaptureAttribute); - } - _ => {} - } - } - // `&mut` pointer parameters never alias other parameters, or mutable global data // // `&T` where `T` contains no `UnsafeCell<U>` is immutable, and can be marked as both @@ -2672,7 +2654,7 @@ fn contains_null(s: &str) -> bool { } pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef { - debug!("get_item_val(id=`{:?}`)", id); + debug!("get_item_val(id=`{}`)", id); match ccx.item_vals().borrow().find_copy(&id) { Some(v) => return v, @@ -2857,7 +2839,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef { } ref variant => { - ccx.sess().bug(format!("get_item_val(): unexpected variant: {:?}", + ccx.sess().bug(format!("get_item_val(): unexpected variant: {}", variant).as_slice()) } }; diff --git a/src/librustc/middle/trans/builder.rs b/src/librustc/middle/trans/builder.rs index 11cf2402782..dbc668a04ba 100644 --- a/src/librustc/middle/trans/builder.rs +++ b/src/librustc/middle/trans/builder.rs @@ -795,11 +795,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { else { llvm::False }; let argtys = inputs.iter().map(|v| { - debug!("Asm Input Type: {:?}", self.ccx.tn().val_to_string(*v)); + debug!("Asm Input Type: {}", self.ccx.tn().val_to_string(*v)); val_ty(*v) }).collect::<Vec<_>>(); - debug!("Asm Output Type: {:?}", self.ccx.tn().type_to_string(output)); + debug!("Asm Output Type: {}", self.ccx.tn().type_to_string(output)); let fty = Type::func(argtys.as_slice(), &output); unsafe { let v = llvm::LLVMInlineAsm( diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index bb32fdcea7e..f607dfdd17f 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -209,7 +209,7 @@ fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr) def::DefSelfTy(..) => { bcx.tcx().sess.span_bug( ref_expr.span, - format!("cannot translate def {:?} \ + format!("cannot translate def {} \ to a callable thing!", def).as_slice()); } } @@ -226,7 +226,7 @@ pub fn trans_fn_ref(bcx: Block, def_id: ast::DefId, node: ExprOrMethodCall) -> V let _icx = push_ctxt("trans_fn_ref"); let substs = node_id_substs(bcx, node); - debug!("trans_fn_ref(def_id={}, node={:?}, substs={})", + debug!("trans_fn_ref(def_id={}, node={}, substs={})", def_id.repr(bcx.tcx()), node, substs.repr(bcx.tcx())); @@ -398,7 +398,7 @@ pub fn trans_fn_ref_with_substs( let ccx = bcx.ccx(); let tcx = bcx.tcx(); - debug!("trans_fn_ref_with_substs(bcx={}, def_id={}, node={:?}, \ + debug!("trans_fn_ref_with_substs(bcx={}, def_id={}, node={}, \ substs={})", bcx.to_str(), def_id.repr(tcx), diff --git a/src/librustc/middle/trans/cleanup.rs b/src/librustc/middle/trans/cleanup.rs index f3844a956fa..9edca215aef 100644 --- a/src/librustc/middle/trans/cleanup.rs +++ b/src/librustc/middle/trans/cleanup.rs @@ -23,6 +23,7 @@ use middle::trans::debuginfo; use middle::trans::glue; use middle::trans::type_::Type; use middle::ty; +use std::fmt; use syntax::ast; use util::ppaux::Repr; @@ -45,6 +46,7 @@ pub struct CleanupScope<'blk, 'tcx: 'blk> { cached_landing_pad: Option<BasicBlockRef>, } +#[deriving(Show)] pub struct CustomScopeIndex { index: uint } @@ -59,7 +61,23 @@ pub enum CleanupScopeKind<'blk, 'tcx: 'blk> { LoopScopeKind(ast::NodeId, [Block<'blk, 'tcx>, ..EXIT_MAX]) } -#[deriving(PartialEq)] +impl<'blk, 'tcx: 'blk> fmt::Show for CleanupScopeKind<'blk, 'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::FormatError> { + match *self { + CustomScopeKind => write!(f, "CustomScopeKind"), + AstScopeKind(nid) => write!(f, "AstScopeKind({})", nid), + LoopScopeKind(nid, ref blks) => { + try!(write!(f, "LoopScopeKind({}, [", nid)); + for blk in blks.iter() { + try!(write!(f, "{:p}, ", blk)); + } + write!(f, "])") + } + } + } +} + +#[deriving(PartialEq, Show)] pub enum EarlyExitLabel { UnwindExit, ReturnExit, @@ -83,6 +101,7 @@ pub trait Cleanup { pub type CleanupObj = Box<Cleanup+'static>; +#[deriving(Show)] pub enum ScopeId { AstScope(ast::NodeId), CustomScope(CustomScopeIndex) @@ -222,7 +241,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { * cleanups for normal exit. */ - debug!("pop_and_trans_custom_cleanup_scope({:?})", custom_scope); + debug!("pop_and_trans_custom_cleanup_scope({})", custom_scope); assert!(self.is_valid_to_pop_custom_scope(custom_scope)); let scope = self.pop_scope(); @@ -273,7 +292,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { ptr: val, }; - debug!("schedule_lifetime_end({:?}, val={})", + debug!("schedule_lifetime_end({}, val={})", cleanup_scope, self.ccx.tn().val_to_string(val)); @@ -298,7 +317,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { zero: false }; - debug!("schedule_drop_mem({:?}, val={}, ty={})", + debug!("schedule_drop_mem({}, val={}, ty={})", cleanup_scope, self.ccx.tn().val_to_string(val), ty.repr(self.ccx.tcx())); @@ -324,7 +343,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { zero: true }; - debug!("schedule_drop_and_zero_mem({:?}, val={}, ty={}, zero={})", + debug!("schedule_drop_and_zero_mem({}, val={}, ty={}, zero={})", cleanup_scope, self.ccx.tn().val_to_string(val), ty.repr(self.ccx.tcx()), @@ -350,7 +369,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { zero: false }; - debug!("schedule_drop_immediate({:?}, val={}, ty={})", + debug!("schedule_drop_immediate({}, val={}, ty={})", cleanup_scope, self.ccx.tn().val_to_string(val), ty.repr(self.ccx.tcx())); @@ -370,7 +389,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { let drop = box FreeValue { ptr: val, heap: heap, content_ty: content_ty }; - debug!("schedule_free_value({:?}, val={}, heap={:?})", + debug!("schedule_free_value({}, val={}, heap={})", cleanup_scope, self.ccx.tn().val_to_string(val), heap); @@ -391,7 +410,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { let drop = box FreeSlice { ptr: val, size: size, align: align, heap: heap }; - debug!("schedule_free_slice({:?}, val={}, heap={:?})", + debug!("schedule_free_slice({}, val={}, heap={})", cleanup_scope, self.ccx.tn().val_to_string(val), heap); @@ -417,7 +436,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { * in the topmost scope, which must be a temporary scope. */ - debug!("schedule_clean_in_ast_scope(cleanup_scope={:?})", + debug!("schedule_clean_in_ast_scope(cleanup_scope={})", cleanup_scope); for scope in self.scopes.borrow_mut().iter_mut().rev() { @@ -598,7 +617,7 @@ impl<'blk, 'tcx> CleanupHelperMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx * perform all cleanups and finally branch to the `break_blk`. */ - debug!("trans_cleanups_to_exit_scope label={:?} scopes={}", + debug!("trans_cleanups_to_exit_scope label={} scopes={}", label, self.scopes_len()); let orig_scopes_len = self.scopes_len(); @@ -634,7 +653,7 @@ impl<'blk, 'tcx> CleanupHelperMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx LoopExit(id, _) => { self.ccx.sess().bug(format!( - "cannot exit from scope {:?}, \ + "cannot exit from scope {}, \ not in scope", id).as_slice()); } } @@ -968,6 +987,7 @@ impl Cleanup for DropValue { } } +#[deriving(Show)] pub enum Heap { HeapExchange } @@ -1072,7 +1092,7 @@ pub fn temporary_scope(tcx: &ty::ctxt, match tcx.region_maps.temporary_scope(id) { Some(scope) => { let r = AstScope(scope); - debug!("temporary_scope({}) = {:?}", id, r); + debug!("temporary_scope({}) = {}", id, r); r } None => { @@ -1086,7 +1106,7 @@ pub fn var_scope(tcx: &ty::ctxt, id: ast::NodeId) -> ScopeId { let r = AstScope(tcx.region_maps.var_scope(id)); - debug!("var_scope({}) = {:?}", id, r); + debug!("var_scope({}) = {}", id, r); r } diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index 1e2e8c589c6..8f877f981c8 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -550,7 +550,7 @@ pub fn get_wrapper_for_bare_fn(ccx: &CrateContext, _ => { ccx.sess().bug(format!("get_wrapper_for_bare_fn: \ expected a statically resolved fn, got \ - {:?}", + {}", def).as_slice()); } }; diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index 9c1fcaa9ce8..a681a750f0b 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -130,7 +130,6 @@ pub struct tydesc_info { pub size: ValueRef, pub align: ValueRef, pub name: ValueRef, - pub visit_glue: Cell<Option<ValueRef>>, } /* @@ -468,7 +467,7 @@ impl<'blk, 'tcx> BlockS<'blk, 'tcx> { Some(v) => v.clone(), None => { self.tcx().sess.bug(format!( - "no def associated with node id {:?}", nid).as_slice()); + "no def associated with node id {}", nid).as_slice()); } } } @@ -704,7 +703,7 @@ pub fn const_get_elt(cx: &CrateContext, v: ValueRef, us: &[c_uint]) unsafe { let r = llvm::LLVMConstExtractValue(v, us.as_ptr(), us.len() as c_uint); - debug!("const_get_elt(v={}, us={:?}, r={})", + debug!("const_get_elt(v={}, us={}, r={})", cx.tn().val_to_string(v), us, cx.tn().val_to_string(r)); return r; @@ -865,7 +864,7 @@ pub fn fulfill_obligation(ccx: &CrateContext, } // Key used to lookup values supplied for type parameters in an expr. -#[deriving(PartialEq)] +#[deriving(PartialEq, Show)] pub enum ExprOrMethodCall { // Type parameters for a path like `None::<int>` ExprId(ast::NodeId), @@ -891,7 +890,7 @@ pub fn node_id_substs(bcx: Block, if substs.types.any(|t| ty::type_needs_infer(*t)) { bcx.sess().bug( - format!("type parameters for node {:?} include inference types: \ + format!("type parameters for node {} include inference types: \ {}", node, substs.repr(bcx.tcx())).as_slice()); diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index ec357f7bfd7..d83c46be14a 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -210,7 +210,7 @@ pub fn const_expr(cx: &CrateContext, e: &ast::Expr) -> (ValueRef, ty::t) { ty::AdjustAddEnv(store) => { cx.sess() .span_bug(e.span, - format!("unexpected static function: {:?}", + format!("unexpected static function: {}", store).as_slice()) } ty::AdjustDerefRef(ref adj) => { @@ -279,7 +279,7 @@ pub fn const_expr(cx: &CrateContext, e: &ast::Expr) -> (ValueRef, ty::t) { cx.sess() .span_bug(e.span, format!("unimplemented const \ - autoref {:?}", + autoref {}", autoref).as_slice()) } } diff --git a/src/librustc/middle/trans/context.rs b/src/librustc/middle/trans/context.rs index ee5ba61a295..67ae93e25c6 100644 --- a/src/librustc/middle/trans/context.rs +++ b/src/librustc/middle/trans/context.rs @@ -72,7 +72,6 @@ pub struct SharedCrateContext<'tcx> { available_monomorphizations: RefCell<HashSet<String>>, available_drop_glues: RefCell<HashMap<ty::t, String>>, - available_visit_glues: RefCell<HashMap<ty::t, String>>, } /// The local portion of a `CrateContext`. There is one `LocalCrateContext` @@ -275,7 +274,6 @@ impl<'tcx> SharedCrateContext<'tcx> { }, available_monomorphizations: RefCell::new(HashSet::new()), available_drop_glues: RefCell::new(HashMap::new()), - available_visit_glues: RefCell::new(HashMap::new()), }; for i in range(0, local_count) { @@ -682,10 +680,6 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> { &self.shared.available_drop_glues } - pub fn available_visit_glues<'a>(&'a self) -> &'a RefCell<HashMap<ty::t, String>> { - &self.shared.available_visit_glues - } - pub fn int_type(&self) -> Type { self.local.int_type } diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index 424007519af..fe9f832e44a 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -138,7 +138,7 @@ pub fn trans_if<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, els: Option<&ast::Expr>, dest: expr::Dest) -> Block<'blk, 'tcx> { - debug!("trans_if(bcx={}, if_id={}, cond={}, thn={:?}, dest={})", + debug!("trans_if(bcx={}, if_id={}, cond={}, thn={}, dest={})", bcx.to_str(), if_id, bcx.expr_to_string(cond), thn.id, dest.to_string(bcx.ccx())); let _icx = push_ctxt("trans_if"); @@ -429,7 +429,7 @@ pub fn trans_break_cont<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, match bcx.tcx().def_map.borrow().find(&expr_id) { Some(&def::DefLabel(loop_id)) => loop_id, ref r => { - bcx.tcx().sess.bug(format!("{:?} in def-map for label", + bcx.tcx().sess.bug(format!("{} in def-map for label", r).as_slice()) } } diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index 260bde0f07f..ea6d9e1dd8c 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -25,6 +25,7 @@ use middle::trans::type_of; use middle::ty; use util::ppaux::{ty_to_string}; +use std::fmt; use syntax::ast; /** @@ -51,6 +52,7 @@ pub struct DatumBlock<'blk, 'tcx: 'blk, K> { pub datum: Datum<K>, } +#[deriving(Show)] pub enum Expr { /// a fresh value that was produced and which has no cleanup yet /// because it has not yet "landed" into its permanent home @@ -62,9 +64,10 @@ pub enum Expr { LvalueExpr, } -#[deriving(Clone)] +#[deriving(Clone, Show)] pub struct Lvalue; +#[deriving(Show)] pub struct Rvalue { pub mode: RvalueMode } @@ -80,7 +83,7 @@ impl Drop for Rvalue { fn drop(&mut self) { } } -#[deriving(PartialEq, Eq, Hash)] +#[deriving(PartialEq, Eq, Hash, Show)] pub enum RvalueMode { /// `val` is a pointer to the actual value (and thus has type *T) ByRef, @@ -539,7 +542,7 @@ impl Datum<Lvalue> { /** * Generic methods applicable to any sort of datum. */ -impl<K:KindOps> Datum<K> { +impl<K: KindOps + fmt::Show> Datum<K> { pub fn new(val: ValueRef, ty: ty::t, kind: K) -> Datum<K> { Datum { val: val, ty: ty, kind: kind } } @@ -615,7 +618,7 @@ impl<K:KindOps> Datum<K> { #[allow(dead_code)] // useful for debugging pub fn to_string(&self, ccx: &CrateContext) -> String { - format!("Datum({}, {}, {:?})", + format!("Datum({}, {}, {})", ccx.tn().val_to_string(self.val), ty_to_string(ccx.tcx(), self.ty), self.kind) @@ -658,7 +661,7 @@ impl<'blk, 'tcx, K> DatumBlock<'blk, 'tcx, K> { } } -impl<'blk, 'tcx, K:KindOps> DatumBlock<'blk, 'tcx, K> { +impl<'blk, 'tcx, K: KindOps + fmt::Show> DatumBlock<'blk, 'tcx, K> { pub fn to_expr_datumblock(self) -> DatumBlock<'blk, 'tcx, Expr> { DatumBlock::new(self.bcx, self.datum.to_expr_datum()) } diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index d81f78f23ff..4e3eaf26f42 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -468,7 +468,7 @@ impl TypeMap { &mut unique_type_id); }, _ => { - cx.sess().bug(format!("get_unique_type_id_of_type() - unexpected type: {}, {:?}", + cx.sess().bug(format!("get_unique_type_id_of_type() - unexpected type: {}, {}", ppaux::ty_to_string(cx.tcx(), type_).as_slice(), ty::get(type_).sty).as_slice()) } @@ -783,14 +783,14 @@ pub fn create_global_var_metadata(cx: &CrateContext, format!("debuginfo::\ create_global_var_metadata() - Captured var-id refers to \ - unexpected ast_item variant: {:?}", + unexpected ast_item variant: {}", var_item).as_slice()) } } }, _ => cx.sess().bug(format!("debuginfo::create_global_var_metadata() \ - Captured var-id refers to unexpected \ - ast_map variant: {:?}", + ast_map variant: {}", var_item).as_slice()) }; @@ -846,7 +846,7 @@ pub fn create_local_var_metadata(bcx: Block, local: &ast::Local) { Some(datum) => datum, None => { bcx.sess().span_bug(span, - format!("no entry in lllocals table for {:?}", + format!("no entry in lllocals table for {}", node_id).as_slice()); } }; @@ -896,7 +896,7 @@ pub fn create_captured_var_metadata(bcx: Block, format!( "debuginfo::create_captured_var_metadata() - \ Captured var-id refers to unexpected \ - ast_map variant: {:?}", + ast_map variant: {}", ast_item).as_slice()); } } @@ -906,7 +906,7 @@ pub fn create_captured_var_metadata(bcx: Block, .span_bug(span, format!("debuginfo::create_captured_var_metadata() - \ Captured var-id refers to unexpected \ - ast_map variant: {:?}", + ast_map variant: {}", ast_item).as_slice()); } }; @@ -1009,7 +1009,7 @@ pub fn create_argument_metadata(bcx: Block, arg: &ast::Arg) { Some(v) => v, None => { bcx.sess().span_bug(span, - format!("no entry in lllocals table for {:?}", + format!("no entry in lllocals table for {}", node_id).as_slice()); } }; @@ -1250,7 +1250,7 @@ pub fn create_function_debug_context(cx: &CrateContext, _ => { cx.sess() .bug(format!("create_function_debug_context: \ - unexpected sort of node: {:?}", + unexpected sort of node: {}", fnitem).as_slice()) } } @@ -1261,7 +1261,7 @@ pub fn create_function_debug_context(cx: &CrateContext, return FunctionDebugContext { repr: FunctionWithoutDebugInfo }; } _ => cx.sess().bug(format!("create_function_debug_context: \ - unexpected sort of node: {:?}", + unexpected sort of node: {}", fnitem).as_slice()) }; @@ -1542,7 +1542,7 @@ fn compile_unit_metadata(cx: &CrateContext) { } }; - debug!("compile_unit_metadata: {:?}", compile_unit_name); + debug!("compile_unit_metadata: {}", compile_unit_name); let producer = format!("rustc version {}", (option_env!("CFG_VERSION")).expect("CFG_VERSION")); @@ -1703,7 +1703,7 @@ fn scope_metadata(fcx: &FunctionContext, let node = fcx.ccx.tcx().map.get(node_id); fcx.ccx.sess().span_bug(error_reporting_span, - format!("debuginfo: Could not find scope info for node {:?}", + format!("debuginfo: Could not find scope info for node {}", node).as_slice()); } } @@ -1711,7 +1711,7 @@ fn scope_metadata(fcx: &FunctionContext, fn basic_type_metadata(cx: &CrateContext, t: ty::t) -> DIType { - debug!("basic_type_metadata: {:?}", ty::get(t)); + debug!("basic_type_metadata: {}", ty::get(t)); let (name, encoding) = match ty::get(t).sty { ty::ty_nil => ("()".to_string(), DW_ATE_unsigned), @@ -2855,7 +2855,7 @@ fn type_metadata(cx: &CrateContext, } }; - debug!("type_metadata: {:?}", ty::get(t)); + debug!("type_metadata: {}", ty::get(t)); let sty = &ty::get(t).sty; let MetadataCreationResult { metadata, already_stored_in_typemap } = match *sty { @@ -2937,7 +2937,7 @@ fn type_metadata(cx: &CrateContext, usage_site_span).finalize(cx) } _ => { - cx.sess().bug(format!("debuginfo: unexpected type in type_metadata: {:?}", + cx.sess().bug(format!("debuginfo: unexpected type in type_metadata: {}", sty).as_slice()) } }; @@ -3991,7 +3991,7 @@ fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId) -> Rc<NamespaceTree Some(node) => node, None => { cx.sess().bug(format!("debuginfo::namespace_for_item(): \ - path too short for {:?}", + path too short for {}", def_id).as_slice()); } } diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 19c9c5e0119..bcbc9fff834 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -666,7 +666,7 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, bcx.tcx().sess.span_bug( expr.span, format!("trans_rvalue_datum_unadjusted reached \ - fall-through case: {:?}", + fall-through case: {}", expr.node).as_slice()); } } @@ -982,7 +982,7 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, bcx.tcx().sess.span_bug( expr.span, format!("trans_rvalue_stmt_unadjusted reached \ - fall-through case: {:?}", + fall-through case: {}", expr.node).as_slice()); } } @@ -1128,7 +1128,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, bcx.tcx().sess.span_bug( expr.span, format!("trans_rvalue_dps_unadjusted reached fall-through \ - case: {:?}", + case: {}", expr.node).as_slice()); } } @@ -1176,7 +1176,7 @@ fn trans_def_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } _ => { bcx.tcx().sess.span_bug(ref_expr.span, format!( - "Non-DPS def {:?} referened by {}", + "Non-DPS def {} referened by {}", def, bcx.node_id_to_string(ref_expr.id)).as_slice()); } } @@ -1200,7 +1200,7 @@ fn trans_def_fn_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } _ => { bcx.tcx().sess.span_bug(ref_expr.span, format!( - "trans_def_fn_unadjusted invoked on: {:?} for {}", + "trans_def_fn_unadjusted invoked on: {} for {}", def, ref_expr.repr(bcx.tcx())).as_slice()); } @@ -1228,7 +1228,7 @@ pub fn trans_local_var<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, Some(&val) => Datum::new(val, local_ty, Lvalue), None => { bcx.sess().bug(format!( - "trans_local_var: no llval for upvar {:?} found", + "trans_local_var: no llval for upvar {} found", nid).as_slice()); } } @@ -1238,17 +1238,17 @@ pub fn trans_local_var<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, Some(&v) => v, None => { bcx.sess().bug(format!( - "trans_local_var: no datum for local/arg {:?} found", + "trans_local_var: no datum for local/arg {} found", nid).as_slice()); } }; - debug!("take_local(nid={:?}, v={}, ty={})", + debug!("take_local(nid={}, v={}, ty={})", nid, bcx.val_to_string(datum.val), bcx.ty_to_string(datum.ty)); datum } _ => { bcx.sess().unimpl(format!( - "unsupported def type in trans_local_var: {:?}", + "unsupported def type in trans_local_var: {}", def).as_slice()); } } @@ -1869,7 +1869,7 @@ fn float_cast(bcx: Block, } else { llsrc }; } -#[deriving(PartialEq)] +#[deriving(PartialEq, Show)] pub enum cast_kind { cast_pointer, cast_integral, @@ -1981,7 +1981,7 @@ fn trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, cast_float => SIToFP(bcx, lldiscrim_a, ll_t_out), _ => { ccx.sess().bug(format!("translating unsupported cast: \ - {} ({:?}) -> {} ({:?})", + {} ({}) -> {} ({})", t_in.repr(bcx.tcx()), k_in, t_out.repr(bcx.tcx()), @@ -1990,7 +1990,7 @@ fn trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } } _ => ccx.sess().bug(format!("translating unsupported cast: \ - {} ({:?}) -> {} ({:?})", + {} ({}) -> {} ({})", t_in.repr(bcx.tcx()), k_in, t_out.repr(bcx.tcx()), diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index e47adb6bc0e..cc28b803208 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -474,7 +474,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let llforeign_align = machine::llalign_of_min(ccx, llforeign_ret_ty); let llrust_align = machine::llalign_of_min(ccx, llrust_ret_ty); let llalign = cmp::min(llforeign_align, llrust_align); - debug!("llrust_size={:?}", llrust_size); + debug!("llrust_size={}", llrust_size); base::call_memcpy(bcx, llretptr_i8, llscratch_i8, C_uint(ccx, llrust_size as uint), llalign as u32); } @@ -576,7 +576,7 @@ pub fn register_rust_fn_with_foreign_abi(ccx: &CrateContext, }; let llfn = base::register_fn_llvmty(ccx, sp, sym, node_id, cconv, llfn_ty); add_argument_attributes(&tys, llfn); - debug!("register_rust_fn_with_foreign_abi(node_id={:?}, llfn_ty={}, llfn={})", + debug!("register_rust_fn_with_foreign_abi(node_id={}, llfn_ty={}, llfn={})", node_id, ccx.tn().type_to_string(llfn_ty), ccx.tn().val_to_string(llfn)); llfn } diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index 87bd451939e..f0b0d9d33e5 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -31,7 +31,6 @@ use middle::trans::datum; use middle::trans::debuginfo; use middle::trans::expr; use middle::trans::machine::*; -use middle::trans::reflect; use middle::trans::tvec; use middle::trans::type_::Type; use middle::trans::type_of::{type_of, sizing_type_of, align_of}; @@ -41,7 +40,6 @@ use util::ppaux; use arena::TypedArena; use std::c_str::ToCStr; -use std::cell::Cell; use libc::c_uint; use syntax::ast; use syntax::parse::token; @@ -186,71 +184,6 @@ pub fn get_drop_glue(ccx: &CrateContext, t: ty::t) -> ValueRef { glue } -pub fn lazily_emit_visit_glue(ccx: &CrateContext, ti: &tydesc_info) -> ValueRef { - let _icx = push_ctxt("lazily_emit_visit_glue"); - - let llfnty = Type::glue_fn(ccx, type_of(ccx, ti.ty).ptr_to()); - - match ti.visit_glue.get() { - Some(visit_glue) => visit_glue, - None => { - debug!("+++ lazily_emit_tydesc_glue VISIT {}", ppaux::ty_to_string(ccx.tcx(), ti.ty)); - - let (glue_fn, new_sym) = match ccx.available_visit_glues().borrow().find(&ti.ty) { - Some(old_sym) => { - let glue_fn = decl_cdecl_fn(ccx, old_sym.as_slice(), llfnty, ty::mk_nil()); - (glue_fn, None) - }, - None => { - let (sym, glue_fn) = declare_generic_glue(ccx, ti.ty, llfnty, "visit"); - (glue_fn, Some(sym)) - }, - }; - - ti.visit_glue.set(Some(glue_fn)); - - match new_sym { - Some(sym) => { - ccx.available_visit_glues().borrow_mut().insert(ti.ty, sym); - make_generic_glue(ccx, ti.ty, glue_fn, make_visit_glue, "visit"); - }, - None => {}, - } - - debug!("--- lazily_emit_tydesc_glue VISIT {}", ppaux::ty_to_string(ccx.tcx(), ti.ty)); - glue_fn - } - } -} - -// See [Note-arg-mode] -pub fn call_visit_glue(bcx: Block, v: ValueRef, tydesc: ValueRef) { - let _icx = push_ctxt("call_visit_glue"); - - // Select the glue function to call from the tydesc - let llfn = Load(bcx, GEPi(bcx, tydesc, [0u, abi::tydesc_field_visit_glue])); - let llrawptr = PointerCast(bcx, v, Type::i8p(bcx.ccx())); - - Call(bcx, llfn, [llrawptr], None); -} - -fn make_visit_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v: ValueRef, t: ty::t) - -> Block<'blk, 'tcx> { - let _icx = push_ctxt("make_visit_glue"); - let mut bcx = bcx; - let (visitor_trait, object_ty) = match ty::visitor_object_ty(bcx.tcx(), - ty::ReStatic, - ty::ReStatic) { - Ok(pair) => pair, - Err(s) => { - bcx.tcx().sess.fatal(s.as_slice()); - } - }; - let v = PointerCast(bcx, v, type_of(bcx.ccx(), object_ty).ptr_to()); - bcx = reflect::emit_calls_to_trait_visit_ty(bcx, t, v, visitor_trait.def_id); - bcx -} - fn trans_struct_drop_flag<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, t: ty::t, v0: ValueRef, @@ -577,7 +510,6 @@ pub fn declare_tydesc(ccx: &CrateContext, t: ty::t) -> tydesc_info { size: llsize, align: llalign, name: ty_name, - visit_glue: Cell::new(None), } } @@ -643,27 +575,11 @@ pub fn emit_tydescs(ccx: &CrateContext) { llvm::LLVMConstPointerCast(get_drop_glue(ccx, ti.ty), glue_fn_ty.to_ref()) }; ccx.stats().n_real_glues.set(ccx.stats().n_real_glues.get() + 1); - let visit_glue = - match ti.visit_glue.get() { - None => { - ccx.stats().n_null_glues.set(ccx.stats().n_null_glues.get() + - 1u); - C_null(glue_fn_ty) - } - Some(v) => { - unsafe { - ccx.stats().n_real_glues.set(ccx.stats().n_real_glues.get() + - 1); - llvm::LLVMConstPointerCast(v, glue_fn_ty.to_ref()) - } - } - }; let tydesc = C_named_struct(ccx.tydesc_type(), [ti.size, // size ti.align, // align drop_glue, // drop_glue - visit_glue, // visit_glue ti.name]); // name unsafe { diff --git a/src/librustc/middle/trans/intrinsic.rs b/src/librustc/middle/trans/intrinsic.rs index f463f258ad5..cf47bbd2a52 100644 --- a/src/librustc/middle/trans/intrinsic.rs +++ b/src/librustc/middle/trans/intrinsic.rs @@ -269,7 +269,6 @@ pub fn trans_intrinsic_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, node: ast::N (_, "get_tydesc") => { let tp_ty = *substs.types.get(FnSpace, 0); let static_ti = get_tydesc(ccx, tp_ty); - glue::lazily_emit_visit_glue(ccx, &*static_ti); // FIXME (#3730): ideally this shouldn't need a cast, // but there's a circularity between translating rust types to llvm @@ -307,13 +306,6 @@ pub fn trans_intrinsic_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, node: ast::N let tp_ty = *substs.types.get(FnSpace, 0); C_bool(ccx, ty::type_contents(ccx.tcx(), tp_ty).owns_managed()) } - (_, "visit_tydesc") => { - let td = *llargs.get(0); - let visitor = *llargs.get(1); - let td = PointerCast(bcx, td, ccx.tydesc_type().ptr_to()); - glue::call_visit_glue(bcx, visitor, td); - C_nil(ccx) - } (_, "offset") => { let ptr = *llargs.get(0); let offset = *llargs.get(1); diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index eb53fe2d673..0b3f1c9840c 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -60,7 +60,7 @@ pub fn trans_impl(ccx: &CrateContext, let _icx = push_ctxt("meth::trans_impl"); let tcx = ccx.tcx(); - debug!("trans_impl(name={}, id={:?})", name.repr(tcx), id); + debug!("trans_impl(name={}, id={})", name.repr(tcx), id); // Both here and below with generic methods, be sure to recurse and look for // items that we need to translate. @@ -174,8 +174,8 @@ pub fn trans_static_method_callee(bcx: Block, let _icx = push_ctxt("meth::trans_static_method_callee"); let ccx = bcx.ccx(); - debug!("trans_static_method_callee(method_id={:?}, trait_id={}, \ - expr_id={:?})", + debug!("trans_static_method_callee(method_id={}, trait_id={}, \ + expr_id={})", method_id, ty::item_path_str(bcx.tcx(), trait_id), expr_id); diff --git a/src/librustc/middle/trans/mod.rs b/src/librustc/middle/trans/mod.rs index f95825c96db..fe7697447ac 100644 --- a/src/librustc/middle/trans/mod.rs +++ b/src/librustc/middle/trans/mod.rs @@ -36,7 +36,6 @@ pub mod cabi_arm; pub mod cabi_mips; pub mod foreign; pub mod intrinsic; -pub mod reflect; pub mod debuginfo; pub mod machine; pub mod adt; diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs index e2c1bf1d8d1..258d12e631f 100644 --- a/src/librustc/middle/trans/monomorphize.rs +++ b/src/librustc/middle/trans/monomorphize.rs @@ -38,7 +38,7 @@ pub fn monomorphic_fn(ccx: &CrateContext, debug!("monomorphic_fn(\ fn_id={}, \ real_substs={}, \ - ref_id={:?})", + ref_id={})", fn_id.repr(ccx.tcx()), real_substs.repr(ccx.tcx()), ref_id); @@ -70,7 +70,7 @@ pub fn monomorphic_fn(ccx: &CrateContext, debug!("monomorphic_fn(\ fn_id={}, \ psubsts={}, \ - hash_id={:?})", + hash_id={})", fn_id.repr(ccx.tcx()), psubsts.repr(ccx.tcx()), hash_id); @@ -82,7 +82,7 @@ pub fn monomorphic_fn(ccx: &CrateContext, ccx.sess(), ccx.tcx().map.find(fn_id.node), || { - format!("while monomorphizing {:?}, couldn't find it in \ + format!("while monomorphizing {}, couldn't find it in \ the item map (may have attempted to monomorphize \ an item defined in a different crate?)", fn_id) @@ -247,7 +247,7 @@ pub fn monomorphic_fn(ccx: &CrateContext, d } _ => { - ccx.sess().bug(format!("can't monomorphize a {:?}", + ccx.sess().bug(format!("can't monomorphize a {}", map_node).as_slice()) } } @@ -273,7 +273,7 @@ pub fn monomorphic_fn(ccx: &CrateContext, ast_map::NodeBlock(..) | ast_map::NodePat(..) | ast_map::NodeLocal(..) => { - ccx.sess().bug(format!("can't monomorphize a {:?}", + ccx.sess().bug(format!("can't monomorphize a {}", map_node).as_slice()) } }; @@ -284,7 +284,7 @@ pub fn monomorphic_fn(ccx: &CrateContext, (lldecl, true) } -#[deriving(PartialEq, Eq, Hash)] +#[deriving(PartialEq, Eq, Hash, Show)] pub struct MonoId { pub def: ast::DefId, pub params: subst::VecPerParamSpace<ty::t> diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs deleted file mode 100644 index ebdd2eb6354..00000000000 --- a/src/librustc/middle/trans/reflect.rs +++ /dev/null @@ -1,460 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use back::link::mangle_internal_name_by_path_and_seq; -use llvm::{ValueRef, get_param}; -use middle::trans::adt; -use middle::trans::base::*; -use middle::trans::build::*; -use middle::trans::callee::ArgVals; -use middle::trans::callee; -use middle::trans::common::*; -use middle::trans::datum::*; -use middle::trans::glue; -use middle::trans::machine; -use middle::trans::meth; -use middle::trans::type_::Type; -use middle::trans::type_of::*; -use middle::ty; -use util::ppaux::ty_to_string; - -use arena::TypedArena; -use libc::c_uint; -use syntax::ast::DefId; -use syntax::ast; -use syntax::ast_map; -use syntax::parse::token::{InternedString, special_idents}; -use syntax::parse::token; - -pub struct Reflector<'a, 'blk, 'tcx: 'blk> { - visitor_val: ValueRef, - visitor_items: &'a [ty::ImplOrTraitItem], - final_bcx: Block<'blk, 'tcx>, - tydesc_ty: Type, - bcx: Block<'blk, 'tcx> -} - -impl<'a, 'blk, 'tcx> Reflector<'a, 'blk, 'tcx> { - pub fn c_uint(&mut self, u: uint) -> ValueRef { - C_uint(self.bcx.ccx(), u) - } - - pub fn c_bool(&mut self, b: bool) -> ValueRef { - C_bool(self.bcx.ccx(), b) - } - - pub fn c_slice(&mut self, s: InternedString) -> ValueRef { - // We're careful to not use first class aggregates here because that - // will kick us off fast isel. (Issue #4352.) - let bcx = self.bcx; - let str_ty = ty::mk_str_slice(bcx.tcx(), ty::ReStatic, ast::MutImmutable); - let scratch = rvalue_scratch_datum(bcx, str_ty, ""); - let len = C_uint(bcx.ccx(), s.get().len()); - let c_str = PointerCast(bcx, C_cstr(bcx.ccx(), s, false), Type::i8p(bcx.ccx())); - Store(bcx, c_str, GEPi(bcx, scratch.val, [ 0, 0 ])); - Store(bcx, len, GEPi(bcx, scratch.val, [ 0, 1 ])); - scratch.val - } - - pub fn c_size_and_align(&mut self, t: ty::t) -> Vec<ValueRef> { - let tr = type_of(self.bcx.ccx(), t); - let s = machine::llsize_of_real(self.bcx.ccx(), tr); - let a = align_of(self.bcx.ccx(), t); - return vec!(self.c_uint(s as uint), - self.c_uint(a as uint)); - } - - pub fn c_tydesc(&mut self, t: ty::t) -> ValueRef { - let bcx = self.bcx; - let static_ti = get_tydesc(bcx.ccx(), t); - glue::lazily_emit_visit_glue(bcx.ccx(), &*static_ti); - PointerCast(bcx, static_ti.tydesc, self.tydesc_ty.ptr_to()) - } - - pub fn c_mt(&mut self, mt: &ty::mt) -> Vec<ValueRef> { - vec!(self.c_uint(mt.mutbl as uint), - self.c_tydesc(mt.ty)) - } - - pub fn visit(&mut self, ty_name: &str, args: &[ValueRef]) { - let fcx = self.bcx.fcx; - let tcx = self.bcx.tcx(); - let mth_idx = ty::impl_or_trait_item_idx(token::str_to_ident(format!( - "visit_{}", ty_name).as_slice()), - self.visitor_items.as_slice()).expect( - format!("couldn't find visit method for {}", ty_name).as_slice()); - let method = match self.visitor_items[mth_idx] { - ty::MethodTraitItem(ref method) => (*method).clone(), - ty::TypeTraitItem(_) => return, - }; - let mth_ty = ty::mk_bare_fn(tcx, method.fty.clone()); - debug!("Emit call visit method: visit_{}: {}", ty_name, ty_to_string(tcx, mth_ty)); - let v = self.visitor_val; - debug!("passing {} args:", args.len()); - let mut bcx = self.bcx; - for (i, a) in args.iter().enumerate() { - debug!("arg {}: {}", i, bcx.val_to_string(*a)); - } - let result = unpack_result!(bcx, callee::trans_call_inner( - self.bcx, None, mth_ty, - |bcx, _| meth::trans_trait_callee_from_llval(bcx, - mth_ty, - mth_idx, - v), - ArgVals(args), None)); - let next_bcx = fcx.new_temp_block("next"); - CondBr(bcx, result, next_bcx.llbb, self.final_bcx.llbb); - self.bcx = next_bcx - } - - pub fn bracketed(&mut self, - bracket_name: &str, - extra: &[ValueRef], - inner: |&mut Reflector|) { - self.visit(format!("enter_{}", bracket_name).as_slice(), extra); - inner(self); - self.visit(format!("leave_{}", bracket_name).as_slice(), extra); - } - - pub fn leaf(&mut self, name: &str) { - self.visit(name, []); - } - - fn visit_closure_ty(&mut self, fty: &ty::ClosureTy, is_unboxed: bool) { - let pureval = ast_fn_style_constant(fty.fn_style); - let sigilval = match fty.store { - ty::UniqTraitStore => 2u, - ty::RegionTraitStore(..) => 4u, - }; - let retval = if ty::type_is_bot(fty.sig.output) {0u} else {1u}; - let extra = vec!(self.c_uint(pureval), - self.c_uint(sigilval), - self.c_uint(fty.sig.inputs.len()), - self.c_uint(retval)); - self.visit("enter_fn", extra.as_slice()); - self.visit_sig(retval, &fty.sig, is_unboxed); - self.visit("leave_fn", extra.as_slice()); - } - - // Entrypoint - pub fn visit_ty(&mut self, t: ty::t) { - let bcx = self.bcx; - let tcx = bcx.tcx(); - debug!("reflect::visit_ty {}", ty_to_string(bcx.tcx(), t)); - - match ty::get(t).sty { - ty::ty_bot => self.leaf("bot"), - ty::ty_nil => self.leaf("nil"), - ty::ty_bool => self.leaf("bool"), - ty::ty_char => self.leaf("char"), - ty::ty_int(ast::TyI) => self.leaf("int"), - ty::ty_int(ast::TyI8) => self.leaf("i8"), - ty::ty_int(ast::TyI16) => self.leaf("i16"), - ty::ty_int(ast::TyI32) => self.leaf("i32"), - ty::ty_int(ast::TyI64) => self.leaf("i64"), - ty::ty_uint(ast::TyU) => self.leaf("uint"), - ty::ty_uint(ast::TyU8) => self.leaf("u8"), - ty::ty_uint(ast::TyU16) => self.leaf("u16"), - ty::ty_uint(ast::TyU32) => self.leaf("u32"), - ty::ty_uint(ast::TyU64) => self.leaf("u64"), - ty::ty_float(ast::TyF32) => self.leaf("f32"), - ty::ty_float(ast::TyF64) => self.leaf("f64"), - - ty::ty_open(_) | ty::ty_str | ty::ty_vec(_, None) | ty::ty_trait(..) => { - // Unfortunately we can't do anything here because at runtime we - // pass around the value by pointer (*u8). But unsized pointers are - // fat and so we can't just cast them to *u8 and back. So we have - // to work with the pointer directly (see ty_ptr/ty_rptr/ty_uniq). - fail!("Can't reflect unsized type") - } - // FIXME(15049) Reflection for unsized structs. - ty::ty_struct(..) if !ty::type_is_sized(bcx.tcx(), t) => { - fail!("Can't reflect unsized type") - } - - // Should rename to vec_*. - ty::ty_vec(ty, Some(sz)) => { - let mut extra = (vec!(self.c_uint(sz))).append(self.c_size_and_align(t).as_slice()); - extra.push(self.c_tydesc(ty)); - self.visit("evec_fixed", extra.as_slice()) - } - ty::ty_ptr(ref mt) => { - match ty::get(mt.ty).sty { - ty::ty_vec(ty, None) => { - let extra = self.c_mt(&ty::mt{ty: ty, mutbl: mt.mutbl}); - self.visit("evec_slice", extra.as_slice()) - } - ty::ty_str => self.visit("estr_slice", &[]), - ty::ty_trait(..) => { - let extra = [ - self.c_slice(token::intern_and_get_ident( - ty_to_string(tcx, t).as_slice())) - ]; - self.visit("trait", extra); - } - _ => { - let extra = self.c_mt(mt); - self.visit("ptr", extra.as_slice()) - } - } - } - ty::ty_uniq(typ) => { - match ty::get(typ).sty { - ty::ty_trait(..) => { - let extra = [ - self.c_slice(token::intern_and_get_ident( - ty_to_string(tcx, t).as_slice())) - ]; - self.visit("trait", extra); - } - // FIXME(15049) allow reflection of Box<[T]>. You'll need to - // restore visit_evec_uniq. - ty::ty_vec(_, None) => { - fail!("Box<[T]> theoretically doesn't exist, so don't try to reflect it") - } - ty::ty_str => fail!("Can't reflect Box<str> which shouldn't be used anyway"), - _ => { - let extra = self.c_mt(&ty::mt { - ty: typ, - mutbl: ast::MutImmutable, - }); - self.visit("uniq", extra.as_slice()) - } - } - } - ty::ty_rptr(_, ref mt) => { - match ty::get(mt.ty).sty { - ty::ty_vec(ty, None) => { - let extra = self.c_mt(&ty::mt{ty: ty, mutbl: mt.mutbl}); - self.visit("evec_slice", extra.as_slice()) - } - ty::ty_str => self.visit("estr_slice", &[]), - ty::ty_trait(..) => { - let extra = [ - self.c_slice(token::intern_and_get_ident( - ty_to_string(tcx, t).as_slice())) - ]; - self.visit("trait", extra); - } - _ => { - let extra = self.c_mt(mt); - self.visit("rptr", extra.as_slice()) - } - } - } - - ty::ty_tup(ref tys) => { - let extra = (vec!(self.c_uint(tys.len()))) - .append(self.c_size_and_align(t).as_slice()); - self.bracketed("tup", extra.as_slice(), |this| { - for (i, t) in tys.iter().enumerate() { - let extra = vec!(this.c_uint(i), this.c_tydesc(*t)); - this.visit("tup_field", extra.as_slice()); - } - }) - } - - // FIXME (#2594): fetch constants out of intrinsic - // FIXME (#4809): visitor should break out bare fns from other fns - ty::ty_closure(box ref fty) => { - self.visit_closure_ty(fty, false); - } - - // FIXME (#2594): fetch constants out of intrinsic:: for the - // numbers. - ty::ty_bare_fn(ref fty) => { - let pureval = ast_fn_style_constant(fty.fn_style); - let sigilval = 0u; - let retval = if ty::type_is_bot(fty.sig.output) {0u} else {1u}; - let extra = vec!(self.c_uint(pureval), - self.c_uint(sigilval), - self.c_uint(fty.sig.inputs.len()), - self.c_uint(retval)); - self.visit("enter_fn", extra.as_slice()); - self.visit_sig(retval, &fty.sig, false); - self.visit("leave_fn", extra.as_slice()); - } - - ty::ty_struct(did, ref substs) => { - let fields = ty::struct_fields(tcx, did, substs); - let mut named_fields = false; - if !fields.is_empty() { - named_fields = fields.get(0).ident.name != - special_idents::unnamed_field.name; - } - - // This and the type_is_sized check on individual field types are - // because we cannot reflect unsized types (see note above). We - // just pretend the unsized field does not exist and print nothing. - // This is sub-optimal. - let len = fields.len(); - - let extra = (vec!( - self.c_slice( - token::intern_and_get_ident(ty_to_string(tcx, - t).as_slice())), - self.c_bool(named_fields), - self.c_uint(len) - )).append(self.c_size_and_align(t).as_slice()); - self.bracketed("class", extra.as_slice(), |this| { - for (i, field) in fields.iter().enumerate() { - let extra = (vec!( - this.c_uint(i), - this.c_slice(token::get_ident(field.ident)), - this.c_bool(named_fields) - )).append(this.c_mt(&field.mt).as_slice()); - this.visit("class_field", extra.as_slice()); - } - }) - } - - // FIXME (#2595): visiting all the variants in turn is probably - // not ideal. It'll work but will get costly on big enums. Maybe - // let the visitor tell us if it wants to visit only a particular - // variant? - ty::ty_enum(did, ref substs) => { - let ccx = bcx.ccx(); - let repr = adt::represent_type(bcx.ccx(), t); - let variants = ty::substd_enum_variants(ccx.tcx(), did, substs); - let llptrty = type_of(ccx, t).ptr_to(); - let opaquety = ty::get_opaque_ty(ccx.tcx()).unwrap(); - let opaqueptrty = ty::mk_ptr(ccx.tcx(), ty::mt { ty: opaquety, - mutbl: ast::MutImmutable }); - - let make_get_disr = || { - let sym = mangle_internal_name_by_path_and_seq( - ast_map::Values([].iter()).chain(None), "get_disr"); - - let fn_ty = ty::mk_ctor_fn(ccx.tcx(), ast::DUMMY_NODE_ID, - [opaqueptrty], ty::mk_u64()); - let llfdecl = decl_internal_rust_fn(ccx, - fn_ty, - sym.as_slice()); - let arena = TypedArena::new(); - let empty_param_substs = param_substs::empty(); - let fcx = new_fn_ctxt(ccx, llfdecl, ast::DUMMY_NODE_ID, false, - ty::mk_u64(), &empty_param_substs, - None, &arena); - let bcx = init_function(&fcx, false, ty::mk_u64()); - - // we know the return type of llfdecl is an int here, so - // no need for a special check to see if the return type - // is immediate. - let arg = get_param(llfdecl, fcx.arg_pos(0u) as c_uint); - let arg = BitCast(bcx, arg, llptrty); - let ret = adt::trans_get_discr(bcx, &*repr, arg, Some(Type::i64(ccx))); - assert!(!fcx.needs_ret_allocas); - let ret_slot = fcx.get_ret_slot(bcx, ty::mk_u64(), "ret_slot"); - Store(bcx, ret, ret_slot); - match fcx.llreturn.get() { - Some(llreturn) => Br(bcx, llreturn), - None => {} - }; - finish_fn(&fcx, bcx, ty::mk_u64()); - llfdecl - }; - - let enum_args = (vec!(self.c_uint(variants.len()), make_get_disr())) - .append(self.c_size_and_align(t).as_slice()); - self.bracketed("enum", enum_args.as_slice(), |this| { - for (i, v) in variants.iter().enumerate() { - let name = token::get_ident(v.name); - let variant_args = [this.c_uint(i), - C_u64(ccx, v.disr_val), - this.c_uint(v.args.len()), - this.c_slice(name)]; - this.bracketed("enum_variant", - variant_args, - |this| { - for (j, a) in v.args.iter().enumerate() { - let bcx = this.bcx; - let null = C_null(llptrty); - let ptr = adt::trans_field_ptr(bcx, &*repr, null, v.disr_val, j); - let offset = p2i(ccx, ptr); - let field_args = [this.c_uint(j), - offset, - this.c_tydesc(*a)]; - this.visit("enum_variant_field", - field_args); - } - }) - } - }) - } - - // Miscellaneous extra types - ty::ty_infer(_) => self.leaf("infer"), - ty::ty_err => self.leaf("err"), - ty::ty_unboxed_closure(ref def_id, _) => { - let closure_map = tcx.unboxed_closures.borrow(); - let fty = &closure_map.find(def_id).unwrap().closure_type; - self.visit_closure_ty(fty, true); - } - ty::ty_param(ref p) => { - let extra = vec!(self.c_uint(p.idx)); - self.visit("param", extra.as_slice()) - } - } - } - - pub fn visit_sig(&mut self, retval: uint, sig: &ty::FnSig, is_unboxed: bool) { - let args = if is_unboxed { - match ty::get(sig.inputs[0]).sty { - ty::ty_tup(ref contents) => contents.iter(), - ty::ty_nil => [].iter(), - _ => unreachable!() - } - } else { - sig.inputs.iter() - }; - - for (i, arg) in args.enumerate() { - let modeval = 5u; // "by copy" - let extra = vec!(self.c_uint(i), - self.c_uint(modeval), - self.c_tydesc(*arg)); - self.visit("fn_input", extra.as_slice()); - } - let extra = vec!(self.c_uint(retval), - self.c_bool(sig.variadic), - self.c_tydesc(sig.output)); - self.visit("fn_output", extra.as_slice()); - } -} - -// Emit a sequence of calls to visit_ty::visit_foo -pub fn emit_calls_to_trait_visit_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, - t: ty::t, - visitor_val: ValueRef, - visitor_trait_id: DefId) - -> Block<'blk, 'tcx> { - let fcx = bcx.fcx; - let final_bcx = fcx.new_temp_block("final"); - let tydesc_ty = ty::get_tydesc_ty(bcx.tcx()).unwrap(); - let tydesc_ty = type_of(bcx.ccx(), tydesc_ty); - let visitor_items = ty::trait_items(bcx.tcx(), visitor_trait_id); - let mut r = Reflector { - visitor_val: visitor_val, - visitor_items: visitor_items.as_slice(), - final_bcx: final_bcx, - tydesc_ty: tydesc_ty, - bcx: bcx - }; - r.visit_ty(t); - Br(r.bcx, final_bcx.llbb); - return final_bcx; -} - -pub fn ast_fn_style_constant(fn_style: ast::FnStyle) -> uint { - match fn_style { - ast::UnsafeFn => 1u, - ast::NormalFn => 2u, - } -} diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index fac0ef2014e..a404d9d221e 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -118,7 +118,7 @@ pub fn trans_fixed_vstore<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // to store the array of the suitable size, so all we have to do is // generate the content. - debug!("trans_fixed_vstore(expr={}, dest={:?})", + debug!("trans_fixed_vstore(expr={}, dest={})", bcx.expr_to_string(expr), dest.to_string(bcx.ccx())); let vt = vec_types_from_expr(bcx, expr); @@ -175,7 +175,7 @@ pub fn trans_slice_vec<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // Handle the &[...] case: let vt = vec_types_from_expr(bcx, content_expr); let count = elements_required(bcx, content_expr); - debug!(" vt={}, count={:?}", vt.to_string(ccx), count); + debug!(" vt={}, count={}", vt.to_string(ccx), count); let llcount = C_uint(ccx, count); let fixed_ty = ty::mk_vec(bcx.tcx(), @@ -249,7 +249,7 @@ pub fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let fcx = bcx.fcx; let mut bcx = bcx; - debug!("write_content(vt={}, dest={}, vstore_expr={:?})", + debug!("write_content(vt={}, dest={}, vstore_expr={})", vt.to_string(bcx.ccx()), dest.to_string(bcx.ccx()), bcx.expr_to_string(vstore_expr)); @@ -291,7 +291,7 @@ pub fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let temp_scope = fcx.push_custom_cleanup_scope(); for (i, element) in elements.iter().enumerate() { let lleltptr = GEPi(bcx, lldest, [i]); - debug!("writing index {:?} with lleltptr={:?}", + debug!("writing index {} with lleltptr={}", i, bcx.val_to_string(lleltptr)); bcx = expr::trans_into(bcx, &**element, SaveIn(lleltptr)); diff --git a/src/librustc/middle/trans/type_.rs b/src/librustc/middle/trans/type_.rs index a6a30d6ba85..6acbde3b2ad 100644 --- a/src/librustc/middle/trans/type_.rs +++ b/src/librustc/middle/trans/type_.rs @@ -197,7 +197,6 @@ impl Type { let elems = [int_ty, // size int_ty, // align glue_fn_ty, // drop - glue_fn_ty, // visit str_slice_ty]; // name tydesc.set_struct_body(elems, false); diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index d41cd7ed9e5..e723d5af89c 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -253,7 +253,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type { None => () } - debug!("type_of {} {:?}", t.repr(cx.tcx()), ty::get(t).sty); + debug!("type_of {} {}", t.repr(cx.tcx()), ty::get(t).sty); // Replace any typedef'd types with their equivalent non-typedef // type. This ensures that all LLVM nominal types that contain @@ -264,7 +264,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type { if t != t_norm { let llty = type_of(cx, t_norm); - debug!("--> normalized {} {:?} to {} {:?} llty={}", + debug!("--> normalized {} {} to {} {} llty={}", t.repr(cx.tcx()), t, t_norm.repr(cx.tcx()), @@ -378,7 +378,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type { ty::ty_err(..) => cx.sess().bug("type_of with ty_err"), }; - debug!("--> mapped t={} {:?} to llty={}", + debug!("--> mapped t={} {} to llty={}", t.repr(cx.tcx()), t, cx.tn().type_to_string(llty)); diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 06d36230068..b84bfe95224 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -18,8 +18,7 @@ use middle::const_eval; use middle::def; use middle::dependency_format; use middle::lang_items::{FnTraitLangItem, FnMutTraitLangItem}; -use middle::lang_items::{FnOnceTraitLangItem, OpaqueStructLangItem}; -use middle::lang_items::{TyDescStructLangItem, TyVisitorTraitLangItem}; +use middle::lang_items::{FnOnceTraitLangItem, TyDescStructLangItem}; use middle::mem_categorization as mc; use middle::resolve; use middle::resolve_lifetime; @@ -70,7 +69,7 @@ pub struct field { pub mt: mt } -#[deriving(Clone)] +#[deriving(Clone, Show)] pub enum ImplOrTraitItemContainer { TraitContainer(ast::DefId), ImplContainer(ast::DefId), @@ -138,7 +137,7 @@ impl ImplOrTraitItemId { } } -#[deriving(Clone)] +#[deriving(Clone, Show)] pub struct Method { pub ident: ast::Ident, pub generics: ty::Generics, @@ -268,13 +267,13 @@ pub enum Variance { Bivariant, // T<A> <: T<B> -- e.g., unused type parameter } -#[deriving(Clone)] +#[deriving(Clone, Show)] pub enum AutoAdjustment { AdjustAddEnv(ty::TraitStore), AdjustDerefRef(AutoDerefRef) } -#[deriving(Clone, PartialEq)] +#[deriving(Clone, PartialEq, Show)] pub enum UnsizeKind { // [T, ..n] -> [T], the uint field is n. UnsizeLength(uint), @@ -284,13 +283,13 @@ pub enum UnsizeKind { UnsizeVtable(TyTrait, /* the self type of the trait */ ty::t) } -#[deriving(Clone)] +#[deriving(Clone, Show)] pub struct AutoDerefRef { pub autoderefs: uint, pub autoref: Option<AutoRef> } -#[deriving(Clone, PartialEq)] +#[deriving(Clone, PartialEq, Show)] pub enum AutoRef { /// Convert from T to &T /// The third field allows us to wrap other AutoRef adjustments. @@ -726,7 +725,7 @@ pub enum Region { * the original var id (that is, the root variable that is referenced * by the upvar) and the id of the closure expression. */ -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, PartialEq, Eq, Hash, Show)] pub struct UpvarId { pub var_id: ast::NodeId, pub closure_expr_id: ast::NodeId, @@ -827,7 +826,7 @@ pub enum BorrowKind { * the closure, so sometimes it is necessary for them to be larger * than the closure lifetime itself. */ -#[deriving(PartialEq, Clone, Encodable, Decodable)] +#[deriving(PartialEq, Clone, Encodable, Decodable, Show)] pub struct UpvarBorrow { pub kind: BorrowKind, pub region: ty::Region, @@ -1434,7 +1433,7 @@ pub struct UnboxedClosure { pub kind: UnboxedClosureKind, } -#[deriving(Clone, PartialEq, Eq)] +#[deriving(Clone, PartialEq, Eq, Show)] pub enum UnboxedClosureKind { FnUnboxedClosureKind, FnMutUnboxedClosureKind, @@ -3133,7 +3132,7 @@ pub fn fn_is_variadic(fty: t) -> bool { ty_bare_fn(ref f) => f.sig.variadic, ty_closure(ref f) => f.sig.variadic, ref s => { - fail!("fn_is_variadic() called on non-fn type: {:?}", s) + fail!("fn_is_variadic() called on non-fn type: {}", s) } } } @@ -3143,7 +3142,7 @@ pub fn ty_fn_sig(fty: t) -> FnSig { ty_bare_fn(ref f) => f.sig.clone(), ty_closure(ref f) => f.sig.clone(), ref s => { - fail!("ty_fn_sig() called on non-fn type: {:?}", s) + fail!("ty_fn_sig() called on non-fn type: {}", s) } } } @@ -3163,7 +3162,7 @@ pub fn ty_fn_args(fty: t) -> Vec<t> { ty_bare_fn(ref f) => f.sig.inputs.clone(), ty_closure(ref f) => f.sig.inputs.clone(), ref s => { - fail!("ty_fn_args() called on non-fn type: {:?}", s) + fail!("ty_fn_args() called on non-fn type: {}", s) } } } @@ -3177,7 +3176,7 @@ pub fn ty_closure_store(fty: t) -> TraitStore { UniqTraitStore } ref s => { - fail!("ty_closure_store() called on non-closure type: {:?}", s) + fail!("ty_closure_store() called on non-closure type: {}", s) } } } @@ -3187,7 +3186,7 @@ pub fn ty_fn_ret(fty: t) -> t { ty_bare_fn(ref f) => f.sig.output, ty_closure(ref f) => f.sig.output, ref s => { - fail!("ty_fn_ret() called on non-fn type: {:?}", s) + fail!("ty_fn_ret() called on non-fn type: {}", s) } } } @@ -3208,7 +3207,7 @@ pub fn ty_region(tcx: &ctxt, ref s => { tcx.sess.span_bug( span, - format!("ty_region() invoked on an inappropriate ty: {:?}", + format!("ty_region() invoked on an inappropriate ty: {}", s).as_slice()); } } @@ -3272,7 +3271,7 @@ pub fn expr_span(cx: &ctxt, id: NodeId) -> Span { e.span } Some(f) => { - cx.sess.bug(format!("Node id {} is not an expr: {:?}", + cx.sess.bug(format!("Node id {} is not an expr: {}", id, f).as_slice()); } @@ -3292,14 +3291,14 @@ pub fn local_var_name_str(cx: &ctxt, id: NodeId) -> InternedString { } _ => { cx.sess.bug( - format!("Variable id {} maps to {:?}, not local", + format!("Variable id {} maps to {}, not local", id, pat).as_slice()); } } } r => { - cx.sess.bug(format!("Variable id {} maps to {:?}, not local", + cx.sess.bug(format!("Variable id {} maps to {}, not local", id, r).as_slice()); } @@ -3343,7 +3342,7 @@ pub fn adjust_ty(cx: &ctxt, ref b => { cx.sess.bug( format!("add_env adjustment on non-bare-fn: \ - {:?}", + {}", b).as_slice()); } } @@ -3456,7 +3455,7 @@ pub fn resolve_expr(tcx: &ctxt, expr: &ast::Expr) -> def::Def { Some(&def) => def, None => { tcx.sess.span_bug(expr.span, format!( - "no def-map entry for expr {:?}", expr.id).as_slice()); + "no def-map entry for expr {}", expr.id).as_slice()); } } } @@ -3547,7 +3546,7 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind { def => { tcx.sess.span_bug( expr.span, - format!("uncategorized def for expr {:?}: {:?}", + format!("uncategorized def for expr {}: {}", expr.id, def).as_slice()); } @@ -3671,7 +3670,7 @@ pub fn field_idx_strict(tcx: &ctxt, name: ast::Name, fields: &[field]) let mut i = 0u; for f in fields.iter() { if f.ident.name == name { return i; } i += 1u; } tcx.sess.bug(format!( - "no field named `{}` found in the list of fields `{:?}`", + "no field named `{}` found in the list of fields `{}`", token::get_name(name), fields.iter() .map(|f| token::get_ident(f.ident).get().to_string()) @@ -3965,7 +3964,7 @@ fn lookup_locally_or_in_crate_store<V:Clone>( } if def_id.krate == ast::LOCAL_CRATE { - fail!("No def'n found for {:?} in tcx.{}", def_id, descr); + fail!("No def'n found for {} in tcx.{}", def_id, descr); } let v = load_external(); map.insert(def_id, v.clone()); @@ -4083,7 +4082,7 @@ pub fn trait_item_def_ids(cx: &ctxt, id: ast::DefId) pub fn impl_trait_ref(cx: &ctxt, id: ast::DefId) -> Option<Rc<TraitRef>> { memoized(&cx.impl_trait_cache, id, |id: ast::DefId| { if id.krate == ast::LOCAL_CRATE { - debug!("(impl_trait_ref) searching for trait impl {:?}", id); + debug!("(impl_trait_ref) searching for trait impl {}", id); match cx.map.find(id.node) { Some(ast_map::NodeItem(item)) => { match item.node { @@ -4821,33 +4820,6 @@ pub fn get_tydesc_ty(tcx: &ctxt) -> Result<t, String> { }) } -pub fn get_opaque_ty(tcx: &ctxt) -> Result<t, String> { - tcx.lang_items.require(OpaqueStructLangItem).map(|opaque_lang_item| { - tcx.intrinsic_defs.borrow().find_copy(&opaque_lang_item) - .expect("Failed to resolve Opaque") - }) -} - -pub fn visitor_object_ty(tcx: &ctxt, - ptr_region: ty::Region, - trait_region: ty::Region) - -> Result<(Rc<TraitRef>, t), String> -{ - let trait_lang_item = match tcx.lang_items.require(TyVisitorTraitLangItem) { - Ok(id) => id, - Err(s) => { return Err(s); } - }; - let substs = Substs::empty(); - let trait_ref = Rc::new(TraitRef { def_id: trait_lang_item, substs: substs }); - Ok((trait_ref.clone(), - mk_rptr(tcx, ptr_region, - mt {mutbl: ast::MutMutable, - ty: mk_trait(tcx, - trait_ref.def_id, - trait_ref.substs.clone(), - ty::region_existential_bound(trait_region))}))) -} - pub fn item_variances(tcx: &ctxt, item_id: ast::DefId) -> Rc<ItemVariances> { lookup_locally_or_in_crate_store( "item_variance_map", item_id, &mut *tcx.item_variance_map.borrow_mut(), @@ -5418,7 +5390,7 @@ impl<'tcx> mc::Typer<'tcx> for ty::ctxt<'tcx> { } /// The category of explicit self. -#[deriving(Clone, Eq, PartialEq)] +#[deriving(Clone, Eq, PartialEq, Show)] pub enum ExplicitSelfCategory { StaticExplicitSelfCategory, ByValueExplicitSelfCategory, diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index efd0a2a0e48..0e9d255adf9 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -961,7 +961,7 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>( _ => { tcx.sess.span_fatal(ast_ty.span, format!("found value name used \ - as a type: {:?}", + as a type: {}", a_def).as_slice()); } } diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index 18e2e6c4f09..9463bafc9d2 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -442,8 +442,8 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) { fcx.infcx().resolve_type_vars_if_possible(fcx.expr_ty(&**begin)); let e_ty = fcx.infcx().resolve_type_vars_if_possible(fcx.expr_ty(&**end)); - debug!("pat_range beginning type: {:?}", b_ty); - debug!("pat_range ending type: {:?}", e_ty); + debug!("pat_range beginning type: {}", b_ty); + debug!("pat_range ending type: {}", e_ty); if !require_same_types( tcx, Some(fcx.infcx()), false, pat.span, b_ty, e_ty, || "mismatched types in range".to_string()) diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 45658e8a356..c2e7be2781f 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -643,7 +643,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { rcvr_ty: ty::t, restrict_to: Option<DefId>, param_ty: ParamTy) { - debug!("push_inherent_candidates_from_param(param_ty={:?})", + debug!("push_inherent_candidates_from_param(param_ty={})", param_ty); self.push_inherent_candidates_from_bounds( rcvr_ty, @@ -754,7 +754,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { } } None => { - debug!("trait doesn't contain method: {:?}", + debug!("trait doesn't contain method: {}", bound_trait_ref.def_id); // check next trait or bound } @@ -873,7 +873,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { None => None, Some(method) => { debug!("(searching for autoderef'd method) writing \ - adjustment {:?} for {}", adjustment, self.ty_to_string(self_ty)); + adjustment {} for {}", adjustment, self.ty_to_string(self_ty)); match adjustment { Some((self_expr_id, adj)) => { self.fcx.write_adjustment(self_expr_id, self.span, adj); @@ -1759,7 +1759,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { impl Repr for Candidate { fn repr(&self, tcx: &ty::ctxt) -> String { format!("Candidate(rcvr_ty={}, rcvr_substs={}, method_ty={}, \ - origin={:?})", + origin={})", self.rcvr_match_condition.repr(tcx), self.rcvr_substs.repr(tcx), self.method_ty.repr(tcx), diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 905d70eac19..be622bd6855 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -1563,7 +1563,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { None => { self.tcx().sess.span_bug( span, - format!("no type for local variable {:?}", + format!("no type for local variable {}", nid).as_slice()); } } @@ -1622,7 +1622,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { node_id: ast::NodeId, span: Span, adj: ty::AutoAdjustment) { - debug!("write_adjustment(node_id={:?}, adj={:?})", node_id, adj); + debug!("write_adjustment(node_id={}, adj={})", node_id, adj); // Careful: adjustments can imply trait obligations if we are // casting from a concrete type to an object type. I think @@ -1673,7 +1673,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn register_unsize_obligations(&self, span: Span, unsize: &ty::UnsizeKind) { - debug!("register_unsize_obligations: unsize={:?}", unsize); + debug!("register_unsize_obligations: unsize={}", unsize); match *unsize { ty::UnsizeLength(..) => {} @@ -2551,7 +2551,7 @@ fn check_argument_types<'a>(fcx: &FnCtxt, err_args(supplied_arg_count) }; - debug!("check_argument_types: formal_tys={:?}", + debug!("check_argument_types: formal_tys={}", formal_tys.iter().map(|t| fcx.infcx().ty_to_string(*t)).collect::<Vec<String>>()); // Check the arguments. @@ -5578,25 +5578,6 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) { } } }, - "visit_tydesc" => { - let tydesc_ty = match ty::get_tydesc_ty(ccx.tcx) { - Ok(t) => t, - Err(s) => { tcx.sess.span_fatal(it.span, s.as_slice()); } - }; - let region0 = ty::ReLateBound(it.id, ty::BrAnon(0)); - let region1 = ty::ReLateBound(it.id, ty::BrAnon(1)); - let visitor_object_ty = - match ty::visitor_object_ty(tcx, region0, region1) { - Ok((_, vot)) => vot, - Err(s) => { tcx.sess.span_fatal(it.span, s.as_slice()); } - }; - - let td_ptr = ty::mk_ptr(ccx.tcx, ty::mt { - ty: tydesc_ty, - mutbl: ast::MutImmutable - }); - (0, vec!( td_ptr, visitor_object_ty ), ty::mk_nil()) - } "offset" => { (1, vec!( diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index f533079be69..b810ea3d94d 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -239,7 +239,7 @@ fn region_of_def(fcx: &FnCtxt, def: def::Def) -> ty::Region { } } _ => { - tcx.sess.bug(format!("unexpected def in region_of_def: {:?}", + tcx.sess.bug(format!("unexpected def in region_of_def: {}", def).as_slice()) } } @@ -560,7 +560,7 @@ fn constrain_bindings_in_pat(pat: &ast::Pat, rcx: &mut Rcx) { } fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) { - debug!("regionck::visit_expr(e={}, repeating_scope={:?})", + debug!("regionck::visit_expr(e={}, repeating_scope={})", expr.repr(rcx.fcx.tcx()), rcx.repeating_scope); // No matter what, the type of each expression must outlive the @@ -575,7 +575,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) { // Check any autoderefs or autorefs that appear. for &adjustment in rcx.fcx.inh.adjustments.borrow().find(&expr.id).iter() { - debug!("adjustment={:?}", adjustment); + debug!("adjustment={}", adjustment); match *adjustment { ty::AdjustDerefRef(ty::AutoDerefRef {autoderefs, autoref: ref opt_autoref}) => { let expr_ty = rcx.resolve_node_type(expr.id); @@ -978,7 +978,7 @@ fn check_expr_fn_block(rcx: &mut Rcx, debug!("constrain_free_variables({}, {})", region_bound.repr(tcx), expr.repr(tcx)); for freevar in freevars.iter() { - debug!("freevar def is {:?}", freevar.def); + debug!("freevar def is {}", freevar.def); // Identify the variable being closed over and its node-id. let def = freevar.def; @@ -1116,7 +1116,7 @@ fn constrain_call<'a, I: Iterator<&'a ast::Expr>>(rcx: &mut Rcx, let tcx = rcx.fcx.tcx(); debug!("constrain_call(call_expr={}, \ receiver={}, \ - implicitly_ref_args={:?})", + implicitly_ref_args={})", call_expr.repr(tcx), receiver.repr(tcx), implicitly_ref_args); @@ -1171,7 +1171,7 @@ fn constrain_autoderefs(rcx: &mut Rcx, */ let r_deref_expr = ty::ReScope(deref_expr.id); for i in range(0u, derefs) { - debug!("constrain_autoderefs(deref_expr=?, derefd_ty={}, derefs={:?}/{:?}", + debug!("constrain_autoderefs(deref_expr=?, derefd_ty={}, derefs={}/{}", rcx.fcx.infcx().ty_to_string(derefd_ty), i, derefs); @@ -1280,7 +1280,7 @@ fn type_of_node_must_outlive( rcx.fcx.inh.adjustments.borrow().find(&id), |method_call| rcx.resolve_method_type(method_call)); debug!("constrain_regions_in_type_of_node(\ - ty={}, ty0={}, id={}, minimum_lifetime={:?})", + ty={}, ty0={}, id={}, minimum_lifetime={})", ty_to_string(tcx, ty), ty_to_string(tcx, ty0), id, minimum_lifetime); type_must_outlive(rcx, origin, ty, minimum_lifetime); @@ -1381,7 +1381,7 @@ fn link_autoref(rcx: &Rcx, * to lifetimes in the value being autoref'd. */ - debug!("link_autoref(autoref={:?})", autoref); + debug!("link_autoref(autoref={})", autoref); let mc = mc::MemCategorizationContext::new(rcx); let expr_cmt = ignore_err!(mc.cat_expr_autoderefd(expr, autoderefs)); debug!("expr_cmt={}", expr_cmt.repr(rcx.tcx())); @@ -1779,7 +1779,7 @@ fn link_upvar_borrow_kind_for_nested_closures(rcx: &mut Rcx, * this function. */ - debug!("link_upvar_borrow_kind: inner_upvar_id={:?} outer_upvar_id={:?}", + debug!("link_upvar_borrow_kind: inner_upvar_id={} outer_upvar_id={}", inner_upvar_id, outer_upvar_id); let mut upvar_borrow_map = rcx.fcx.inh.upvar_borrow_map.borrow_mut(); @@ -1795,7 +1795,7 @@ fn link_upvar_borrow_kind_for_nested_closures(rcx: &mut Rcx, fn adjust_upvar_borrow_kind_for_loan(upvar_id: ty::UpvarId, upvar_borrow: &mut ty::UpvarBorrow, kind: ty::BorrowKind) { - debug!("adjust_upvar_borrow_kind_for_loan: upvar_id={:?} kind={:?} -> {:?}", + debug!("adjust_upvar_borrow_kind_for_loan: upvar_id={} kind={} -> {}", upvar_id, upvar_borrow.kind, kind); adjust_upvar_borrow_kind(upvar_id, upvar_borrow, kind) @@ -1812,7 +1812,7 @@ fn adjust_upvar_borrow_kind(upvar_id: ty::UpvarId, * is required by some particular use. */ - debug!("adjust_upvar_borrow_kind: id={:?} kind=({:?} -> {:?})", + debug!("adjust_upvar_borrow_kind: id={} kind=({} -> {})", upvar_id, upvar_borrow.kind, kind); match (upvar_borrow.kind, kind) { diff --git a/src/librustc/middle/typeck/check/writeback.rs b/src/librustc/middle/typeck/check/writeback.rs index 6384c655911..56dec61d410 100644 --- a/src/librustc/middle/typeck/check/writeback.rs +++ b/src/librustc/middle/typeck/check/writeback.rs @@ -306,7 +306,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { }) } }; - debug!("Adjustments for node {}: {:?}", id, resolved_adjustment); + debug!("Adjustments for node {}: {}", id, resolved_adjustment); self.tcx().adjustments.borrow_mut().insert( id, resolved_adjustment); } @@ -319,7 +319,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { // Resolve any method map entry match self.fcx.inh.method_map.borrow_mut().pop(&method_call) { Some(method) => { - debug!("writeback::resolve_method_map_entry(call={:?}, entry={})", + debug!("writeback::resolve_method_map_entry(call={}, entry={})", method_call, method.repr(self.tcx())); let new_method = MethodCallee { diff --git a/src/librustc/middle/typeck/coherence/mod.rs b/src/librustc/middle/typeck/coherence/mod.rs index f6ac0e1666c..eef466ceebb 100644 --- a/src/librustc/middle/typeck/coherence/mod.rs +++ b/src/librustc/middle/typeck/coherence/mod.rs @@ -86,7 +86,7 @@ fn get_base_type(inference_context: &InferCtxt, ty_str(..) | ty_vec(..) | ty_bare_fn(..) | ty_closure(..) | ty_tup(..) | ty_infer(..) | ty_param(..) | ty_err | ty_open(..) | ty_uniq(_) | ty_ptr(_) | ty_rptr(_, _) => { - debug!("(getting base type) no base type; found {:?}", + debug!("(getting base type) no base type; found {}", get(original_type).sty); None } @@ -245,7 +245,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { trait_ref: &ty::TraitRef, all_impl_items: &mut Vec<ImplOrTraitItemId>) { let tcx = self.crate_context.tcx; - debug!("instantiate_default_methods(impl_id={:?}, trait_ref={})", + debug!("instantiate_default_methods(impl_id={}, trait_ref={})", impl_id, trait_ref.repr(tcx)); let impl_poly_type = ty::lookup_item_type(tcx, impl_id); @@ -256,7 +256,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { let new_id = tcx.sess.next_node_id(); let new_did = local_def(new_id); - debug!("new_did={:?} trait_method={}", new_did, trait_method.repr(tcx)); + debug!("new_did={} trait_method={}", new_did, trait_method.repr(tcx)); // Create substitutions for the various trait parameters. let new_method_ty = diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 6e25b23daac..8e4948bbea9 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -171,7 +171,7 @@ impl<'a, 'tcx> AstConv<'tcx> for CrateCtxt<'a, 'tcx> { } x => { self.tcx.sess.bug(format!("unexpected sort of node \ - in get_item_ty(): {:?}", + in get_item_ty(): {}", x).as_slice()); } } @@ -1421,7 +1421,7 @@ pub fn trait_def_of_item(ccx: &CrateCtxt, it: &ast::Item) -> Rc<ty::TraitDef> { ref s => { tcx.sess.span_bug( it.span, - format!("trait_def_of_item invoked on {:?}", s).as_slice()); + format!("trait_def_of_item invoked on {}", s).as_slice()); } }; diff --git a/src/librustc/middle/typeck/infer/coercion.rs b/src/librustc/middle/typeck/infer/coercion.rs index a0c190c5c81..9f88bec7f42 100644 --- a/src/librustc/middle/typeck/infer/coercion.rs +++ b/src/librustc/middle/typeck/infer/coercion.rs @@ -231,7 +231,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { self.get_ref().infcx.tcx.sess.span_bug( self.get_ref().trace.origin.span(), format!("failed to resolve even without \ - any force options: {:?}", e).as_slice()); + any force options: {}", e).as_slice()); } } } @@ -243,7 +243,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { b: ty::t, mutbl_b: ast::Mutability) -> CoerceResult { - debug!("coerce_borrowed_pointer(a={}, sty_a={:?}, b={})", + debug!("coerce_borrowed_pointer(a={}, sty_a={}, b={})", a.repr(self.get_ref().infcx.tcx), sty_a, b.repr(self.get_ref().infcx.tcx)); @@ -283,7 +283,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { b: ty::t, mutbl_b: ast::Mutability) -> CoerceResult { - debug!("coerce_unsized_with_borrow(a={}, sty_a={:?}, b={})", + debug!("coerce_unsized_with_borrow(a={}, sty_a={}, b={})", a.repr(self.get_ref().infcx.tcx), sty_a, b.repr(self.get_ref().infcx.tcx)); @@ -314,7 +314,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { sty_a: &ty::sty, b: ty::t) -> CoerceResult { - debug!("coerce_unsized(a={}, sty_a={:?}, b={})", + debug!("coerce_unsized(a={}, sty_a={}, b={})", a.repr(self.get_ref().infcx.tcx), sty_a, b.repr(self.get_ref().infcx.tcx)); @@ -342,7 +342,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { ty::mt{ty: ty, mutbl: mt_b.mutbl}); try!(self.get_ref().infcx.try(|| sub.tys(ty, b))); debug!("Success, coerced with AutoDerefRef(1, \ - AutoPtr(AutoUnsize({:?})))", kind); + AutoPtr(AutoUnsize({})))", kind); Ok(Some(AdjustDerefRef(AutoDerefRef { autoderefs: 1, autoref: Some(ty::AutoPtr(r_borrow, mt_b.mutbl, @@ -365,7 +365,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { ty::mt{ty: ty, mutbl: mt_b.mutbl}); try!(self.get_ref().infcx.try(|| sub.tys(ty, b))); debug!("Success, coerced with AutoDerefRef(1, \ - AutoPtr(AutoUnsize({:?})))", kind); + AutoPtr(AutoUnsize({})))", kind); Ok(Some(AdjustDerefRef(AutoDerefRef { autoderefs: 1, autoref: Some(ty::AutoUnsafe(mt_b.mutbl, @@ -383,7 +383,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { let ty = ty::mk_uniq(self.get_ref().infcx.tcx, ty); try!(self.get_ref().infcx.try(|| sub.tys(ty, b))); debug!("Success, coerced with AutoDerefRef(1, \ - AutoUnsizeUniq({:?}))", kind); + AutoUnsizeUniq({}))", kind); Ok(Some(AdjustDerefRef(AutoDerefRef { autoderefs: 1, autoref: Some(ty::AutoUnsizeUniq(kind)) @@ -405,7 +405,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { sty_a: &ty::sty, ty_b: ty::t) -> Option<(ty::t, ty::UnsizeKind)> { - debug!("unsize_ty(sty_a={:?}, ty_b={})", sty_a, ty_b.repr(self.get_ref().infcx.tcx)); + debug!("unsize_ty(sty_a={}, ty_b={})", sty_a, ty_b.repr(self.get_ref().infcx.tcx)); let tcx = self.get_ref().infcx.tcx; @@ -485,7 +485,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { { let tcx = self.get_ref().infcx.tcx; - debug!("coerce_borrowed_object(a={}, sty_a={:?}, b={}, b_mutbl={})", + debug!("coerce_borrowed_object(a={}, sty_a={}, b={}, b_mutbl={})", a.repr(tcx), sty_a, b.repr(tcx), b_mutbl); @@ -505,7 +505,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { { let tcx = self.get_ref().infcx.tcx; - debug!("coerce_unsafe_object(a={}, sty_a={:?}, b={}, b_mutbl={})", + debug!("coerce_unsafe_object(a={}, sty_a={}, b={}, b_mutbl={})", a.repr(tcx), sty_a, b.repr(tcx), b_mutbl); @@ -557,7 +557,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { sty_a: &ty::sty, b: ty::t) -> CoerceResult { - debug!("coerce_borrowed_fn(a={}, sty_a={:?}, b={})", + debug!("coerce_borrowed_fn(a={}, sty_a={}, b={})", a.repr(self.get_ref().infcx.tcx), sty_a, b.repr(self.get_ref().infcx.tcx)); @@ -610,7 +610,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { b: ty::t, mutbl_b: ast::Mutability) -> CoerceResult { - debug!("coerce_unsafe_ptr(a={}, sty_a={:?}, b={})", + debug!("coerce_unsafe_ptr(a={}, sty_a={}, b={})", a.repr(self.get_ref().infcx.tcx), sty_a, b.repr(self.get_ref().infcx.tcx)); diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs index a742cf45059..8ae0b603e48 100644 --- a/src/librustc/middle/typeck/infer/combine.rs +++ b/src/librustc/middle/typeck/infer/combine.rs @@ -390,7 +390,7 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C, a: ty::t, b: ty::t) -> cres<t let tcx = this.infcx().tcx; let a_sty = &ty::get(a).sty; let b_sty = &ty::get(b).sty; - debug!("super_tys: a_sty={:?} b_sty={:?}", a_sty, b_sty); + debug!("super_tys: a_sty={} b_sty={}", a_sty, b_sty); return match (a_sty, b_sty) { // The "subtype" ought to be handling cases involving bot or var: (&ty::ty_bot, _) | @@ -470,7 +470,7 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C, a: ty::t, b: ty::t) -> cres<t (&ty::ty_trait(ref a_), &ty::ty_trait(ref b_)) if a_.def_id == b_.def_id => { - debug!("Trying to match traits {:?} and {:?}", a, b); + debug!("Trying to match traits {} and {}", a, b); let substs = try!(this.substs(a_.def_id, &a_.substs, &b_.substs)); let bounds = try!(this.existential_bounds(a_.bounds, b_.bounds)); Ok(ty::mk_trait(tcx, diff --git a/src/librustc/middle/typeck/infer/error_reporting.rs b/src/librustc/middle/typeck/infer/error_reporting.rs index 1a79837c03a..2ab585f5ae9 100644 --- a/src/librustc/middle/typeck/infer/error_reporting.rs +++ b/src/librustc/middle/typeck/infer/error_reporting.rs @@ -268,7 +268,7 @@ impl<'a, 'tcx> ErrorReporting for InferCtxt<'a, 'tcx> { } } let pe = ProcessedErrors(var_origins, trace_origins, same_regions); - debug!("errors processed: {:?}", pe); + debug!("errors processed: {}", pe); processed_errors.push(pe); } return processed_errors; @@ -297,7 +297,7 @@ impl<'a, 'tcx> ErrorReporting for InferCtxt<'a, 'tcx> { sub: Region, sup: Region) -> Option<FreeRegionsFromSameFn> { - debug!("free_regions_from_same_fn(sub={:?}, sup={:?})", sub, sup); + debug!("free_regions_from_same_fn(sub={}, sup={})", sub, sup); let (scope_id, fr1, fr2) = match (sub, sup) { (ReFree(fr1), ReFree(fr2)) => { if fr1.scope_id != fr2.scope_id { diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs index 08d4f9f3a86..83ca67f33bc 100644 --- a/src/librustc/middle/typeck/infer/glb.rs +++ b/src/librustc/middle/typeck/infer/glb.rs @@ -109,7 +109,7 @@ impl<'f, 'tcx> Combine<'tcx> for Glb<'f, 'tcx> { } fn regions(&self, a: ty::Region, b: ty::Region) -> cres<ty::Region> { - debug!("{}.regions({:?}, {:?})", + debug!("{}.regions({}, {})", self.tag(), a.repr(self.fields.infcx.tcx), b.repr(self.fields.infcx.tcx)); @@ -130,7 +130,7 @@ impl<'f, 'tcx> Combine<'tcx> for Glb<'f, 'tcx> { // Note: this is a subtle algorithm. For a full explanation, // please see the large comment in `region_inference.rs`. - debug!("{}.fn_sigs({:?}, {:?})", + debug!("{}.fn_sigs({}, {})", self.tag(), a.repr(self.fields.infcx.tcx), b.repr(self.fields.infcx.tcx)); let _indenter = indenter(); @@ -254,7 +254,7 @@ impl<'f, 'tcx> Combine<'tcx> for Glb<'f, 'tcx> { } this.fields.infcx.tcx.sess.span_bug( this.fields.trace.origin.span(), - format!("could not find original bound region for {:?}", + format!("could not find original bound region for {}", r).as_slice()) } diff --git a/src/librustc/middle/typeck/infer/lattice.rs b/src/librustc/middle/typeck/infer/lattice.rs index 6095e5b0504..24642d52138 100644 --- a/src/librustc/middle/typeck/infer/lattice.rs +++ b/src/librustc/middle/typeck/infer/lattice.rs @@ -123,7 +123,7 @@ pub fn var_ids<'tcx, T: Combine<'tcx>>(this: &T, r => { this.infcx().tcx.sess.span_bug( this.trace().origin.span(), - format!("found non-region-vid: {:?}", r).as_slice()); + format!("found non-region-vid: {}", r).as_slice()); } }).collect() } diff --git a/src/librustc/middle/typeck/infer/lub.rs b/src/librustc/middle/typeck/infer/lub.rs index 276a2264837..f2d9203f843 100644 --- a/src/librustc/middle/typeck/infer/lub.rs +++ b/src/librustc/middle/typeck/infer/lub.rs @@ -157,7 +157,7 @@ impl<'f, 'tcx> Combine<'tcx> for Lub<'f, 'tcx> { // Regions that pre-dated the LUB computation stay as they are. if !is_var_in_set(new_vars, r0) { assert!(!r0.is_bound()); - debug!("generalize_region(r0={:?}): not new variable", r0); + debug!("generalize_region(r0={}): not new variable", r0); return r0; } @@ -167,8 +167,8 @@ impl<'f, 'tcx> Combine<'tcx> for Lub<'f, 'tcx> { // *related* to regions that pre-date the LUB computation // stay as they are. if !tainted.iter().all(|r| is_var_in_set(new_vars, *r)) { - debug!("generalize_region(r0={:?}): \ - non-new-variables found in {:?}", + debug!("generalize_region(r0={}): \ + non-new-variables found in {}", r0, tainted); assert!(!r0.is_bound()); return r0; @@ -181,8 +181,8 @@ impl<'f, 'tcx> Combine<'tcx> for Lub<'f, 'tcx> { // with. for (a_br, a_r) in a_map.iter() { if tainted.iter().any(|x| x == a_r) { - debug!("generalize_region(r0={:?}): \ - replacing with {:?}, tainted={:?}", + debug!("generalize_region(r0={}): \ + replacing with {}, tainted={}", r0, *a_br, tainted); return ty::ReLateBound(new_scope, *a_br); } @@ -190,7 +190,7 @@ impl<'f, 'tcx> Combine<'tcx> for Lub<'f, 'tcx> { this.fields.infcx.tcx.sess.span_bug( this.fields.trace.origin.span(), - format!("region {:?} is not associated with \ + format!("region {} is not associated with \ any bound region from A!", r0).as_slice()) } diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index 7c04b371aae..7c455b85707 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -95,7 +95,7 @@ pub struct InferCtxt<'a, 'tcx: 'a> { /// Why did we require that the two types be related? /// /// See `error_reporting.rs` for more details -#[deriving(Clone)] +#[deriving(Clone, Show)] pub enum TypeOrigin { // Not yet categorized in a better way Misc(Span), @@ -127,7 +127,7 @@ pub enum TypeOrigin { } /// See `error_reporting.rs` for more details -#[deriving(Clone)] +#[deriving(Clone, Show)] pub enum ValuePairs { Types(ty::expected_found<ty::t>), TraitRefs(ty::expected_found<Rc<ty::TraitRef>>), @@ -137,7 +137,7 @@ pub enum ValuePairs { /// encounter an error or subtyping constraint. /// /// See `error_reporting.rs` for more details. -#[deriving(Clone)] +#[deriving(Clone, Show)] pub struct TypeTrace { origin: TypeOrigin, values: ValuePairs, @@ -146,7 +146,7 @@ pub struct TypeTrace { /// The origin of a `r1 <= r2` constraint. /// /// See `error_reporting.rs` for more details -#[deriving(Clone)] +#[deriving(Clone, Show)] pub enum SubregionOrigin { // Arose from a subtyping relation Subtype(TypeTrace), @@ -224,7 +224,7 @@ pub enum SubregionOrigin { /// Reasons to create a region inference variable /// /// See `error_reporting.rs` for more details -#[deriving(Clone)] +#[deriving(Clone, Show)] pub enum RegionVariableOrigin { // Region variables created for ill-categorized reasons, // mostly indicates places in need of refactoring @@ -887,7 +887,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { expected_ty: Option<ty::t>, actual_ty: String, err: Option<&ty::type_err>) { - debug!("hi! expected_ty = {:?}, actual_ty = {}", expected_ty, actual_ty); + debug!("hi! expected_ty = {}, actual_ty = {}", expected_ty, actual_ty); let error_str = err.map_or("".to_string(), |t_err| { format!(" ({})", ty::type_err_to_str(self.tcx, t_err)) @@ -965,7 +965,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { replace_late_bound_regions_in_fn_sig(self.tcx, fsig, |br| { let rvar = self.next_region_var( BoundRegionInFnType(trace.origin.span(), br)); - debug!("Bound region {} maps to {:?}", + debug!("Bound region {} maps to {}", bound_region_to_string(self.tcx, "", false, br), rvar); rvar @@ -1120,7 +1120,7 @@ impl Repr for SubregionOrigin { } Reborrow(a) => format!("Reborrow({})", a.repr(tcx)), ReborrowUpvar(a, b) => { - format!("ReborrowUpvar({},{:?})", a.repr(tcx), b) + format!("ReborrowUpvar({},{})", a.repr(tcx), b) } ReferenceOutlivesReferent(_, a) => { format!("ReferenceOutlivesReferent({})", a.repr(tcx)) diff --git a/src/librustc/middle/typeck/infer/region_inference/mod.rs b/src/librustc/middle/typeck/infer/region_inference/mod.rs index 008ca6c0771..504550f0d40 100644 --- a/src/librustc/middle/typeck/infer/region_inference/mod.rs +++ b/src/librustc/middle/typeck/infer/region_inference/mod.rs @@ -81,7 +81,7 @@ pub enum CombineMapType { Lub, Glb } -#[deriving(Clone)] +#[deriving(Clone, Show)] pub enum RegionResolutionError { /// `ConcreteFailure(o, a, b)`: /// @@ -133,7 +133,7 @@ pub enum RegionResolutionError { /// ``` /// would report an error because we expect 'a and 'b to match, and so we group /// 'a and 'b together inside a SameRegions struct -#[deriving(Clone)] +#[deriving(Clone, Show)] pub struct SameRegions { pub scope_id: ast::NodeId, pub regions: Vec<BoundRegion> diff --git a/src/librustc/middle/typeck/infer/sub.rs b/src/librustc/middle/typeck/infer/sub.rs index 7403d50a210..158fda802ff 100644 --- a/src/librustc/middle/typeck/infer/sub.rs +++ b/src/librustc/middle/typeck/infer/sub.rs @@ -200,7 +200,7 @@ impl<'f, 'tcx> Combine<'tcx> for Sub<'f, 'tcx> { let (skol_map, b_sig) = { replace_late_bound_regions_in_fn_sig(self.fields.infcx.tcx, b, |br| { let skol = self.fields.infcx.region_vars.new_skolemized(br); - debug!("Bound region {} skolemized to {:?}", + debug!("Bound region {} skolemized to {}", bound_region_to_string(self.fields.infcx.tcx, "", false, br), skol); skol diff --git a/src/librustc/middle/typeck/infer/test.rs b/src/librustc/middle/typeck/infer/test.rs index 6ef2143b624..baa4f6d013b 100644 --- a/src/librustc/middle/typeck/infer/test.rs +++ b/src/librustc/middle/typeck/infer/test.rs @@ -315,7 +315,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { pub fn make_lub_ty(&self, t1: ty::t, t2: ty::t) -> ty::t { match self.lub().tys(t1, t2) { Ok(t) => t, - Err(ref e) => fail!("unexpected error computing LUB: {:?}", + Err(ref e) => fail!("unexpected error computing LUB: {}", ty::type_err_to_str(self.infcx.tcx, e)) } } @@ -341,7 +341,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { self.ty_to_string(t_glb)); match self.glb().tys(t1, t2) { Err(e) => { - fail!("unexpected error computing LUB: {:?}", e) + fail!("unexpected error computing LUB: {}", e) } Ok(t) => { self.assert_eq(t, t_glb); diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index e93ad056051..5a23d54c972 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -87,13 +87,13 @@ pub mod collect; pub mod coherence; pub mod variance; -#[deriving(Clone, Encodable, Decodable, PartialEq, PartialOrd)] +#[deriving(Clone, Encodable, Decodable, PartialEq, PartialOrd, Show)] pub struct param_index { pub space: subst::ParamSpace, pub index: uint } -#[deriving(Clone)] +#[deriving(Clone, Show)] pub enum MethodOrigin { // fully statically resolved method MethodStatic(ast::DefId), @@ -111,7 +111,7 @@ pub enum MethodOrigin { // details for a method invoked with a receiver whose type is a type parameter // with a bounded trait. -#[deriving(Clone)] +#[deriving(Clone, Show)] pub struct MethodParam { // the precise trait reference that occurs as a bound -- this may // be a supertrait of what the user actually typed. @@ -122,7 +122,7 @@ pub struct MethodParam { } // details for a method invoked with a receiver whose type is an object -#[deriving(Clone)] +#[deriving(Clone, Show)] pub struct MethodObject { // the (super)trait containing the method to be invoked pub trait_ref: Rc<ty::TraitRef>, @@ -249,7 +249,7 @@ impl Repr for vtable_origin { fn repr(&self, tcx: &ty::ctxt) -> String { match *self { vtable_static(def_id, ref tys, ref vtable_res) => { - format!("vtable_static({:?}:{}, {}, {})", + format!("vtable_static({}:{}, {}, {})", def_id, ty::item_path_str(tcx, def_id), tys.repr(tcx), @@ -257,7 +257,7 @@ impl Repr for vtable_origin { } vtable_param(x, y) => { - format!("vtable_param({:?}, {:?})", x, y) + format!("vtable_param({}, {})", x, y) } vtable_unboxed_closure(def_id) => { diff --git a/src/librustc/middle/typeck/variance.rs b/src/librustc/middle/typeck/variance.rs index 60a7aa77904..dd6e087b672 100644 --- a/src/librustc/middle/typeck/variance.rs +++ b/src/librustc/middle/typeck/variance.rs @@ -232,6 +232,7 @@ pub fn infer_variance(tcx: &ty::ctxt) { type VarianceTermPtr<'a> = &'a VarianceTerm<'a>; +#[deriving(Show)] struct InferredIndex(uint); enum VarianceTerm<'a> { @@ -325,10 +326,10 @@ impl<'a, 'tcx> TermsContext<'a, 'tcx> { assert!(newly_added); debug!("add_inferred(item_id={}, \ - kind={:?}, \ + kind={}, \ index={}, \ param_id={}, - inf_index={:?})", + inf_index={})", item_id, kind, index, param_id, inf_index); } @@ -852,7 +853,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { region_param_defs: &[ty::RegionParameterDef], substs: &subst::Substs, variance: VarianceTermPtr<'a>) { - debug!("add_constraints_from_substs(def_id={:?})", def_id); + debug!("add_constraints_from_substs(def_id={})", def_id); for p in type_param_defs.iter() { let variance_decl = diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 8ea9015c05d..082dde978d8 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -13,6 +13,7 @@ use std::cell::RefCell; use std::collections::HashMap; use std::hash::{Hash, Hasher}; +use std::fmt::Show; use syntax::ast; use syntax::visit; use syntax::visit::Visitor; @@ -36,12 +37,12 @@ pub fn time<T, U>(do_it: bool, what: &str, u: U, f: |U| -> T) -> T { rv } -pub fn indent<R>(op: || -> R) -> R { +pub fn indent<R: Show>(op: || -> R) -> R { // Use in conjunction with the log post-processor like `src/etc/indenter` // to make debug output more readable. debug!(">>"); let r = op(); - debug!("<< (Result = {:?})", r); + debug!("<< (Result = {})", r); r } diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 459e7eb093e..404864cec04 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -154,7 +154,7 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region) // I believe these cases should not occur (except when debugging, // perhaps) ty::ReInfer(_) | ty::ReLateBound(..) => { - (format!("lifetime {:?}", region), None) + (format!("lifetime {}", region), None) } }; @@ -599,7 +599,7 @@ impl<T:UserString> UserString for Vec<T> { impl Repr for def::Def { fn repr(&self, _tcx: &ctxt) -> String { - format!("{:?}", *self) + format!("{}", *self) } } @@ -843,14 +843,14 @@ impl Repr for ast::DefId { Some(ast_map::NodeVariant(..)) | Some(ast_map::NodeStructCtor(..)) => { return format!( - "{:?}:{}", + "{}:{}", *self, ty::item_path_str(tcx, *self)) } _ => {} } } - return format!("{:?}", *self) + return format!("{}", *self) } } @@ -922,19 +922,19 @@ impl Repr for ast::Ident { impl Repr for ast::ExplicitSelf_ { fn repr(&self, _tcx: &ctxt) -> String { - format!("{:?}", *self) + format!("{}", *self) } } impl Repr for ast::Visibility { fn repr(&self, _tcx: &ctxt) -> String { - format!("{:?}", *self) + format!("{}", *self) } } impl Repr for ty::BareFnTy { fn repr(&self, tcx: &ctxt) -> String { - format!("BareFnTy {{fn_style: {:?}, abi: {}, sig: {}}}", + format!("BareFnTy {{fn_style: {}, abi: {}, sig: {}}}", self.fn_style, self.abi.to_string(), self.sig.repr(tcx)) @@ -985,7 +985,7 @@ impl Repr for typeck::MethodParam { impl Repr for typeck::MethodObject { fn repr(&self, tcx: &ctxt) -> String { - format!("MethodObject({},{:?},{:?})", + format!("MethodObject({},{},{})", self.trait_ref.repr(tcx), self.method_num, self.real_index) @@ -1000,7 +1000,7 @@ impl Repr for ty::TraitStore { impl Repr for ty::BuiltinBound { fn repr(&self, _tcx: &ctxt) -> String { - format!("{:?}", *self) + format!("{}", *self) } } @@ -1118,13 +1118,13 @@ impl Repr for ty::UpvarId { impl Repr for ast::Mutability { fn repr(&self, _tcx: &ctxt) -> String { - format!("{:?}", *self) + format!("{}", *self) } } impl Repr for ty::BorrowKind { fn repr(&self, _tcx: &ctxt) -> String { - format!("{:?}", *self) + format!("{}", *self) } } @@ -1162,25 +1162,25 @@ impl Repr for ty::TyVid { impl Repr for ty::IntVarValue { fn repr(&self, _tcx: &ctxt) -> String { - format!("{:?}", *self) + format!("{}", *self) } } impl Repr for ast::IntTy { fn repr(&self, _tcx: &ctxt) -> String { - format!("{:?}", *self) + format!("{}", *self) } } impl Repr for ast::UintTy { fn repr(&self, _tcx: &ctxt) -> String { - format!("{:?}", *self) + format!("{}", *self) } } impl Repr for ast::FloatTy { fn repr(&self, _tcx: &ctxt) -> String { - format!("{:?}", *self) + format!("{}", *self) } } diff --git a/src/librustc_back/abi.rs b/src/librustc_back/abi.rs index bf525db7661..aa07b9a5034 100644 --- a/src/librustc_back/abi.rs +++ b/src/librustc_back/abi.rs @@ -14,8 +14,6 @@ pub const box_field_refcnt: uint = 0u; pub const box_field_drop_glue: uint = 1u; pub const box_field_body: uint = 4u; -pub const tydesc_field_visit_glue: uint = 3u; - // The two halves of a closure: code and environment. pub const fn_field_code: uint = 0u; pub const fn_field_box: uint = 1u; diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 7e9bb2844a7..102ba5820fe 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1251,7 +1251,7 @@ impl Clean<Type> for ast::Ty { TyBareFn(ref barefn) => BareFunction(box barefn.clean(cx)), TyParen(ref ty) => ty.clean(cx), TyBot => Bottom, - ref x => fail!("Unimplemented type {:?}", x), + ref x => fail!("Unimplemented type {}", x), } } } @@ -1575,7 +1575,7 @@ impl Clean<VariantKind> for ast::VariantKind { } } -#[deriving(Clone, Encodable, Decodable)] +#[deriving(Clone, Encodable, Decodable, Show)] pub struct Span { pub filename: String, pub loline: uint, @@ -1714,7 +1714,7 @@ impl Clean<BareFunctionDecl> for ast::BareFnTy { } } -#[deriving(Clone, Encodable, Decodable)] +#[deriving(Clone, Encodable, Decodable, Show)] pub struct Static { pub type_: Type, pub mutability: Mutability, @@ -1726,7 +1726,7 @@ pub struct Static { impl Clean<Item> for doctree::Static { fn clean(&self, cx: &DocContext) -> Item { - debug!("claning static {}: {:?}", self.name.clean(cx), self); + debug!("claning static {}: {}", self.name.clean(cx), self); Item { name: Some(self.name.clean(cx)), attrs: self.attrs.clean(cx), @@ -2004,7 +2004,7 @@ trait ToSource { impl ToSource for syntax::codemap::Span { fn to_src(&self, cx: &DocContext) -> String { - debug!("converting span {:?} to snippet", self.clean(cx)); + debug!("converting span {} to snippet", self.clean(cx)); let sn = match cx.sess().codemap().span_to_snippet(*self) { Some(x) => x.to_string(), None => "".to_string() @@ -2017,7 +2017,7 @@ impl ToSource for syntax::codemap::Span { fn lit_to_string(lit: &ast::Lit) -> String { match lit.node { ast::LitStr(ref st, _) => st.get().to_string(), - ast::LitBinary(ref data) => format!("{:?}", data.as_slice()), + ast::LitBinary(ref data) => format!("{}", data), ast::LitByte(b) => { let mut res = String::from_str("b'"); (b as char).escape_default(|c| { @@ -2037,7 +2037,7 @@ fn lit_to_string(lit: &ast::Lit) -> String { fn name_from_pat(p: &ast::Pat) -> String { use syntax::ast::*; - debug!("Trying to get a name from pattern: {:?}", p); + debug!("Trying to get a name from pattern: {}", p); match p.node { PatWild(PatWildSingle) => "_".to_string(), @@ -2082,7 +2082,7 @@ fn resolve_type(cx: &DocContext, path: Path, // If we're extracting tests, this return value doesn't matter. None => return Primitive(Bool), }; - debug!("searching for {:?} in defmap", id); + debug!("searching for {} in defmap", id); let def = match tcx.def_map.borrow().find(&id) { Some(&k) => k, None => fail!("unresolved id not in defmap") diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index f0f08ff7077..c5c9aae89e4 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -135,7 +135,7 @@ pub fn run_core(libs: Vec<Path>, cfgs: Vec<String>, externs: Externs, inlined: RefCell::new(Some(HashSet::new())), populated_crate_impls: RefCell::new(HashSet::new()), }; - debug!("crate: {:?}", ctxt.krate); + debug!("crate: {}", ctxt.krate); let analysis = CrateAnalysis { exported_items: exported_items, diff --git a/src/librustdoc/doctree.rs b/src/librustdoc/doctree.rs index b173f0f16e3..7509f96f916 100644 --- a/src/librustdoc/doctree.rs +++ b/src/librustdoc/doctree.rs @@ -141,6 +141,7 @@ pub struct Typedef { pub stab: Option<attr::Stability>, } +#[deriving(Show)] pub struct Static { pub type_: P<ast::Ty>, pub mutability: ast::Mutability, diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 497bbd3a1cd..b4bf1668d94 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1042,7 +1042,7 @@ impl Context { /// sure it always points to the top (relatively) fn recurse<T>(&mut self, s: String, f: |&mut Context| -> T) -> T { if s.len() == 0 { - fail!("what {:?}", self); + fail!("Unexpected empty destination: {}", self.current); } let prev = self.dst.clone(); self.dst.push(s.as_slice()); @@ -1491,7 +1491,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context, indices.sort_by(|&i1, &i2| cmp(&items[i1], &items[i2], i1, i2)); - debug!("{:?}", indices); + debug!("{}", indices); let mut curty = None; for &idx in indices.iter() { let myitem = &items[idx]; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 77d63224fcd..ad79faebd45 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; @@ -334,7 +333,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche let (mut krate, analysis) = std::task::try(proc() { let cr = cr; core::run_core(libs, cfgs, externs, &cr, triple) - }).map_err(|boxed_any|format!("{:?}", boxed_any)).unwrap(); + }).map_err(|_| "rustc failed").unwrap(); info!("finished with rustc"); analysiskey.replace(Some(analysis)); @@ -481,7 +480,7 @@ fn json_output(krate: clean::Crate, res: Vec<plugins::PluginJson> , }; let crate_json = match json::from_str(crate_json_str.as_slice()) { Ok(j) => j, - Err(e) => fail!("Rust generated JSON is invalid: {:?}", e) + Err(e) => fail!("Rust generated JSON is invalid: {}", e) }; json.insert("crate".to_string(), crate_json); diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index 6456f4acd30..8e377037a97 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -264,7 +264,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { pub fn visit_item(&mut self, item: &ast::Item, renamed: Option<ast::Ident>, om: &mut Module) { - debug!("Visiting item {:?}", item); + debug!("Visiting item {}", item); let name = renamed.unwrap_or(item.ident); match item.node { ast::ItemMod(ref m) => { diff --git a/src/librustrt/rtio.rs b/src/librustrt/rtio.rs index 1afd88edbc2..a08bc697602 100644 --- a/src/librustrt/rtio.rs +++ b/src/librustrt/rtio.rs @@ -356,6 +356,7 @@ pub trait PausableIdleCallback { pub trait RtioSignal {} +#[deriving(Show)] pub struct IoError { pub code: uint, pub extra: uint, diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs index bc71f8ae790..ed8ff821f5c 100644 --- a/src/libstd/dynamic_lib.rs +++ b/src/libstd/dynamic_lib.rs @@ -183,7 +183,7 @@ mod test { let expected_result = 1.0; let result = cosine(argument); if result != expected_result { - fail!("cos({:?}) != {:?} but equaled {:?} instead", argument, + fail!("cos({}) != {} but equaled {} instead", argument, expected_result, result) } } 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/io/fs.rs b/src/libstd/io/fs.rs index e8fed67fffe..8632fc63e52 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -963,7 +963,7 @@ mod test { macro_rules! error( ($e:expr, $s:expr) => ( match $e { - Ok(val) => fail!("Should have been an error, was {:?}", val), + Ok(val) => fail!("Unexpected success. Should've been: {}", $s), Err(ref err) => assert!(err.to_string().as_slice().contains($s.as_slice()), format!("`{}` did not contain `{}`", err, $s)) } diff --git a/src/libstd/io/net/pipe.rs b/src/libstd/io/net/pipe.rs index 3f8069468f6..e0cf761fdbd 100644 --- a/src/libstd/io/net/pipe.rs +++ b/src/libstd/io/net/pipe.rs @@ -340,7 +340,7 @@ mod tests { assert!(e.kind == BrokenPipe || e.kind == NotConnected || e.kind == ConnectionReset, - "unknown error {:?}", e); + "unknown error {}", e); break; } } 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/libstd/os.rs b/src/libstd/os.rs index 03eca5c728b..e758dec6bff 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -1975,7 +1975,7 @@ mod tests { let path = os::self_exe_name(); assert!(path.is_some()); let path = path.unwrap(); - debug!("{:?}", path.clone()); + debug!("{}", path.display()); // Hard to test this function assert!(path.is_absolute()); @@ -1986,7 +1986,7 @@ mod tests { let path = os::self_exe_path(); assert!(path.is_some()); let path = path.unwrap(); - debug!("{:?}", path.clone()); + debug!("{}", path.display()); // Hard to test this function assert!(path.is_absolute()); @@ -1999,7 +1999,7 @@ mod tests { assert!(e.len() > 0u); for p in e.iter() { let (n, v) = (*p).clone(); - debug!("{:?}", n.clone()); + debug!("{}", n); let v2 = getenv(n.as_slice()); // MingW seems to set some funky environment variables like // "=C:=C:\MinGW\msys\1.0\bin" and "!::=::\" that are returned @@ -2037,8 +2037,8 @@ mod tests { let cwd = getcwd(); debug!("Current working directory: {}", cwd.display()); - debug!("{:?}", make_absolute(&Path::new("test-path"))); - debug!("{:?}", make_absolute(&Path::new("/usr/bin"))); + debug!("{}", make_absolute(&Path::new("test-path")).display()); + debug!("{}", make_absolute(&Path::new("/usr/bin")).display()); } #[test] diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index 27eafdab642..69b6dd76676 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -986,19 +986,19 @@ mod tests { let path = $path; let filename = $filename; assert!(path.filename_str() == filename, - "{}.filename_str(): Expected `{:?}`, found {:?}", + "{}.filename_str(): Expected `{}`, found {}", path.as_str().unwrap(), filename, path.filename_str()); let dirname = $dirname; assert!(path.dirname_str() == dirname, - "`{}`.dirname_str(): Expected `{:?}`, found `{:?}`", + "`{}`.dirname_str(): Expected `{}`, found `{}`", path.as_str().unwrap(), dirname, path.dirname_str()); let filestem = $filestem; assert!(path.filestem_str() == filestem, - "`{}`.filestem_str(): Expected `{:?}`, found `{:?}`", + "`{}`.filestem_str(): Expected `{}`, found `{}`", path.as_str().unwrap(), filestem, path.filestem_str()); let ext = $ext; assert!(path.extension_str() == mem::transmute(ext), - "`{}`.extension_str(): Expected `{:?}`, found `{:?}`", + "`{}`.extension_str(): Expected `{}`, found `{}`", path.as_str().unwrap(), ext, path.extension_str()); } } @@ -1200,11 +1200,11 @@ mod tests { let comps = path.components().collect::<Vec<&[u8]>>(); let exp: &[&str] = $exp; let exps = exp.iter().map(|x| x.as_bytes()).collect::<Vec<&[u8]>>(); - assert!(comps == exps, "components: Expected {:?}, found {:?}", + assert!(comps == exps, "components: Expected {}, found {}", comps, exps); let comps = path.components().rev().collect::<Vec<&[u8]>>(); let exps = exps.into_iter().rev().collect::<Vec<&[u8]>>(); - assert!(comps == exps, "rev_components: Expected {:?}, found {:?}", + assert!(comps == exps, "rev_components: Expected {}, found {}", comps, exps); } ); diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 5bd738ed58b..4456cf96094 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -996,7 +996,7 @@ pub fn is_sep_byte_verbatim(u: &u8) -> bool { } /// Prefix types for Path -#[deriving(PartialEq, Clone)] +#[deriving(PartialEq, Clone, Show)] pub enum PathPrefix { /// Prefix `\\?\`, uint is the length of the following component VerbatimPrefix(uint), @@ -1172,7 +1172,7 @@ mod tests { let exp = $exp; let res = parse_prefix(path); assert!(res == exp, - "parse_prefix(\"{}\"): expected {:?}, found {:?}", path, exp, res); + "parse_prefix(\"{}\"): expected {}, found {}", path, exp, res); } ) ) @@ -1904,19 +1904,19 @@ mod tests { let path = $path; let filename = $filename; assert!(path.filename_str() == filename, - "`{}`.filename_str(): Expected `{:?}`, found `{:?}`", + "`{}`.filename_str(): Expected `{}`, found `{}`", path.as_str().unwrap(), filename, path.filename_str()); let dirname = $dirname; assert!(path.dirname_str() == dirname, - "`{}`.dirname_str(): Expected `{:?}`, found `{:?}`", + "`{}`.dirname_str(): Expected `{}`, found `{}`", path.as_str().unwrap(), dirname, path.dirname_str()); let filestem = $filestem; assert!(path.filestem_str() == filestem, - "`{}`.filestem_str(): Expected `{:?}`, found `{:?}`", + "`{}`.filestem_str(): Expected `{}`, found `{}`", path.as_str().unwrap(), filestem, path.filestem_str()); let ext = $ext; assert!(path.extension_str() == mem::transmute(ext), - "`{}`.extension_str(): Expected `{:?}`, found `{:?}`", + "`{}`.extension_str(): Expected `{}`, found `{}`", path.as_str().unwrap(), ext, path.extension_str()); } } @@ -1974,16 +1974,16 @@ mod tests { let path = Path::new($path); let (abs, vol, cwd, rel) = ($abs, $vol, $cwd, $rel); let b = path.is_absolute(); - assert!(b == abs, "Path '{}'.is_absolute(): expected {:?}, found {:?}", + assert!(b == abs, "Path '{}'.is_absolute(): expected {}, found {}", path.as_str().unwrap(), abs, b); let b = is_vol_relative(&path); - assert!(b == vol, "is_vol_relative('{}'): expected {:?}, found {:?}", + assert!(b == vol, "is_vol_relative('{}'): expected {}, found {}", path.as_str().unwrap(), vol, b); let b = is_cwd_relative(&path); - assert!(b == cwd, "is_cwd_relative('{}'): expected {:?}, found {:?}", + assert!(b == cwd, "is_cwd_relative('{}'): expected {}, found {}", path.as_str().unwrap(), cwd, b); let b = path.is_relative(); - assert!(b == rel, "Path '{}'.is_relativf(): expected {:?}, found {:?}", + assert!(b == rel, "Path '{}'.is_relativf(): expected {}, found {}", path.as_str().unwrap(), rel, b); } ) @@ -2016,7 +2016,7 @@ mod tests { let exp = $exp; let res = path.is_ancestor_of(&dest); assert!(res == exp, - "`{}`.is_ancestor_of(`{}`): Expected {:?}, found {:?}", + "`{}`.is_ancestor_of(`{}`): Expected {}, found {}", path.as_str().unwrap(), dest.as_str().unwrap(), exp, res); } ) @@ -2151,7 +2151,7 @@ mod tests { let res = path.path_relative_from(&other); let exp = $exp; assert!(res.as_ref().and_then(|x| x.as_str()) == exp, - "`{}`.path_relative_from(`{}`): Expected {:?}, got {:?}", + "`{}`.path_relative_from(`{}`): Expected {}, got {}", path.as_str().unwrap(), other.as_str().unwrap(), exp, res.as_ref().and_then(|x| x.as_str())); } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index c1aa588eecc..df63d161eec 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -81,7 +81,7 @@ impl PartialEq for Ident { // one example and its non-hygienic counterpart would be: // syntax::parse::token::mtwt_token_eq // syntax::ext::tt::macro_parser::token_name_eq - fail!("not allowed to compare these idents: {:?}, {:?}. \ + fail!("not allowed to compare these idents: {}, {}. \ Probably related to issue \\#6993", self, other); } } diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs index 2d0cea2fefc..fb5373cee00 100644 --- a/src/libsyntax/ast_map/mod.rs +++ b/src/libsyntax/ast_map/mod.rs @@ -96,6 +96,7 @@ pub fn path_to_string<PI: Iterator<PathElem>>(mut path: PI) -> String { }).to_string() } +#[deriving(Show)] pub enum Node<'ast> { NodeItem(&'ast Item), NodeForeignItem(&'ast ForeignItem), @@ -387,7 +388,7 @@ impl<'ast> Map<'ast> { PathName(ident.name) } MethMac(_) => { - fail!("no path elem for {:?}", node) + fail!("no path elem for {}", node) } } } @@ -401,13 +402,13 @@ impl<'ast> Map<'ast> { MethDecl(ident, _, _, _, _, _, _, _) => { PathName(ident.name) } - MethMac(_) => fail!("no path elem for {:?}", node), + MethMac(_) => fail!("no path elem for {}", node), } } TypeTraitItem(ref m) => PathName(m.ident.name), }, NodeVariant(v) => PathName(v.node.name.name), - _ => fail!("no path elem for {:?}", node) + _ => fail!("no path elem for {}", node) } } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index f51c2985f0b..726aceb5819 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -308,7 +308,7 @@ pub fn empty_generics() -> Generics { // ______________________________________________________________________ // Enumerating the IDs which appear in an AST -#[deriving(Encodable, Decodable)] +#[deriving(Encodable, Decodable, Show)] pub struct IdRange { pub min: NodeId, pub max: NodeId, diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 575dcf32dd6..c792d4b99ee 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1700,11 +1700,11 @@ foo_module!() }).enumerate() { if mtwt::resolve(v.segments.get(0).identifier) != resolved_binding { println!("uh oh, xx binding didn't match xx varref:"); - println!("this is xx varref \\# {:?}",idx); - println!("binding: {:?}",cxbind); - println!("resolves to: {:?}",resolved_binding); - println!("varref: {:?}",v.segments.get(0).identifier); - println!("resolves to: {:?}", + println!("this is xx varref \\# {}", idx); + println!("binding: {}", cxbind); + println!("resolves to: {}", resolved_binding); + println!("varref: {}", v.segments.get(0).identifier); + println!("resolves to: {}", mtwt::resolve(v.segments.get(0).identifier)); mtwt::with_sctable(|x| mtwt::display_sctable(x)); } diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index 1ed41e6870d..07f0ca85f35 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -668,7 +668,6 @@ impl<'a, 'b> Context<'a, 'b> { Known(ref tyname) => { match tyname.as_slice() { "" => ("std", "secret_show"), - "?" => ("debug", "secret_poly"), "b" => ("std", "secret_bool"), "c" => ("std", "secret_char"), "d" | "i" => ("std", "secret_signed"), diff --git a/src/libsyntax/ext/mtwt.rs b/src/libsyntax/ext/mtwt.rs index 6fe4f5b324c..523299abce1 100644 --- a/src/libsyntax/ext/mtwt.rs +++ b/src/libsyntax/ext/mtwt.rs @@ -38,7 +38,7 @@ pub struct SCTable { rename_memo: RefCell<HashMap<(SyntaxContext,Ident,Name),SyntaxContext>>, } -#[deriving(PartialEq, Encodable, Decodable, Hash)] +#[deriving(PartialEq, Encodable, Decodable, Hash, Show)] pub enum SyntaxContext_ { EmptyCtxt, Mark (Mrk,SyntaxContext), @@ -129,7 +129,7 @@ fn new_sctable_internal() -> SCTable { pub fn display_sctable(table: &SCTable) { error!("SC table:"); for (idx,val) in table.table.borrow().iter().enumerate() { - error!("{:4u} : {:?}",idx,val); + error!("{:4u} : {}",idx,val); } } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 8faecd407a8..2eb3b398da8 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -1389,7 +1389,7 @@ mod test { let a_val = $a; let b_val = $b; if !(pred_val(a_val.as_slice(),b_val.as_slice())) { - fail!("expected args satisfying {}, got {:?} and {:?}", + fail!("expected args satisfying {}, got {} and {}", $predname, a_val, b_val); } } 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/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index 74b93e75e64..17dd546ad59 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -63,7 +63,7 @@ impl<'a> ParserAttr for Parser<'a> { /// If permit_inner is true, then a leading `!` indicates an inner /// attribute fn parse_attribute(&mut self, permit_inner: bool) -> ast::Attribute { - debug!("parse_attributes: permit_inner={:?} self.token={:?}", + debug!("parse_attributes: permit_inner={} self.token={}", permit_inner, self.token); let (span, value, mut style) = match self.token { token::POUND => { diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 66ecdbfca02..c4a8775a012 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -823,19 +823,19 @@ mod test { } }, _ => { - error!("failing value 3: {:?}",first_set); + error!("failing value 3: {}",first_set); assert_eq!("wrong 3","correct") } } }, _ => { - error!("failing value 2: {:?}",delim_elts); + error!("failing value 2: {}",delim_elts); assert_eq!("wrong","correct"); } } }, _ => { - error!("failing value: {:?}",tts); + error!("failing value: {}",tts); assert_eq!("wrong 1","correct"); } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index d5253cff6cb..7e77283cca7 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -492,7 +492,7 @@ impl<'a> Parser<'a> { /// followed by some token from the set edible + inedible. Recover /// from anticipated input errors, discarding erroneous characters. pub fn commit_expr(&mut self, e: &Expr, edible: &[token::Token], inedible: &[token::Token]) { - debug!("commit_expr {:?}", e); + debug!("commit_expr {}", e); match e.node { ExprPath(..) => { // might be unit-struct construction; check for recoverableinput error. @@ -1535,7 +1535,7 @@ impl<'a> Parser<'a> { // TYPE TO BE INFERRED TyInfer } else { - let msg = format!("expected type, found token {:?}", self.token); + let msg = format!("expected type, found token {}", self.token); self.fatal(msg.as_slice()); }; @@ -1591,7 +1591,7 @@ impl<'a> Parser<'a> { /// identifier names. pub fn parse_arg_general(&mut self, require_name: bool) -> Arg { let pat = if require_name || self.is_named_argument() { - debug!("parse_arg_general parse_pat (require_name:{:?})", + debug!("parse_arg_general parse_pat (require_name:{})", require_name); let pat = self.parse_pat(); @@ -1882,7 +1882,7 @@ impl<'a> Parser<'a> { token::BINOP(token::SHR) => { return res; } _ => { let msg = format!("expected `,` or `>` after lifetime \ - name, got: {:?}", + name, got: {}", self.token); self.fatal(msg.as_slice()); } @@ -4711,7 +4711,7 @@ impl<'a> Parser<'a> { attrs = attrs_remaining.clone().append(attrs.as_slice()); first = false; } - debug!("parse_mod_items: parse_item_or_view_item(attrs={:?})", + debug!("parse_mod_items: parse_item_or_view_item(attrs={})", attrs); match self.parse_item_or_view_item(attrs, true /* macros allowed */) { 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<T>() { 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<request>, responses: &Sender<uint>) { 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<request>, responses: &Sender<uint>) { 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<int> = box 42; let mut x: Box<int>; 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<int> = box 42; let mut x: Box<int>; 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<T:Send>(ch: _chan<T>, data: T) { - println!("{:?}", ch); - println!("{:?}", data); +fn send<T:Send + std::fmt::Show>(ch: _chan<T>, data: T) { + println!("{}", ch); + println!("{}", data); fail!(); } +#[deriving(Show)] struct _chan<T>(int); // Tests that "log(debug, message);" is flagged as using // message after the send deinitializes it fn test00_start(ch: _chan<Box<int>>, message: Box<int>, _count: Box<int>) { 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: &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<Vec<int> >), t2, } fn foo(t: bar) { match t { t1(_, Some::<int>(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::<int,String>("kitty".to_string()).unwrap()); + println!("{}", result::Err::<int,String>("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,B> { a: A, b: B } @@ -38,7 +36,7 @@ fn f<A:Clone + 'static>(a: A, b: u16) -> Box<Invokable<A>+'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<T, U> { a: T, b: U } struct Triple { x: int, y: int, z: int } fn f<T,U>(x: T, y: U) -> Pair<T, U> { 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<T>(v: Vec<T> , 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<T>(v: Vec<T> , 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<int>, values: Vec<int> } 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,B> { a: A, b: B } @@ -42,7 +40,7 @@ fn f<A:Clone + 'static>(a: A, b: u16) -> Box<Invokable<A>+'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 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// FIXME(15049) Re-enable this test. -// ignore-test -// Test that structs with unsized fields work with {:?} reflection. - -extern crate debug; - -struct Fat<Sized? T> { - 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::<E>(), 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 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -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:Send>(t: T) -> T { return t; } pub fn main() { let expected = box 100i; let actual = id::<Box<int>>(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) -> X { return x; } #[deriving(Clone)] @@ -25,8 +23,8 @@ fn f<T:Clone>(t: T) -> Pair<T> { pub fn main() { let b = f::<int>(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<T>(x: Box<T>) -> Box<T> { 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<T> { some(T), } struct Pair { x: int, y: int } pub fn main() { let nop: noption<int> = some::<int>(5); - match nop { some::<int>(n) => { println!("{:?}", n); assert!((n == 5)); } } + match nop { some::<int>(n) => { println!("{}", n); assert!((n == 5)); } } let nop2: noption<Pair> = 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)) -> 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: Repro>(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 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![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<String, int>) { - 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<String, json:: } _ => { - 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<T>(&self, x: &T); - fn default_method<T>(&self, x: &T) { - println!("X::default_method {:?} {:?}", self, x); + fn call<T: std::fmt::Show>(&self, x: &T); + fn default_method<T: std::fmt::Show>(&self, x: &T) { + println!("X::default_method {}", x); } } +#[deriving(Show)] struct Y(int); +#[deriving(Show)] struct Z<T> { x: T } impl X for Y { - fn call<T>(&self, x: &T) { - println!("X::call {:?} {:?}", self, x); + fn call<T: std::fmt::Show>(&self, x: &T) { + println!("X::call {} {}", self, x); } } #[unsafe_destructor] -impl<T: X> Drop for Z<T> { +impl<T: X + std::fmt::Show> Drop for Z<T> { 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<T>(obj : T, expected : String) { - assert_eq!(expected, format!("{:?}", obj)); +fn assert_repr_eq<T: std::fmt::Show>(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<int> } 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<T>(exp: String, v: T) { - assert_eq!(exp, format!("{:?}", v)); +fn check_log<T: std::fmt::Show>(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::<int>(_x) => { let mut bar; match None::<int> { None::<int> => { bar = 5i; } _ => { baz(); } } - println!("{:?}", bar); + println!("{}", bar); } None::<int> => { 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<K,V> { @@ -30,14 +28,14 @@ impl<K,V> AssociationList<K,V> { } } -impl<K:PartialEq,V:Clone> Index<K,V> for AssociationList<K,V> { +impl<K: PartialEq + std::fmt::Show, V:Clone> Index<K,V> for AssociationList<K,V> { 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::<Inner>()); - println!("size outer = {:?}", mem::size_of::<Outer>()); + println!("align inner = {}", rusti::min_align_of::<Inner>()); + println!("size outer = {}", mem::size_of::<Outer>()); 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::<Outer>(), m::size()); - assert_eq!(y, "Outer{c8: 22u8, t: Inner{c64: 44u32}}".to_string()); + assert_eq!(y, "Outer { c8: 22, t: Inner { c64: 44 } }".to_string()); } } 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::<Inner>()); println!("size outer = {}", mem::size_of::<Outer>()); @@ -96,6 +95,6 @@ pub fn main() { // because `Inner`s alignment was 4. assert_eq!(mem::size_of::<Outer>(), m::m::size()); - assert_eq!(y, "Outer{c8: 22u8, t: Inner{c64: 44u64}}".to_string()); + assert_eq!(y, "Outer { c8: 22, t: Inner { c64: 44 } }".to_string()); } } diff --git a/src/test/run-pass/reflect-visit-type.rs b/src/test/run-pass/reflect-visit-type.rs deleted file mode 100644 index 5de34dc2df5..00000000000 --- a/src/test/run-pass/reflect-visit-type.rs +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::intrinsics::{TyDesc, get_tydesc, visit_tydesc, TyVisitor, Disr, Opaque}; - -struct MyVisitor { - types: Vec<String> , -} - -impl TyVisitor for MyVisitor { - fn visit_bot(&mut self) -> bool { - self.types.push("bot".to_string()); - println!("visited bot type"); - true - } - fn visit_nil(&mut self) -> bool { - self.types.push("nil".to_string()); - println!("visited nil type"); - true - } - fn visit_bool(&mut self) -> bool { - self.types.push("bool".to_string()); - println!("visited bool type"); - true - } - fn visit_int(&mut self) -> bool { - self.types.push("int".to_string()); - println!("visited int type"); - true - } - fn visit_i8(&mut self) -> bool { - self.types.push("i8".to_string()); - println!("visited i8 type"); - true - } - fn visit_i16(&mut self) -> bool { - self.types.push("i16".to_string()); - println!("visited i16 type"); - true - } - fn visit_i32(&mut self) -> bool { true } - fn visit_i64(&mut self) -> bool { true } - - fn visit_uint(&mut self) -> bool { true } - fn visit_u8(&mut self) -> bool { true } - fn visit_u16(&mut self) -> bool { true } - fn visit_u32(&mut self) -> bool { true } - fn visit_u64(&mut self) -> bool { true } - - fn visit_f32(&mut self) -> bool { true } - fn visit_f64(&mut self) -> bool { true } - - fn visit_char(&mut self) -> bool { true } - - fn visit_estr_slice(&mut self) -> bool { true } - - fn visit_box(&mut self, _mtbl: uint, _inner: *const TyDesc) -> bool { true } - fn visit_uniq(&mut self, _mtbl: uint, _inner: *const TyDesc) -> bool { true } - fn visit_ptr(&mut self, _mtbl: uint, _inner: *const TyDesc) -> bool { true } - fn visit_rptr(&mut self, _mtbl: uint, _inner: *const TyDesc) -> bool { true } - - fn visit_evec_slice(&mut self, _mtbl: uint, _inner: *const TyDesc) -> bool { true } - fn visit_evec_fixed(&mut self, _n: uint, _sz: uint, _align: uint, - _inner: *const TyDesc) -> bool { true } - - fn visit_enter_rec(&mut self, _n_fields: uint, - _sz: uint, _align: uint) -> bool { true } - fn visit_rec_field(&mut self, _i: uint, _name: &str, - _mtbl: uint, _inner: *const TyDesc) -> bool { true } - fn visit_leave_rec(&mut self, _n_fields: uint, - _sz: uint, _align: uint) -> bool { true } - - fn visit_enter_class(&mut self, _name: &str, _named_fields: bool, _n_fields: uint, - _sz: uint, _align: uint) -> bool { true } - fn visit_class_field(&mut self, _i: uint, _name: &str, _named: bool, - _mtbl: uint, _inner: *const TyDesc) -> bool { true } - fn visit_leave_class(&mut self, _name: &str, _named_fields: bool, _n_fields: uint, - _sz: uint, _align: uint) -> bool { true } - - fn visit_enter_tup(&mut self, _n_fields: uint, - _sz: uint, _align: uint) -> bool { true } - fn visit_tup_field(&mut self, _i: uint, _inner: *const TyDesc) -> bool { true } - fn visit_leave_tup(&mut self, _n_fields: uint, - _sz: uint, _align: uint) -> bool { true } - - fn visit_enter_enum(&mut self, _n_variants: uint, - _get_disr: unsafe extern fn(ptr: *const Opaque) -> Disr, - _sz: uint, _align: uint) -> bool { true } - fn visit_enter_enum_variant(&mut self, - _variant: uint, - _disr_val: Disr, - _n_fields: uint, - _name: &str) -> bool { true } - fn visit_enum_variant_field(&mut self, _i: uint, _offset: uint, _inner: *const TyDesc) - -> bool { true } - fn visit_leave_enum_variant(&mut self, - _variant: uint, - _disr_val: Disr, - _n_fields: uint, - _name: &str) -> bool { true } - fn visit_leave_enum(&mut self, - _n_variants: uint, - _get_disr: unsafe extern fn(ptr: *const Opaque) -> Disr, - _sz: uint, _align: uint) -> bool { true } - - fn visit_enter_fn(&mut self, _purity: uint, _proto: uint, - _n_inputs: uint, _retstyle: uint) -> bool { true } - fn visit_fn_input(&mut self, _i: uint, _mode: uint, _inner: *const TyDesc) -> bool { true } - fn visit_fn_output(&mut self, _retstyle: uint, _variadic: bool, _inner: *const TyDesc) - -> bool { 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 { true } - fn visit_param(&mut self, _i: uint) -> bool { true } - fn visit_self(&mut self) -> bool { true } -} - -fn visit_ty<T>(v: &mut MyVisitor) { - unsafe { visit_tydesc(get_tydesc::<T>(), v as &mut TyVisitor) } -} - -pub fn main() { - let mut v = MyVisitor {types: Vec::new()}; - - visit_ty::<bool>(&mut v); - visit_ty::<int>(&mut v); - visit_ty::<i8>(&mut v); - visit_ty::<i16>(&mut v); - - for s in v.types.iter() { - println!("type: {}", (*s).clone()); - } - - let vec_types: Vec<String> = v.types.clone().into_iter().collect(); - assert_eq!(vec_types, vec!("bool".to_string(), "int".to_string(), - "i8".to_string(), "i16".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<int> ) { let a: int = 5; let mut b: Vec<int> = Vec::new(); @@ -18,7 +16,7 @@ fn foo(c: Vec<int> ) { match none::<int> { some::<int>(_) => { 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<T> { a(T, int), b, } fn uhoh<T>(v: Vec<clam<T>> ) { match *v.get(1) { a::<T>(ref _t, ref u) => { println!("incorrect"); - println!("{:?}", u); + println!("{}", u); fail!(); } b::<T> => { 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<u8>, 2, None, "None", - Some(129u8), "Some(129u8)"); + Some(129u8), "Some(129)"); check!(Option<i16>, 4, None, "None", - Some(-20000i16), "Some(-20000i16)"); + Some(-20000i16), "Some(-20000)"); check!(Either<u8, i8>, 2, - Left(132u8), "Left(132u8)", - Right(-32i8), "Right(-32i8)"); + Left(132u8), "Left(132)", + Right(-32i8), "Right(-32)"); check!(Either<u8, i16>, 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<int>), 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<int>), 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(); } |
