Remove libdebug and update tests.

This commit is contained in:
Luqman Aden 2014-10-14 21:07:11 -04:00
parent b6e0d3a5bf
commit 38aca17c47
134 changed files with 236 additions and 1716 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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())
}
}
}
}

View File

@ -1,33 +0,0 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! 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;

View File

@ -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
}
}

View File

@ -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)");
}

View File

@ -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;

View File

@ -67,7 +67,6 @@
extern crate alloc;
extern crate libc;
#[cfg(test)] extern crate debug;
use std::os;
use std::rt;

View File

@ -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::*;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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());

View File

@ -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)
}

View File

@ -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() })());
}

View File

@ -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);

View File

@ -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());
}

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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);
}
}
}

View File

@ -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;

View File

@ -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());
}

View File

@ -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!();

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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`.
}

View File

@ -10,4 +10,4 @@
// error-pattern: unresolved name `foobar`.
fn main() { println!("{:?}", foobar); }
fn main() { println!("{}", foobar); }

View File

@ -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);
}
}

View File

@ -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) {

View File

@ -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);
}

View File

@ -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

View File

@ -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
}

View File

@ -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

View File

@ -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 {

View File

@ -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`
}

View File

@ -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();
}

View File

@ -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!(); }

View File

@ -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;
}

View File

@ -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) {}

View File

@ -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"),
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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!(); }
}

View File

@ -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`

View File

@ -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);
}

View File

@ -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.
}

View File

@ -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());
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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!() } });
}

View File

@ -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!();
}

View File

@ -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);

View File

@ -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]);

View File

@ -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, "&[]");
}

View File

@ -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();

View File

@ -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);
}

View File

@ -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());
}

View File

@ -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");

View File

@ -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());
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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); }

View File

@ -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);
}

View File

@ -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);
}

View File

@ -9,7 +9,6 @@
// except according to those terms.
extern crate getopts;
extern crate debug;
use getopts::{optopt, getopts};

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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");

View File

@ -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 {

View File

@ -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)));
}

View File

@ -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);
}

View File

@ -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());
}

View File

@ -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);
}

View File

@ -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() {}

View File

@ -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()
}

View File

@ -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!()
}
}

View File

@ -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"));
}

View File

@ -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);
}
}

View File

@ -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
});
}

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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)
}

View File

@ -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)
}
}
}

View File

@ -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);
}

View File

@ -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());
}

View File

@ -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;

Some files were not shown because too many files have changed in this diff Show More