rollup merge of #20481: seanmonstar/fmt-show-string

Conflicts:
	src/compiletest/runtest.rs
	src/libcore/fmt/mod.rs
	src/libfmt_macros/lib.rs
	src/libregex/parse.rs
	src/librustc/middle/cfg/construct.rs
	src/librustc/middle/dataflow.rs
	src/librustc/middle/infer/higher_ranked/mod.rs
	src/librustc/middle/ty.rs
	src/librustc_back/archive.rs
	src/librustc_borrowck/borrowck/fragments.rs
	src/librustc_borrowck/borrowck/gather_loans/mod.rs
	src/librustc_resolve/lib.rs
	src/librustc_trans/back/link.rs
	src/librustc_trans/save/mod.rs
	src/librustc_trans/trans/base.rs
	src/librustc_trans/trans/callee.rs
	src/librustc_trans/trans/common.rs
	src/librustc_trans/trans/consts.rs
	src/librustc_trans/trans/controlflow.rs
	src/librustc_trans/trans/debuginfo.rs
	src/librustc_trans/trans/expr.rs
	src/librustc_trans/trans/monomorphize.rs
	src/librustc_typeck/astconv.rs
	src/librustc_typeck/check/method/mod.rs
	src/librustc_typeck/check/mod.rs
	src/librustc_typeck/check/regionck.rs
	src/librustc_typeck/collect.rs
	src/libsyntax/ext/format.rs
	src/libsyntax/ext/source_util.rs
	src/libsyntax/ext/tt/transcribe.rs
	src/libsyntax/parse/mod.rs
	src/libsyntax/parse/token.rs
	src/test/run-pass/issue-8898.rs
This commit is contained in:
Alex Crichton
2015-01-06 15:22:24 -08:00
252 changed files with 2703 additions and 2072 deletions

View File

