diff options
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/abi.rs | 14 | ||||
| -rw-r--r-- | src/libsyntax/ast.rs | 67 | ||||
| -rw-r--r-- | src/libsyntax/ast_map/mod.rs | 17 | ||||
| -rw-r--r-- | src/libsyntax/attr.rs | 7 | ||||
| -rw-r--r-- | src/libsyntax/codemap.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/diagnostic.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/show.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/format.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/mtwt.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/source_util.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/transcribe.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/attr.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 28 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 14 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/parse/token.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/test.rs | 2 |
18 files changed, 139 insertions, 64 deletions
diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index c366ced58b2..09235ee209c 100644 --- a/src/libsyntax/abi.rs +++ b/src/libsyntax/abi.rs @@ -47,7 +47,7 @@ pub enum Abi { } #[allow(non_camel_case_types)] -#[derive(Copy, PartialEq)] +#[derive(Copy, PartialEq, Show)] pub enum Architecture { X86, X86_64, @@ -121,12 +121,24 @@ impl Abi { impl fmt::Show for Abi { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for Abi { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "\"{}\"", self.name()) } } impl fmt::Show for Os { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for Os { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { OsLinux => "linux".fmt(f), OsWindows => "windows".fmt(f), diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 753e60738f6..10cdea791b8 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -100,13 +100,26 @@ impl Ident { } } -impl Show for Ident { +//NOTE(stage0): remove after snapshot +impl fmt::Show for Ident { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for Ident { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}#{}", self.name, self.ctxt) } } -impl Show for Name { +impl fmt::Show for Name { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for Name { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let Name(nm) = *self; write!(f, "\"{}\"({})", token::get_name(*self).get(), nm) @@ -1094,8 +1107,15 @@ pub enum IntTy { TyI64, } +//NOTE(stage0): remove after snapshot impl fmt::Show for IntTy { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for IntTy { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", ast_util::int_ty_to_string(*self, None)) } } @@ -1129,8 +1149,15 @@ impl UintTy { } } +//NOTE(stage0): remove after snapshot impl fmt::Show for UintTy { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for UintTy { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", ast_util::uint_ty_to_string(*self, None)) } } @@ -1141,8 +1168,15 @@ pub enum FloatTy { TyF64, } +//NOTE(stage0): remove after snapshot impl fmt::Show for FloatTy { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for FloatTy { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", ast_util::float_ty_to_string(*self)) } } @@ -1192,10 +1226,19 @@ pub enum Onceness { impl fmt::Show for Onceness { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - Once => "once".fmt(f), - Many => "many".fmt(f), - } + fmt::String::fmt(match *self { + Once => "once", + Many => "many", + }, f) + } +} + +impl fmt::String for Onceness { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(match *self { + Once => "once", + Many => "many", + }, f) } } @@ -1305,18 +1348,18 @@ pub struct FnDecl { pub variadic: bool } -#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)] +#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum Unsafety { Unsafe, Normal, } -impl fmt::Show for Unsafety { +impl fmt::String for Unsafety { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - Unsafety::Normal => "normal".fmt(f), - Unsafety::Unsafe => "unsafe".fmt(f), - } + fmt::String::fmt(match *self { + Unsafety::Normal => "normal", + Unsafety::Unsafe => "unsafe", + }, f) } } diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs index efd35f73d45..7496a0f9f26 100644 --- a/src/libsyntax/ast_map/mod.rs +++ b/src/libsyntax/ast_map/mod.rs @@ -46,8 +46,15 @@ impl PathElem { } } +//NOTE(stage0): replace with deriving(Show) after snapshot impl fmt::Show for PathElem { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(self, f) + } +} + +impl fmt::String for PathElem { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let slot = token::get_name(self.name()); write!(f, "{}", slot) } @@ -396,7 +403,7 @@ impl<'ast> Map<'ast> { PathName(ident.name) } MethMac(_) => { - panic!("no path elem for {}", node) + panic!("no path elem for {:?}", node) } } } @@ -410,7 +417,7 @@ impl<'ast> Map<'ast> { MethDecl(ident, _, _, _, _, _, _, _) => { PathName(ident.name) } - MethMac(_) => panic!("no path elem for {}", node), + MethMac(_) => panic!("no path elem for {:?}", node), } } TypeTraitItem(ref m) => { @@ -418,7 +425,7 @@ impl<'ast> Map<'ast> { } }, NodeVariant(v) => PathName(v.node.name.name), - _ => panic!("no path elem for {}", node) + _ => panic!("no path elem for {:?}", node) } } @@ -549,7 +556,7 @@ impl<'ast> Map<'ast> { pub fn span(&self, id: NodeId) -> Span { self.opt_span(id) - .unwrap_or_else(|| panic!("AstMap.span: could not find span for id {}", id)) + .unwrap_or_else(|| panic!("AstMap.span: could not find span for id {:?}", id)) } pub fn def_id_span(&self, def_id: DefId, fallback: Span) -> Span { @@ -729,7 +736,7 @@ struct NodeCollector<'ast> { impl<'ast> NodeCollector<'ast> { fn insert_entry(&mut self, id: NodeId, entry: MapEntry<'ast>) { - debug!("ast_map: {} => {}", id, entry); + debug!("ast_map: {:?} => {:?}", id, entry); let len = self.map.len(); if id as uint >= len { self.map.extend(repeat(NotPresent).take(id as uint - len + 1)); diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index c5cffc401a1..416fc8c2278 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -28,6 +28,7 @@ use ptr::P; use std::cell::{RefCell, Cell}; use std::collections::BitvSet; use std::collections::HashSet; +use std::fmt; thread_local! { static USED_ATTRS: RefCell<BitvSet> = RefCell::new(BitvSet::new()) } @@ -357,6 +358,12 @@ pub enum StabilityLevel { Locked } +impl fmt::String for StabilityLevel { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Show::fmt(self, f) + } +} + pub fn find_stability_generic<'a, AM: AttrMetaMethods, I: Iterator<Item=&'a AM>> diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 6d329fe614c..04753bdf652 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -488,7 +488,7 @@ impl CodeMap { let mut total_extra_bytes = 0; for mbc in map.multibyte_chars.borrow().iter() { - debug!("{}-byte char at {}", mbc.bytes, mbc.pos); + debug!("{}-byte char at {:?}", mbc.bytes, mbc.pos); if mbc.pos < bpos { // every character is at least one byte, so we only // count the actual extra bytes. @@ -566,9 +566,9 @@ impl CodeMap { let chpos = self.bytepos_to_file_charpos(pos); let linebpos = (*f.lines.borrow())[a]; let linechpos = self.bytepos_to_file_charpos(linebpos); - debug!("byte pos {} is on the line at byte pos {}", + debug!("byte pos {:?} is on the line at byte pos {:?}", pos, linebpos); - debug!("char pos {} is on the line at char pos {}", + debug!("char pos {:?} is on the line at char pos {:?}", chpos, linechpos); debug!("byte is on line: {}", line); assert!(chpos >= linechpos); diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index f43a236341e..fde2fdb3c55 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -222,7 +222,7 @@ pub fn mk_handler(e: Box<Emitter + Send>) -> Handler { } } -#[derive(Copy, PartialEq, Clone)] +#[derive(Copy, PartialEq, Clone, Show)] pub enum Level { Bug, Fatal, @@ -232,9 +232,9 @@ pub enum Level { Help, } -impl fmt::Show for Level { +impl fmt::String for Level { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use std::fmt::Show; + use std::fmt::String; match *self { Bug => "error: internal compiler error".fmt(f), @@ -374,7 +374,7 @@ impl Emitter for EmitterWriter { match error { Ok(()) => {} - Err(e) => panic!("failed to print diagnostics: {}", e), + Err(e) => panic!("failed to print diagnostics: {:?}", e), } } @@ -382,7 +382,7 @@ impl Emitter for EmitterWriter { sp: RenderSpan, msg: &str, lvl: Level) { match emit(self, cm, sp, msg, None, lvl, true) { Ok(()) => {} - Err(e) => panic!("failed to print diagnostics: {}", e), + Err(e) => panic!("failed to print diagnostics: {:?}", e), } } } diff --git a/src/libsyntax/ext/deriving/show.rs b/src/libsyntax/ext/deriving/show.rs index 70d6da0f88b..fa9a7899a12 100644 --- a/src/libsyntax/ext/deriving/show.rs +++ b/src/libsyntax/ext/deriving/show.rs @@ -90,7 +90,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span, for (i, field) in fields.iter().enumerate() { if i != 0 { format_string.push_str(", "); } - format_string.push_str("{}"); + format_string.push_str("{:?}"); exprs.push(field.self_.clone()); } @@ -107,7 +107,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span, let name = token::get_ident(field.name.unwrap()); format_string.push_str(" "); format_string.push_str(name.get()); - format_string.push_str(": {}"); + format_string.push_str(": {:?}"); exprs.push(field.self_.clone()); } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 75aea623de6..3e1bccf394a 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -36,7 +36,7 @@ pub fn expand_type(t: P<ast::Ty>, fld: &mut MacroExpander, impl_ty: Option<P<ast::Ty>>) -> P<ast::Ty> { - debug!("expanding type {} with impl_ty {}", t, impl_ty); + debug!("expanding type {:?} with impl_ty {:?}", t, impl_ty); let t = match (t.node.clone(), impl_ty) { // Expand uses of `Self` in impls to the concrete type. (ast::Ty_::TyPath(ref path, _), Some(ref impl_ty)) => { diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index 85a3a5ebcae..44a596d2657 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -607,7 +607,7 @@ impl<'a, 'b> Context<'a, 'b> { let trait_ = match *ty { Known(ref tyname) => { match tyname.index(&FullRange) { - "" => "Show", + "" => "String", "?" => "Show", "e" => "LowerExp", "E" => "UpperExp", diff --git a/src/libsyntax/ext/mtwt.rs b/src/libsyntax/ext/mtwt.rs index 49d6b255c81..d7d768a007e 100644 --- a/src/libsyntax/ext/mtwt.rs +++ b/src/libsyntax/ext/mtwt.rs @@ -121,7 +121,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!("{:4} : {}",idx,val); + error!("{:4} : {:?}",idx,val); } } diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 5c966ed9823..1ba91dd371c 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -135,7 +135,7 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) let bytes = match File::open(&file).read_to_end() { Err(e) => { cx.span_err(sp, - format!("couldn't read {}: {}", + format!("couldn't read {:?}: {}", file.display(), e).index(&FullRange)); return DummyResult::expr(sp); @@ -146,7 +146,7 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) Ok(src) => { // Add this input file to the code map to make it available as // dependency information - let filename = file.display().to_string(); + let filename = format!("{:?}", file.display()); let interned = token::intern_and_get_ident(src.index(&FullRange)); cx.codemap().new_filemap(filename, src); @@ -154,7 +154,7 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) } Err(_) => { cx.span_err(sp, - format!("{} wasn't a utf-8 file", + format!("{:?} wasn't a utf-8 file", file.display()).index(&FullRange)); return DummyResult::expr(sp); } @@ -177,7 +177,7 @@ pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) match File::open(&file).read_to_end() { Err(e) => { cx.span_err(sp, - format!("couldn't read {}: {}", file.display(), e).index(&FullRange)); + format!("couldn't read {:?}: {}", file.display(), e).index(&FullRange)); return DummyResult::expr(sp); } Ok(bytes) => { diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 7ca920a6196..b3bb5cdd897 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -128,7 +128,7 @@ impl Add for LockstepIterSize { let l_n = token::get_ident(l_id.clone()); let r_n = token::get_ident(r_id); LisContradiction(format!("inconsistent lockstep iteration: \ - '{}' has {} items, but '{}' has {}", + '{:?}' has {} items, but '{:?}' has {}", l_n, l_len, r_n, r_len).to_string()) } }, @@ -296,7 +296,7 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan { MatchedSeq(..) => { r.sp_diag.span_fatal( r.cur_span, /* blame the macro writer */ - format!("variable '{}' is still repeating at this depth", + format!("variable '{:?}' is still repeating at this depth", token::get_ident(ident)).index(&FullRange)); } } diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index f4810cee5f8..4aad7f911db 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -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 => { diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 850d527fe39..e6331cc085b 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -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 } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index b79f59cc0c1..82e2c8136a4 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -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, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 0ecd098951f..7d7e10e181e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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)); diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index f70ce54bb1c..306ab303411 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -652,6 +652,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)) } } diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 0b2c45ee3a7..711715355e9 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -194,7 +194,7 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> { if !self.cx.path.is_empty() { self.tested_submods.push((self.cx.path[self.cx.path.len()-1], sym)); } else { - debug!("pushing nothing, sym: {}", sym); + debug!("pushing nothing, sym: {:?}", sym); self.cx.toplevel_reexport = Some(sym); } } |
