From 363e67273622285a65caa74bb63ecfa04df59055 Mon Sep 17 00:00:00 2001 From: Seo Sanghyeon Date: Thu, 23 May 2013 23:58:23 +0900 Subject: [PATCH 1/2] Use adjustments table for allocation lint --- src/librustc/middle/lint.rs | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index d156457ca8865..ae60a90c7acd8 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -892,14 +892,9 @@ fn lint_session(cx: @mut Context) -> visit::vt<()> { } fn lint_unnecessary_allocations(cx: @mut Context) -> visit::vt<()> { - // If the expression `e` has an allocated type, but `t` dictates that it's - // something like a slice (doesn't need allocation), emit a warning with the - // specified span. - // - // Currently, this only applies to string and vector literals with sigils in - // front. Those can have the sigil removed to get a borrowed pointer - // automatically. - fn check(cx: @mut Context, e: @ast::expr, t: ty::t) { + // Warn if string and vector literals with sigils are immediately borrowed. + // Those can have the sigil removed. + fn check(cx: @mut Context, e: @ast::expr) { match e.node { ast::expr_vstore(e2, ast::expr_vstore_uniq) | ast::expr_vstore(e2, ast::expr_vstore_box) => { @@ -914,9 +909,9 @@ fn lint_unnecessary_allocations(cx: @mut Context) -> visit::vt<()> { _ => return } - match ty::get(t).sty { - ty::ty_estr(ty::vstore_slice(*)) | - ty::ty_evec(_, ty::vstore_slice(*)) => { + match cx.tcx.adjustments.find_copy(&e.id) { + Some(@ty::AutoDerefRef(ty::AutoDerefRef { + autoref: Some(ty::AutoBorrowVec(*)), _ })) => { cx.span_lint(unnecessary_allocation, e.span, "unnecessary allocation, the sigil can be \ removed"); @@ -927,23 +922,7 @@ fn lint_unnecessary_allocations(cx: @mut Context) -> visit::vt<()> { } let visit_expr: @fn(@ast::expr) = |e| { - match e.node { - ast::expr_call(c, ref args, _) => { - let t = ty::node_id_to_type(cx.tcx, c.id); - let s = ty::ty_fn_sig(t); - for vec::each2(*args, s.inputs) |e, t| { - check(cx, *e, *t); - } - } - ast::expr_method_call(_, _, _, ref args, _) => { - let t = ty::node_id_to_type(cx.tcx, e.callee_id); - let s = ty::ty_fn_sig(t); - for vec::each2(*args, s.inputs) |e, t| { - check(cx, *e, *t); - } - } - _ => {} - } + check(cx, e); }; visit::mk_simple_visitor(@visit::SimpleVisitor { From 8f80323f09ef150efc5cf729100f99981afc96e1 Mon Sep 17 00:00:00 2001 From: Seo Sanghyeon Date: Fri, 24 May 2013 01:09:11 +0900 Subject: [PATCH 2/2] Remove unnecessary allocations flagged by lint --- src/libextra/bitv.rs | 2 +- src/libextra/getopts.rs | 18 +++++------ src/libextra/json.rs | 16 +++++----- src/libextra/md4.rs | 2 +- src/librustc/back/arm.rs | 40 ++++++++++++------------- src/librustc/back/link.rs | 16 +++++----- src/librustc/back/mips.rs | 40 ++++++++++++------------- src/librustc/back/x86.rs | 6 ++-- src/librustc/back/x86_64.rs | 20 ++++++------- src/librustc/metadata/creader.rs | 6 ++-- src/librustc/metadata/decoder.rs | 2 +- src/librustc/metadata/encoder.rs | 2 +- src/librustc/metadata/loader.rs | 4 +-- src/librustc/metadata/tyencode.rs | 4 +-- src/librustc/middle/check_const.rs | 2 +- src/librustc/middle/check_match.rs | 2 +- src/librustc/middle/trans/asm.rs | 2 +- src/librustc/middle/trans/base.rs | 10 +++---- src/librustc/middle/trans/build.rs | 4 +-- src/librustc/middle/trans/common.rs | 4 +-- src/librustc/middle/trans/foreign.rs | 2 +- src/librustc/middle/trans/reflect.rs | 2 +- src/librustc/middle/ty.rs | 4 +-- src/librustc/middle/typeck/check/mod.rs | 4 +-- src/librustc/middle/typeck/mod.rs | 6 ++-- src/librustc/util/ppaux.rs | 8 ++--- src/libstd/io.rs | 6 ++-- src/libstd/to_str.rs | 4 +-- src/libsyntax/diagnostic.rs | 14 ++++----- src/libsyntax/ext/asm.rs | 2 +- src/libsyntax/ext/fmt.rs | 12 ++++---- src/libsyntax/ext/pipes/pipec.rs | 10 +++---- src/libsyntax/parse/attr.rs | 12 ++++---- src/libsyntax/parse/comments.rs | 6 ++-- src/libsyntax/parse/common.rs | 4 +-- src/libsyntax/parse/lexer.rs | 2 +- src/libsyntax/parse/parser.rs | 6 ++-- src/libsyntax/parse/token.rs | 10 +++---- src/libsyntax/print/pp.rs | 4 +-- src/libsyntax/print/pprust.rs | 2 +- 40 files changed, 161 insertions(+), 161 deletions(-) diff --git a/src/libextra/bitv.rs b/src/libextra/bitv.rs index 1262e90518db3..8aac20d7a6356 100644 --- a/src/libextra/bitv.rs +++ b/src/libextra/bitv.rs @@ -462,7 +462,7 @@ pub impl Bitv { */ fn to_str(&self) -> ~str { let mut rs = ~""; - for self.each() |i| { if i { rs += ~"1"; } else { rs += ~"0"; } }; + for self.each() |i| { if i { rs += "1"; } else { rs += "0"; } }; rs } diff --git a/src/libextra/getopts.rs b/src/libextra/getopts.rs index 539d18cb0cd5b..3c223fe05d410 100644 --- a/src/libextra/getopts.rs +++ b/src/libextra/getopts.rs @@ -193,19 +193,19 @@ pub enum Fail_ { pub fn fail_str(f: Fail_) -> ~str { return match f { ArgumentMissing(ref nm) => { - ~"Argument to option '" + *nm + ~"' missing." + ~"Argument to option '" + *nm + "' missing." } UnrecognizedOption(ref nm) => { - ~"Unrecognized option: '" + *nm + ~"'." + ~"Unrecognized option: '" + *nm + "'." } OptionMissing(ref nm) => { - ~"Required option '" + *nm + ~"' missing." + ~"Required option '" + *nm + "' missing." } OptionDuplicated(ref nm) => { - ~"Option '" + *nm + ~"' given more than once." + ~"Option '" + *nm + "' given more than once." } UnexpectedArgument(ref nm) => { - ~"Option " + *nm + ~" does not take an argument." + ~"Option " + *nm + " does not take an argument." } }; } @@ -618,7 +618,7 @@ pub mod groups { row += match hasarg { No => ~"", Yes => hint, - Maybe => ~"[" + hint + ~"]", + Maybe => ~"[" + hint + "]", }; // FIXME: #5516 @@ -650,10 +650,10 @@ pub mod groups { row }); - return str::to_owned(brief) + - ~"\n\nOptions:\n" + + return str::to_owned(brief) + + "\n\nOptions:\n" + str::connect(rows, "\n") + - ~"\n\n"; + "\n\n"; } } // end groups module diff --git a/src/libextra/json.rs b/src/libextra/json.rs index 5ef0500d53ad5..adf2c4f35b51e 100644 --- a/src/libextra/json.rs +++ b/src/libextra/json.rs @@ -47,18 +47,18 @@ fn escape_str(s: &str) -> ~str { let mut escaped = ~"\""; for str::each_char(s) |c| { match c { - '"' => escaped += ~"\\\"", - '\\' => escaped += ~"\\\\", - '\x08' => escaped += ~"\\b", - '\x0c' => escaped += ~"\\f", - '\n' => escaped += ~"\\n", - '\r' => escaped += ~"\\r", - '\t' => escaped += ~"\\t", + '"' => escaped += "\\\"", + '\\' => escaped += "\\\\", + '\x08' => escaped += "\\b", + '\x0c' => escaped += "\\f", + '\n' => escaped += "\\n", + '\r' => escaped += "\\r", + '\t' => escaped += "\\t", _ => escaped += str::from_char(c) } }; - escaped += ~"\""; + escaped += "\""; escaped } diff --git a/src/libextra/md4.rs b/src/libextra/md4.rs index 449774e4cbc16..9873d7fcd8e35 100644 --- a/src/libextra/md4.rs +++ b/src/libextra/md4.rs @@ -115,7 +115,7 @@ pub fn md4_str(msg: &[u8]) -> ~str { let mut i = 0u32; while i < 4u32 { let byte = (u >> (i * 8u32)) as u8; - if byte <= 16u8 { result += ~"0"; } + if byte <= 16u8 { result += "0"; } result += uint::to_str_radix(byte as uint, 16u); i += 1u32; } diff --git a/src/librustc/back/arm.rs b/src/librustc/back/arm.rs index ff3c71da458a2..fc59df8d24894 100644 --- a/src/librustc/back/arm.rs +++ b/src/librustc/back/arm.rs @@ -22,42 +22,42 @@ pub fn get_target_strs(target_os: session::os) -> target_strs::t { data_layout: match target_os { session::os_macos => { ~"e-p:32:32:32" + - ~"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + - ~"-f32:32:32-f64:64:64" + - ~"-v64:64:64-v128:64:128" + - ~"-a0:0:64-n32" + "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + + "-f32:32:32-f64:64:64" + + "-v64:64:64-v128:64:128" + + "-a0:0:64-n32" } session::os_win32 => { ~"e-p:32:32:32" + - ~"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + - ~"-f32:32:32-f64:64:64" + - ~"-v64:64:64-v128:64:128" + - ~"-a0:0:64-n32" + "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + + "-f32:32:32-f64:64:64" + + "-v64:64:64-v128:64:128" + + "-a0:0:64-n32" } session::os_linux => { ~"e-p:32:32:32" + - ~"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + - ~"-f32:32:32-f64:64:64" + - ~"-v64:64:64-v128:64:128" + - ~"-a0:0:64-n32" + "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + + "-f32:32:32-f64:64:64" + + "-v64:64:64-v128:64:128" + + "-a0:0:64-n32" } session::os_android => { ~"e-p:32:32:32" + - ~"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + - ~"-f32:32:32-f64:64:64" + - ~"-v64:64:64-v128:64:128" + - ~"-a0:0:64-n32" + "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + + "-f32:32:32-f64:64:64" + + "-v64:64:64-v128:64:128" + + "-a0:0:64-n32" } session::os_freebsd => { ~"e-p:32:32:32" + - ~"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + - ~"-f32:32:32-f64:64:64" + - ~"-v64:64:64-v128:64:128" + - ~"-a0:0:64-n32" + "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + + "-f32:32:32-f64:64:64" + + "-v64:64:64-v128:64:128" + + "-a0:0:64-n32" } }, diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index e230d839879e6..cfb4b32f08e44 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -54,7 +54,7 @@ pub fn llvm_err(sess: Session, msg: ~str) -> ! { if cstr == ptr::null() { sess.fatal(msg); } else { - sess.fatal(msg + ~": " + str::raw::from_c_str(cstr)); + sess.fatal(msg + ": " + str::raw::from_c_str(cstr)); } } } @@ -653,13 +653,13 @@ pub fn sanitize(s: &str) -> ~str { let mut result = ~""; for str::each_char(s) |c| { match c { - '@' => result += ~"_sbox_", - '~' => result += ~"_ubox_", - '*' => result += ~"_ptr_", - '&' => result += ~"_ref_", - ',' => result += ~"_", + '@' => result += "_sbox_", + '~' => result += "_ubox_", + '*' => result += "_ptr_", + '&' => result += "_ref_", + ',' => result += "_", - '{' | '(' => result += ~"_of_", + '{' | '(' => result += "_of_", 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' @@ -693,7 +693,7 @@ pub fn mangle(sess: Session, ss: path) -> ~str { n += fmt!("%u%s", str::len(sani), sani); } } } - n += ~"E"; // End name-sequence. + n += "E"; // End name-sequence. n } diff --git a/src/librustc/back/mips.rs b/src/librustc/back/mips.rs index b15306a56b0b9..3409db5aabe3f 100644 --- a/src/librustc/back/mips.rs +++ b/src/librustc/back/mips.rs @@ -22,42 +22,42 @@ pub fn get_target_strs(target_os: session::os) -> target_strs::t { data_layout: match target_os { session::os_macos => { ~"e-p:32:32:32" + - ~"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + - ~"-f32:32:32-f64:64:64" + - ~"-v64:64:64-v128:64:128" + - ~"-a0:0:64-n32" + "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + + "-f32:32:32-f64:64:64" + + "-v64:64:64-v128:64:128" + + "-a0:0:64-n32" } session::os_win32 => { ~"e-p:32:32:32" + - ~"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + - ~"-f32:32:32-f64:64:64" + - ~"-v64:64:64-v128:64:128" + - ~"-a0:0:64-n32" + "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + + "-f32:32:32-f64:64:64" + + "-v64:64:64-v128:64:128" + + "-a0:0:64-n32" } session::os_linux => { ~"e-p:32:32:32" + - ~"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + - ~"-f32:32:32-f64:64:64" + - ~"-v64:64:64-v128:64:128" + - ~"-a0:0:64-n32" + "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + + "-f32:32:32-f64:64:64" + + "-v64:64:64-v128:64:128" + + "-a0:0:64-n32" } session::os_android => { ~"e-p:32:32:32" + - ~"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + - ~"-f32:32:32-f64:64:64" + - ~"-v64:64:64-v128:64:128" + - ~"-a0:0:64-n32" + "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + + "-f32:32:32-f64:64:64" + + "-v64:64:64-v128:64:128" + + "-a0:0:64-n32" } session::os_freebsd => { ~"e-p:32:32:32" + - ~"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + - ~"-f32:32:32-f64:64:64" + - ~"-v64:64:64-v128:64:128" + - ~"-a0:0:64-n32" + "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + + "-f32:32:32-f64:64:64" + + "-v64:64:64-v128:64:128" + + "-a0:0:64-n32" } }, diff --git a/src/librustc/back/x86.rs b/src/librustc/back/x86.rs index 759f5f63c9ec2..c5dbbf8f028db 100644 --- a/src/librustc/back/x86.rs +++ b/src/librustc/back/x86.rs @@ -23,9 +23,9 @@ pub fn get_target_strs(target_os: session::os) -> target_strs::t { data_layout: match target_os { session::os_macos => { ~"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16" + - ~"-i32:32:32-i64:32:64" + - ~"-f32:32:32-f64:32:64-v64:64:64" + - ~"-v128:128:128-a0:0:64-f80:128:128" + ~"-n8:16:32" + "-i32:32:32-i64:32:64" + + "-f32:32:32-f64:32:64-v64:64:64" + + "-v128:128:128-a0:0:64-f80:128:128" + "-n8:16:32" } session::os_win32 => { diff --git a/src/librustc/back/x86_64.rs b/src/librustc/back/x86_64.rs index ed6f1d285147e..42420094e1767 100644 --- a/src/librustc/back/x86_64.rs +++ b/src/librustc/back/x86_64.rs @@ -23,32 +23,32 @@ pub fn get_target_strs(target_os: session::os) -> target_strs::t { data_layout: match target_os { session::os_macos => { ~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ - ~"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ - ~"s0:64:64-f80:128:128-n8:16:32:64" + "f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ + "s0:64:64-f80:128:128-n8:16:32:64" } session::os_win32 => { // FIXME: Test this. Copied from linux (#2398) ~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ - ~"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ - ~"s0:64:64-f80:128:128-n8:16:32:64-S128" + "f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ + "s0:64:64-f80:128:128-n8:16:32:64-S128" } session::os_linux => { ~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ - ~"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ - ~"s0:64:64-f80:128:128-n8:16:32:64-S128" + "f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ + "s0:64:64-f80:128:128-n8:16:32:64-S128" } session::os_android => { ~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ - ~"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ - ~"s0:64:64-f80:128:128-n8:16:32:64-S128" + "f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ + "s0:64:64-f80:128:128-n8:16:32:64-S128" } session::os_freebsd => { ~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ - ~"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ - ~"s0:64:64-f80:128:128-n8:16:32:64-S128" + "f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ + "s0:64:64-f80:128:128-n8:16:32:64-S128" } }, diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 55689d8df4e4b..d189ddf9533f6 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -170,8 +170,8 @@ fn visit_item(e: @mut Env, i: @ast::item) { if *nn == ~"" { e.diag.span_fatal( i.span, - ~"empty #[link_name] not allowed; use " + - ~"#[nolink]."); + "empty #[link_name] not allowed; use \ + #[nolink]."); } nn } @@ -183,7 +183,7 @@ fn visit_item(e: @mut Env, i: @ast::item) { } if !link_args.is_empty() && already_added { e.diag.span_fatal(i.span, ~"library '" + *foreign_name + - ~"' already added: can't specify link_args."); + "' already added: can't specify link_args."); } } ast::anonymous => { /* do nothing */ } diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 2cc0382269ebc..bb35af198079d 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -528,7 +528,7 @@ pub fn _each_path(intr: @ident_interner, if path_is_empty { reexport_path = reexport_name; } else { - reexport_path = path + ~"::" + reexport_name; + reexport_path = path + "::" + reexport_name; } // This reexport may be in yet another crate diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 715465a757784..4bbbd4893a30c 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -922,7 +922,7 @@ fn encode_info_for_item(ecx: @EncodeContext, // >:-< let mut impl_path = vec::append(~[], path); - impl_path += ~[ast_map::path_name(item.ident)]; + impl_path += [ast_map::path_name(item.ident)]; for methods.each |m| { index.push(entry {val: m.id, pos: ebml_w.writer.tell()}); diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs index 232101930ad28..94060ab327181 100644 --- a/src/librustc/metadata/loader.rs +++ b/src/librustc/metadata/loader.rs @@ -81,7 +81,7 @@ fn find_library_crate_aux( filesearch: @filesearch::FileSearch ) -> Option<(~str, @~[u8])> { let crate_name = crate_name_from_metas(cx.metas); - let prefix: ~str = prefix + *crate_name + ~"-"; + let prefix: ~str = prefix + *crate_name + "-"; let suffix: ~str = /*bad*/copy suffix; let mut matches = ~[]; @@ -262,7 +262,7 @@ pub fn list_file_metadata(intr: @ident_interner, option::Some(bytes) => decoder::list_crate_metadata(intr, bytes, out), option::None => { out.write_str(~"could not find metadata in " - + path.to_str() + ~".\n"); + + path.to_str() + ".\n"); } } } diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index bc9edcfeed383..42423b4df29f3 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -89,8 +89,8 @@ pub fn enc_ty(w: @io::Writer, cx: @ctxt, t: ty::t) { let abbrev_len = 3u + estimate_sz(pos) + estimate_sz(len); if abbrev_len < len { // I.e. it's actually an abbreviation. - let s = ~"#" + uint::to_str_radix(pos, 16u) + ~":" + - uint::to_str_radix(len, 16u) + ~"#"; + let s = ~"#" + uint::to_str_radix(pos, 16u) + ":" + + uint::to_str_radix(len, 16u) + "#"; let a = ty_abbrev { pos: pos, len: len, s: @s }; abbrevs.insert(t, a); } diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index 345b128239fc2..01398db432416 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -110,7 +110,7 @@ pub fn check_expr(sess: Session, if !ty::type_is_numeric(ety) && !ty::type_is_unsafe_ptr(ety) { sess.span_err(e.span, ~"can not cast to `" + ppaux::ty_to_str(tcx, ety) + - ~"` in a constant expression"); + "` in a constant expression"); } } expr_path(pth) => { diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 9d164f5eb401a..803fdc4ed5d70 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -171,7 +171,7 @@ pub fn check_exhaustive(cx: @MatchCheckCtxt, sp: span, pats: ~[@pat]) { } }; let msg = ~"non-exhaustive patterns" + match ext { - Some(ref s) => ~": " + **s + ~" not covered", + Some(ref s) => ~": " + **s + " not covered", None => ~"" }; cx.tcx.sess.span_err(sp, msg); diff --git a/src/librustc/middle/trans/asm.rs b/src/librustc/middle/trans/asm.rs index e2baabc5baa49..fad5dc73c1a12 100644 --- a/src/librustc/middle/trans/asm.rs +++ b/src/librustc/middle/trans/asm.rs @@ -90,7 +90,7 @@ pub fn trans_inline_asm(bcx: block, ia: &ast::inline_asm) -> block { let mut clobbers = getClobbers(); if *ia.clobbers != ~"" && clobbers != ~"" { - clobbers = *ia.clobbers + ~"," + clobbers; + clobbers = *ia.clobbers + "," + clobbers; } else { clobbers += *ia.clobbers; }; diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index f14ea279c2d59..7826781aa6b96 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -1984,7 +1984,7 @@ pub fn trans_enum_variant(ccx: @CrateContext, debug!("trans_enum_variant: name=%s tps=%s repr=%? enum_ty=%s", unsafe { str::raw::from_c_str(llvm::LLVMGetValueName(llfndecl)) }, - ~"[" + str::connect(ty_param_substs.map(|&t| ty_to_str(ccx.tcx, t)), ", ") + ~"]", + ~"[" + str::connect(ty_param_substs.map(|&t| ty_to_str(ccx.tcx, t)), ", ") + "]", repr, ty_to_str(ccx.tcx, enum_ty)); adt::trans_start_init(bcx, repr, fcx.llretptr.get(), disr); @@ -2901,7 +2901,7 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta, let cstore = sess.cstore; while cstore::have_crate_data(cstore, n_subcrates) { n_subcrates += 1; } let mapname = if *sess.building_library { - mapmeta.name.to_owned() + ~"_" + mapmeta.vers.to_owned() + ~"_" + mapmeta.name.to_owned() + "_" + mapmeta.vers.to_owned() + "_" + mapmeta.extras_hash.to_owned() } else { ~"toplevel" @@ -2925,8 +2925,8 @@ pub fn fill_crate_map(ccx: @CrateContext, map: ValueRef) { while cstore::have_crate_data(cstore, i) { let cdata = cstore::get_crate_data(cstore, i); let nm = ~"_rust_crate_map_" + *cdata.name + - ~"_" + *cstore::get_crate_vers(cstore, i) + - ~"_" + *cstore::get_crate_hash(cstore, i); + "_" + *cstore::get_crate_vers(cstore, i) + + "_" + *cstore::get_crate_hash(cstore, i); let cr = str::as_c_str(nm, |buf| { unsafe { llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type, buf) @@ -3035,7 +3035,7 @@ pub fn trans_crate(sess: session::Session, // crashes if the module identifer is same as other symbols // such as a function name in the module. // 1. http://llvm.org/bugs/show_bug.cgi?id=11479 - let llmod_id = link_meta.name.to_owned() + ~".rc"; + let llmod_id = link_meta.name.to_owned() + ".rc"; unsafe { let llmod = str::as_c_str(llmod_id, |buf| { diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs index 0411aad32c33b..7079c11e7d0d2 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc/middle/trans/build.rs @@ -65,12 +65,12 @@ pub fn count_insn(cx: block, category: &str) { i = 0u; while i < len { i = *mm.get(&v[i]); - s += ~"/"; + s += "/"; s += v[i]; i += 1u; } - s += ~"/"; + s += "/"; s += category; let n = match h.find(&s) { diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index d56690f4b6a48..be074cfc57a30 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -356,7 +356,7 @@ pub type fn_ctxt = @mut fn_ctxt_; pub fn warn_not_to_commit(ccx: @CrateContext, msg: &str) { if !*ccx.do_not_commit_warning_issued { *ccx.do_not_commit_warning_issued = true; - ccx.sess.warn(msg.to_str() + ~" -- do not commit like this!"); + ccx.sess.warn(msg.to_str() + " -- do not commit like this!"); } } @@ -1420,7 +1420,7 @@ pub fn path_str(sess: session::Session, p: &[path_elt]) -> ~str { match *e { ast_map::path_name(s) | ast_map::path_mod(s) => { if first { first = false; } - else { r += ~"::"; } + else { r += "::"; } r += *sess.str_of(s); } } diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index 58c77f037ded3..79b88a9ba812d 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -402,7 +402,7 @@ pub fn trans_foreign_mod(ccx: @CrateContext, let lname = link_name(ccx, foreign_item); let llbasefn = base_fn(ccx, *lname, tys, cc); // Name the shim function - let shim_name = *lname + ~"__c_stack_shim"; + let shim_name = *lname + "__c_stack_shim"; build_shim_fn_(ccx, shim_name, llbasefn, diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index 4d9d9f53e4c16..b8d38cf7701bc 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -279,7 +279,7 @@ pub impl Reflector { let opaqueptrty = ty::mk_ptr(ccx.tcx, ty::mt { ty: opaquety, mutbl: ast::m_imm }); let make_get_disr = || { - let sub_path = bcx.fcx.path + ~[path_name(special_idents::anon)]; + let sub_path = bcx.fcx.path + [path_name(special_idents::anon)]; let sym = mangle_internal_name_by_path_and_seq(ccx, sub_path, "get_disr"); diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 621ce48a4fd08..6d1ae8ff0e6a8 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -3354,8 +3354,8 @@ pub fn occurs_check(tcx: ctxt, sp: span, vid: TyVid, rt: t) { (sp, ~"type inference failed because I \ could not find a type\n that's both of the form " + ::util::ppaux::ty_to_str(tcx, mk_var(tcx, vid)) + - ~" and of the form " + ::util::ppaux::ty_to_str(tcx, rt) + - ~" - such a type would have to be infinitely large."); + " and of the form " + ::util::ppaux::ty_to_str(tcx, rt) + + " - such a type would have to be infinitely large."); } } diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 6ae03ee45062d..ec76e74ae8f66 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -1870,7 +1870,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, let (_, seen) = *class_field_map.get(&name); if !seen { missing_fields.push( - ~"`" + *tcx.sess.str_of(name) + ~"`"); + ~"`" + *tcx.sess.str_of(name) + "`"); } } @@ -3669,7 +3669,7 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) { ref other => { tcx.sess.span_err(it.span, ~"unrecognized intrinsic function: `" + - (*other) + ~"`"); + (*other) + "`"); return; } }; diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index f4900f5bfeb63..b75654e7251b7 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -256,7 +256,7 @@ pub fn require_same_types( match infer::mk_eqty(l_infcx, t1_is_expected, span, t1, t2) { result::Ok(()) => true, result::Err(ref terr) => { - l_tcx.sess.span_err(span, msg() + ~": " + + l_tcx.sess.span_err(span, msg() + ": " + ty::type_err_to_str(l_tcx, terr)); ty::note_and_explain_type_err(l_tcx, terr); false @@ -323,7 +323,7 @@ fn check_main_fn_ty(ccx: @mut CrateCtxt, _ => { tcx.sess.span_bug(main_span, ~"main has a non-function type: found `" + - ppaux::ty_to_str(tcx, main_t) + ~"`"); + ppaux::ty_to_str(tcx, main_t) + "`"); } } } @@ -372,7 +372,7 @@ fn check_start_fn_ty(ccx: @mut CrateCtxt, _ => { tcx.sess.span_bug(start_span, ~"start has a non-function type: found `" + - ppaux::ty_to_str(tcx, start_t) + ~"`"); + ppaux::ty_to_str(tcx, start_t) + "`"); } } } diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 384298da92e27..9d74f6c7b0ed7 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -382,10 +382,10 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str { m.fty.purity, m.fty.abis, Some(m.ident), - &m.fty.sig) + ~";" + &m.fty.sig) + ";" } fn field_to_str(cx: ctxt, f: field) -> ~str { - return *cx.sess.str_of(f.ident) + ~": " + mt_to_str(cx, &f.mt); + return *cx.sess.str_of(f.ident) + ": " + mt_to_str(cx, &f.mt); } // if there is an id, print that instead of the structural type: @@ -413,11 +413,11 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str { ty_rptr(r, ref tm) => { region_to_str_space(cx, "&", r) + mt_to_str(cx, tm) } - ty_unboxed_vec(ref tm) => { ~"unboxed_vec<" + mt_to_str(cx, tm) + ~">" } + ty_unboxed_vec(ref tm) => { ~"unboxed_vec<" + mt_to_str(cx, tm) + ">" } ty_type => ~"type", ty_tup(ref elems) => { let strs = elems.map(|elem| ty_to_str(cx, *elem)); - ~"(" + str::connect(strs, ",") + ~")" + ~"(" + str::connect(strs, ",") + ")" } ty_closure(ref f) => { closure_to_str(cx, f) diff --git a/src/libstd/io.rs b/src/libstd/io.rs index 4ce4ea108e58c..5cbadaf2df683 100644 --- a/src/libstd/io.rs +++ b/src/libstd/io.rs @@ -1711,9 +1711,9 @@ pub fn read_whole_file_str(file: &Path) -> Result<~str, ~str> { result::chain(read_whole_file(file), |bytes| { if str::is_utf8(bytes) { result::Ok(str::from_bytes(bytes)) - } else { - result::Err(file.to_str() + ~" is not UTF-8") - } + } else { + result::Err(file.to_str() + " is not UTF-8") + } }) } diff --git a/src/libstd/to_str.rs b/src/libstd/to_str.rs index 1469471b7cef3..9ca54066289a3 100644 --- a/src/libstd/to_str.rs +++ b/src/libstd/to_str.rs @@ -46,7 +46,7 @@ impl ToStr for (A,) { fn to_str(&self) -> ~str { match *self { (ref a,) => { - ~"(" + a.to_str() + ~", " + ~")" + ~"(" + a.to_str() + ",)" } } } @@ -97,7 +97,7 @@ impl ToStr for (A, B) { //let &(ref a, ref b) = self; match *self { (ref a, ref b) => { - ~"(" + a.to_str() + ~", " + b.to_str() + ~")" + ~"(" + a.to_str() + ", " + b.to_str() + ")" } } } diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 792b561f110c1..0057579c9b7ee 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -241,7 +241,7 @@ fn highlight_lines(cm: @codemap::CodeMap, // Print the offending lines for display_lines.each |line| { io::stderr().write_str(fmt!("%s:%u ", fm.name, *line + 1u)); - let s = fm.get_line(*line as int) + ~"\n"; + let s = fm.get_line(*line as int) + "\n"; io::stderr().write_str(s); } if elided { @@ -249,8 +249,8 @@ fn highlight_lines(cm: @codemap::CodeMap, let s = fmt!("%s:%u ", fm.name, last_line + 1u); let mut indent = str::len(s); let mut out = ~""; - while indent > 0u { out += ~" "; indent -= 1u; } - out += ~"...\n"; + while indent > 0u { out += " "; indent -= 1u; } + out += "...\n"; io::stderr().write_str(out); } @@ -271,7 +271,7 @@ fn highlight_lines(cm: @codemap::CodeMap, // part of the 'filename:line ' part of the previous line. let skip = str::len(fm.name) + digits + 3u; for skip.times() { - s += ~" "; + s += " "; } let orig = fm.get_line(lines.lines[0] as int); for uint::range(0u,left-skip) |pos| { @@ -281,14 +281,14 @@ fn highlight_lines(cm: @codemap::CodeMap, _ => " " // -squigly-line as well (instead of a }; // space). This way the squigly-line will } // usually appear in the correct position. - s += ~"^"; + s += "^"; let hi = cm.lookup_char_pos(sp.hi); if hi.col != lo.col { // the ^ already takes up one space let num_squiglies = hi.col.to_uint()-lo.col.to_uint()-1u; - for num_squiglies.times() { s += ~"~"; } + for num_squiglies.times() { s += "~"; } } - io::stderr().write_str(s + ~"\n"); + io::stderr().write_str(s + "\n"); } } diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index 204eb9a9f8b77..05ac87adcc53b 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -114,7 +114,7 @@ pub fn expand_asm(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) p.eat(&token::COMMA); } - let clob = ~"~{" + *p.parse_str() + ~"}"; + let clob = ~"~{" + *p.parse_str() + "}"; clobs.push(clob); } diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 987f7fc319abb..2efed5780b47c 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -158,15 +158,15 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span, FlagSignAlways => { if !is_signed_type(cnv) { cx.span_fatal(sp, - ~"+ flag only valid in " + - ~"signed fmt! conversion"); + "+ flag only valid in \ + signed fmt! conversion"); } } FlagSpaceForSign => { if !is_signed_type(cnv) { cx.span_fatal(sp, - ~"space flag only valid in " + - ~"signed fmt! conversions"); + "space flag only valid in \ + signed fmt! conversions"); } } FlagLeftZeroPad => (), @@ -284,8 +284,8 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span, n += 1u; if n >= nargs { cx.span_fatal(sp, - ~"not enough arguments to fmt! " + - ~"for the given format string"); + "not enough arguments to fmt! \ + for the given format string"); } log_conv(conv); diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 1a7b7e55acea9..e55ecbc29bca2 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -66,7 +66,7 @@ impl gen_send for message { let mut body = ~"{\n"; body += fmt!("use super::%s;\n", name); - body += ~"let mut pipe = pipe;\n"; + body += "let mut pipe = pipe;\n"; if this.proto.is_bounded() { let (sp, rp) = match (this.dir, next.dir) { @@ -76,7 +76,7 @@ impl gen_send for message { (recv, recv) => (~"c", ~"s") }; - body += ~"let mut b = pipe.reuse_buffer();\n"; + body += "let mut b = pipe.reuse_buffer();\n"; body += fmt!("let %s = ::std::pipes::SendPacketBuffered(\ &mut (b.buffer.data.%s));\n", sp, next.name); @@ -103,7 +103,7 @@ impl gen_send for message { if !try { body += fmt!("::std::pipes::send(pipe, message);\n"); // return the new channel - body += ~"c }"; + body += "c }"; } else { body += fmt!("if ::std::pipes::send(pipe, message) {\n \ @@ -152,7 +152,7 @@ impl gen_send for message { } else { ~"(" + str::connect(arg_names.map(|x| copy *x), - ", ") + ~")" + ", ") + ")" }; let mut body = ~"{ "; @@ -161,7 +161,7 @@ impl gen_send for message { if !try { body += fmt!("::std::pipes::send(pipe, message);\n"); - body += ~" }"; + body += " }"; } else { body += fmt!("if ::std::pipes::send(pipe, message) \ { \ diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index d947fa43ca7e8..ed9a83d6b1ebc 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -42,7 +42,7 @@ impl parser_attr for Parser { if self.look_ahead(1u) != token::LBRACKET { break; } - attrs += ~[self.parse_attribute(ast::attr_outer)]; + attrs += [self.parse_attribute(ast::attr_outer)]; } token::DOC_COMMENT(s) => { let attr = ::attr::mk_sugared_doc_attr( @@ -53,7 +53,7 @@ impl parser_attr for Parser { if attr.node.style != ast::attr_outer { self.fatal("expected outer comment"); } - attrs += ~[attr]; + attrs += [attr]; self.bump(); } _ => break @@ -105,7 +105,7 @@ impl parser_attr for Parser { let attr = self.parse_attribute(ast::attr_inner); if *self.token == token::SEMI { self.bump(); - inner_attrs += ~[attr]; + inner_attrs += [attr]; } else { // It's not really an inner attribute let outer_attr = @@ -113,7 +113,7 @@ impl parser_attr for Parser { ast::attribute_ { style: ast::attr_outer, value: attr.node.value, is_sugared_doc: false }); - next_outer_attrs += ~[outer_attr]; + next_outer_attrs += [outer_attr]; break; } } @@ -125,9 +125,9 @@ impl parser_attr for Parser { ); self.bump(); if attr.node.style == ast::attr_inner { - inner_attrs += ~[attr]; + inner_attrs += [attr]; } else { - next_outer_attrs += ~[attr]; + next_outer_attrs += [attr]; break; } } diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index 66d2d46cc584d..3fa0fa3b0f06c 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -235,7 +235,7 @@ fn read_block_comment(rdr: @mut StringReader, bump(rdr); } if !is_eof(rdr) { - curr_line += ~"*/"; + curr_line += "*/"; bump(rdr); bump(rdr); } @@ -259,13 +259,13 @@ fn read_block_comment(rdr: @mut StringReader, if rdr.curr == '/' && nextch(rdr) == '*' { bump(rdr); bump(rdr); - curr_line += ~"*"; + curr_line += "*"; level += 1; } else { if rdr.curr == '*' && nextch(rdr) == '/' { bump(rdr); bump(rdr); - curr_line += ~"/"; + curr_line += "/"; level -= 1; } else { bump(rdr); } } diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index 6a868fbf173dd..bdbe91e4112b7 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -194,9 +194,9 @@ pub impl Parser { } else { let mut s: ~str = ~"expected `"; s += self.token_to_str(&token::GT); - s += ~"`, found `"; + s += "`, found `"; s += self.this_token_to_str(); - s += ~"`"; + s += "`"; self.fatal(s); } } diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index d49a3d7fe42b7..eabe664d8ef62 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -320,7 +320,7 @@ fn consume_block_comment(rdr: @mut StringReader) if is_eof(rdr) { rdr.fatal(~"unterminated block doc-comment"); } else { - acc += ~"*/"; + acc += "*/"; bump(rdr); bump(rdr); // but comments with only "*"s between two "/"s are not diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index e8b200439d6da..1af0cfab273e3 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3584,7 +3584,7 @@ pub impl Parser { let prefix = prefix.dir_path(); let mod_path_stack = &*self.mod_path_stack; let mod_path = Path(".").push_many(*mod_path_stack); - let default_path = *self.sess.interner.get(id) + ~".rs"; + let default_path = *self.sess.interner.get(id) + ".rs"; let file_path = match ::attr::first_attr_value_str_by_name( outer_attrs, "path") { Some(d) => { @@ -4213,8 +4213,8 @@ pub impl Parser { // FAILURE TO PARSE ITEM if visibility != inherited { let mut s = ~"unmatched visibility `"; - s += if visibility == public { ~"pub" } else { ~"priv" }; - s += ~"`"; + s += if visibility == public { "pub" } else { "priv" }; + s += "`"; self.span_fatal(*self.last_span, s); } return iovi_none; diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 56b1ed5d5c7f8..c43924486e711 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -138,7 +138,7 @@ pub fn to_str(in: @ident_interner, t: &Token) -> ~str { OROR => ~"||", ANDAND => ~"&&", BINOP(op) => binop_to_str(op), - BINOPEQ(op) => binop_to_str(op) + ~"=", + BINOPEQ(op) => binop_to_str(op) + "=", /* Structural symbols */ AT => ~"@", @@ -163,7 +163,7 @@ pub fn to_str(in: @ident_interner, t: &Token) -> ~str { /* Literals */ LIT_INT(c, ast::ty_char) => { - ~"'" + char::escape_default(c as char) + ~"'" + ~"'" + char::escape_default(c as char) + "'" } LIT_INT(i, t) => { i.to_str() + ast_util::int_ty_to_str(t) @@ -175,18 +175,18 @@ pub fn to_str(in: @ident_interner, t: &Token) -> ~str { LIT_FLOAT(s, t) => { let mut body = copy *in.get(s); if body.ends_with(".") { - body = body + ~"0"; // `10.f` is not a float literal + body += "0"; // `10.f` is not a float literal } body + ast_util::float_ty_to_str(t) } LIT_FLOAT_UNSUFFIXED(s) => { let mut body = copy *in.get(s); if body.ends_with(".") { - body = body + ~"0"; // `10.f` is not a float literal + body += "0"; // `10.f` is not a float literal } body } - LIT_STR(s) => { ~"\"" + str::escape_default(*in.get(s)) + ~"\"" } + LIT_STR(s) => { ~"\"" + str::escape_default(*in.get(s)) + "\"" } /* Name components */ IDENT(s, _) => copy *in.get(s), diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 4e2fd5592dfa0..d3b5c751e695d 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -120,12 +120,12 @@ pub fn buf_str(toks: ~[token], szs: ~[int], left: uint, right: uint, let mut s = ~"["; while i != right && L != 0u { L -= 1u; - if i != left { s += ~", "; } + if i != left { s += ", "; } s += fmt!("%d=%s", szs[i], tok_str(toks[i])); i += 1u; i %= n; } - s += ~"]"; + s += "]"; return s; } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 9110becefbce9..3ecd0e6ab80a3 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1996,7 +1996,7 @@ pub fn print_literal(s: @ps, lit: @ast::lit) { match lit.node { ast::lit_str(st) => print_string(s, *st), ast::lit_int(ch, ast::ty_char) => { - word(s.s, ~"'" + char::escape_default(ch as char) + ~"'"); + word(s.s, ~"'" + char::escape_default(ch as char) + "'"); } ast::lit_int(i, t) => { if i < 0_i64 {