diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2013-11-28 23:52:11 +1100 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2013-12-04 22:35:53 +1100 |
| commit | 9d64e46013096997627da62ecc65225bc22682e8 (patch) | |
| tree | fa20c8fd1d653acff5f996253d16103dd61addd9 /src/libsyntax | |
| parent | 9635c763ba5edc8c8ea2868b895548b52f640e5a (diff) | |
| download | rust-9d64e46013096997627da62ecc65225bc22682e8.tar.gz rust-9d64e46013096997627da62ecc65225bc22682e8.zip | |
std::str: remove from_utf8.
This function had type &[u8] -> ~str, i.e. it allocates a string internally, even though the non-allocating version that take &[u8] -> &str and ~[u8] -> ~str are all that is necessary in most circumstances.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/parse/comments.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index d8f2d8a5380..0704bf913d7 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -346,7 +346,7 @@ pub fn gather_comments_and_literals(span_diagnostic: path: @str, srdr: &mut io::Reader) -> (~[cmnt], ~[lit]) { - let src = str::from_utf8(srdr.read_to_end()).to_managed(); + let src = str::from_utf8_owned(srdr.read_to_end()).to_managed(); let cm = CodeMap::new(); let filemap = cm.new_filemap(path, src); let rdr = lexer::new_low_level_string_reader(span_diagnostic, filemap); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 9eb61728e59..3c6fa86485d 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -210,7 +210,7 @@ pub fn fun_to_str(decl: &ast::fn_decl, purity: ast::purity, name: ast::Ident, end(s); // Close the head box end(s); // Close the outer box eof(s.s); - str::from_utf8(*wr.inner_ref()) + str::from_utf8_owned(wr.inner_ref().to_owned()) } pub fn block_to_str(blk: &ast::Block, intr: @ident_interner) -> ~str { @@ -222,7 +222,7 @@ pub fn block_to_str(blk: &ast::Block, intr: @ident_interner) -> ~str { ibox(s, 0u); print_block(s, blk); eof(s.s); - str::from_utf8(*wr.inner_ref()) + str::from_utf8_owned(wr.inner_ref().to_owned()) } pub fn meta_item_to_str(mi: &ast::MetaItem, intr: @ident_interner) -> ~str { @@ -2292,7 +2292,7 @@ pub fn to_str<T>(t: &T, f: |@ps, &T|, intr: @ident_interner) -> ~str { let s = rust_printer(wr as @mut io::Writer, intr); f(s, t); eof(s.s); - str::from_utf8(*wr.inner_ref()) + str::from_utf8_owned(wr.inner_ref().to_owned()) } pub fn next_comment(s: @ps) -> Option<comments::cmnt> { |