@@ -32,7 +32,7 @@ impl<'a> ParserAttr for Parser<'a> {
fn parse_outer_attributes(&mut self) -> Vec<ast::Attribute> {
let mut attrs: Vec<ast::Attribute> = Vec::new();
loop {
debug!("parse_outer_attributes: self.token={}",
debug!("parse_outer_attributes: self.token={:?}",
self.token);
match self.token {
token::Pound => {
@@ -62,7 +62,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 => {

View File

@@ -111,7 +111,7 @@ impl<'a> Reader for TtReader<'a> {
}
fn next_token(&mut self) -> TokenAndSpan {
let r = tt_next_token(self);
debug!("TtReader: r={}", r);
debug!("TtReader: r={:?}", r);
r
}
fn fatal(&self, m: &str) -> ! {
@@ -256,13 +256,13 @@ impl<'a> StringReader<'a> {
/// adjusted 1 towards each other (assumes that on either side there is a
/// single-byte delimiter).
pub fn name_from(&self, start: BytePos) -> ast::Name {
debug!("taking an ident from {} to {}", start, self.last_pos);
debug!("taking an ident from {:?} to {:?}", start, self.last_pos);
self.with_str_from(start, token::intern)
}
/// As name_from, with an explicit endpoint.
pub fn name_from_to(&self, start: BytePos, end: BytePos) -> ast::Name {
debug!("taking an ident from {} to {}", start, end);
debug!("taking an ident from {:?} to {:?}", start, end);
self.with_str_from_to(start, end, token::intern)
}
@@ -496,7 +496,7 @@ impl<'a> StringReader<'a> {
// for skipping over all "junk"
'/' | '#' => {
let c = self.scan_comment();
debug!("scanning a comment {}", c);
debug!("scanning a comment {:?}", c);
c
},
c if is_whitespace(Some(c)) => {
@@ -506,7 +506,7 @@ impl<'a> StringReader<'a> {
tok: token::Whitespace,
sp: codemap::mk_sp(start_bpos, self.last_pos)
});
debug!("scanning whitespace: {}", c);
debug!("scanning whitespace: {:?}", c);
c
},
_ => None
@@ -592,8 +592,8 @@ impl<'a> StringReader<'a> {
whence: &str) {
match r.curr {
Some(r_c) if r_c == c => r.bump(),
Some(r_c) => panic!("expected {}, hit {}, {}", described_c, r_c, whence),
None => panic!("expected {}, hit EOF, {}", described_c, whence),
Some(r_c) => panic!("expected {:?}, hit {:?}, {}", described_c, r_c, whence),
None => panic!("expected {:?}, hit EOF, {}", described_c, whence),
}
}
@@ -614,7 +614,7 @@ impl<'a> StringReader<'a> {
self.scan_digits(base);
let encoded_name : u32 = self.with_str_from(start_bpos, |s| {
num::from_str_radix(s, 10).unwrap_or_else(|| {
panic!("expected digits representing a name, got `{}`, {}, range [{},{}]",
panic!("expected digits representing a name, got {:?}, {}, range [{:?},{:?}]",
s, whence, start_bpos, self.last_pos);
})
});
@@ -632,7 +632,7 @@ impl<'a> StringReader<'a> {
self.scan_digits(base);
let encoded_ctxt : ast::SyntaxContext = self.with_str_from(start_bpos, |s| {
num::from_str_radix(s, 10).unwrap_or_else(|| {
panic!("expected digits representing a ctxt, got `{}`, {}", s, whence);
panic!("expected digits representing a ctxt, got {:?}, {}", s, whence);
})
});
@@ -652,7 +652,7 @@ impl<'a> StringReader<'a> {
if c == Some('_') { debug!("skipping a _"); self.bump(); continue; }
match c.and_then(|cc| cc.to_digit(radix)) {
Some(_) => {
debug!("{} in scan_digits", c);
debug!("{:?} in scan_digits", c);
len += 1;
self.bump();
}
@@ -728,7 +728,7 @@ impl<'a> StringReader<'a> {
delim: char,
below_0x7f_only: bool)
-> bool {
debug!("scanning {} digits until {}", n_digits, delim);
debug!("scanning {} digits until {:?}", n_digits, delim);
let start_bpos = self.last_pos;
let mut accum_int = 0;
@@ -990,7 +990,7 @@ impl<'a> StringReader<'a> {
if is_dec_digit(c) {
let num = self.scan_number(c.unwrap());
let suffix = self.scan_optional_raw_name();
debug!("next_token_inner: scanned number {}, {}", num, suffix);
debug!("next_token_inner: scanned number {:?}, {:?}", num, suffix);
return token::Literal(num, suffix)
}
@@ -1444,14 +1444,14 @@ fn is_dec_digit(c: Option<char>) -> bool { return in_range(c, '0', '9'); }
pub fn is_doc_comment(s: &str) -> bool {
let res = (s.starts_with("///") && *s.as_bytes().get(3).unwrap_or(&b' ') != b'/')
|| s.starts_with("//!");
debug!("is `{}` a doc comment? {}", s, res);
debug!("is {:?} a doc comment? {}", s, res);
res
}
pub fn is_block_doc_comment(s: &str) -> bool {
let res = (s.starts_with("/**") && *s.as_bytes().get(3).unwrap_or(&b' ') != b'*')
|| s.starts_with("/*!");
debug!("is `{}` a doc comment? {}", s, res);
debug!("is {:?} a doc comment? {}", s, res);
res
}

View File

@@ -254,7 +254,7 @@ pub fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>)
let bytes = match File::open(path).read_to_end() {
Ok(bytes) => bytes,
Err(e) => {
err(format!("couldn't read {}: {}",
err(format!("couldn't read {:?}: {:?}",
path.display(),
e).index(&FullRange));
unreachable!()
@@ -266,7 +266,7 @@ pub fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>)
path.as_str().unwrap().to_string())
}
None => {
err(format!("{} is not UTF-8 encoded", path.display()).index(&FullRange))
err(format!("{:?} is not UTF-8 encoded", path.display()).index(&FullRange))
}
}
unreachable!()
@@ -539,7 +539,7 @@ fn looks_like_width_suffix(first_chars: &[char], s: &str) -> bool {
fn filtered_float_lit(data: token::InternedString, suffix: Option<&str>,
sd: &SpanHandler, sp: Span) -> ast::Lit_ {
debug!("filtered_float_lit: {}, {}", data, suffix);
debug!("filtered_float_lit: {}, {:?}", data, suffix);
match suffix {
Some("f32") => ast::LitFloat(data, ast::TyF32),
Some("f64") => ast::LitFloat(data, ast::TyF64),
@@ -559,7 +559,7 @@ fn filtered_float_lit(data: token::InternedString, suffix: Option<&str>,
}
}
pub fn float_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) -> ast::Lit_ {
debug!("float_lit: {}, {}", s, suffix);
debug!("float_lit: {:?}, {:?}", s, suffix);
// FIXME #2252: bounds checking float literals is defered until trans
let s = s.chars().filter(|&c| c != '_').collect::<String>();
let data = token::intern_and_get_ident(&*s);
@@ -664,7 +664,7 @@ pub fn integer_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) ->
let s2 = s.chars().filter(|&c| c != '_').collect::<String>();
let mut s = s2.index(&FullRange);
debug!("integer_lit: {}, {}", s, suffix);
debug!("integer_lit: {}, {:?}", s, suffix);
let mut base = 10;
let orig = s;
@@ -729,8 +729,8 @@ pub fn integer_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) ->
}
}
debug!("integer_lit: the type is {}, base {}, the new string is {}, the original \
string was {}, the original suffix was {}", ty, base, s, orig, suffix);
debug!("integer_lit: the type is {:?}, base {:?}, the new string is {:?}, the original \
string was {:?}, the original suffix was {:?}", ty, base, s, orig, suffix);
let res: u64 = match ::std::num::from_str_radix(s, base) {
Some(r) => r,

View File

@@ -488,7 +488,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);
if let ExprPath(..) = e.node {
// might be unit-struct construction; check for recoverableinput error.
let mut expected = edible.iter().map(|x| x.clone()).collect::<Vec<_>>();
@@ -5054,7 +5054,7 @@ impl<'a> Parser<'a> {
attrs = tmp;
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 */) {
@@ -5191,7 +5191,7 @@ impl<'a> Parser<'a> {
format!("file not found for module `{}`",
mod_name).index(&FullRange),
format!("name the file either {} or {} inside \
the directory {}",
the directory {:?}",
default_path_str,
secondary_path_str,
dir_path.display()).index(&FullRange));

View File

@@ -651,6 +651,12 @@ impl BytesContainer for InternedString {
}
impl fmt::Show for InternedString {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl fmt::String for InternedString {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.string.index(&FullRange))
}