Skip to content

Commit

Permalink
syntax: Replace String::from_str with the stable String::from
Browse files Browse the repository at this point in the history
  • Loading branch information
erickt committed Apr 21, 2015
1 parent 8553658 commit 2937cce
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/libsyntax/ast_util.rs
Expand Up @@ -238,7 +238,7 @@ pub fn name_to_dummy_lifetime(name: Name) -> Lifetime {
pub fn impl_pretty_name(trait_ref: &Option<TraitRef>, ty: Option<&Ty>) -> Ident {
let mut pretty = match ty {
Some(t) => pprust::ty_to_string(t),
None => String::from_str("..")
None => String::from("..")
};

match *trait_ref {
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/codemap.rs
Expand Up @@ -557,9 +557,9 @@ impl CodeMap {
// FIXME #12884: no efficient/safe way to remove from the start of a string
// and reuse the allocation.
let mut src = if src.starts_with("\u{feff}") {
String::from_str(&src[3..])
String::from(&src[3..])
} else {
String::from_str(&src[..])
String::from(&src[..])
};

// Append '\n' in case it's not already there.
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/diagnostic.rs
Expand Up @@ -644,7 +644,7 @@ fn highlight_lines(err: &mut EmitterWriter,
}

try!(write!(&mut err.dst, "{}", s));
let mut s = String::from_str("^");
let mut s = String::from("^");
let count = match lastc {
// Most terminals have a tab stop every eight columns by default
'\t' => 8 - col%8,
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/parse/lexer/comments.rs
Expand Up @@ -246,7 +246,7 @@ fn read_block_comment(rdr: &mut StringReader,
rdr.bump();
rdr.bump();

let mut curr_line = String::from_str("/*");
let mut curr_line = String::from("/*");

// doc-comments are not really comments, they are attributes
if (rdr.curr_is('*') && !rdr.nextch_is('*')) || rdr.curr_is('!') {
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/parse/parser.rs
Expand Up @@ -4834,7 +4834,7 @@ impl<'a> Parser<'a> {
let mut included_mod_stack = self.sess.included_mod_stack.borrow_mut();
match included_mod_stack.iter().position(|p| *p == path) {
Some(i) => {
let mut err = String::from_str("circular modules: ");
let mut err = String::from("circular modules: ");
let len = included_mod_stack.len();
for p in &included_mod_stack[i.. len] {
err.push_str(&p.to_string_lossy());
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/print/pp.rs
Expand Up @@ -131,7 +131,7 @@ pub fn buf_str(toks: &[Token],
assert_eq!(n, szs.len());
let mut i = left;
let mut l = lim;
let mut s = string::String::from_str("[");
let mut s = string::String::from("[");
while i != right && l != 0 {
l -= 1;
if i != left {
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/print/pprust.rs
Expand Up @@ -2794,13 +2794,13 @@ impl<'a> State<'a> {
match lit.node {
ast::LitStr(ref st, style) => self.print_string(&st, style),
ast::LitByte(byte) => {
let mut res = String::from_str("b'");
let mut res = String::from("b'");
res.extend(ascii::escape_default(byte).map(|c| c as char));
res.push('\'');
word(&mut self.s, &res[..])
}
ast::LitChar(ch) => {
let mut res = String::from_str("'");
let mut res = String::from("'");
res.extend(ch.escape_default());
res.push('\'');
word(&mut self.s, &res[..])
Expand Down

0 comments on commit 2937cce

Please sign in to comment.