Skip to content

Commit 732e057

Browse files
committed
auto merge of #14667 : aochagavia/rust/pr2, r=huonw
2 parents 100ff4c + 501b904 commit 732e057

File tree

31 files changed

+54
-51
lines changed

31 files changed

+54
-51
lines changed

src/compiletest/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub fn load_errors(re: &Regex, testfile: &Path) -> Vec<ExpectedError> {
3131
fn parse_expected(line_num: uint, line: &str, re: &Regex) -> Option<ExpectedError> {
3232
re.captures(line).and_then(|caps| {
3333
let adjusts = caps.name("adjusts").len();
34-
let kind = caps.name("kind").to_ascii().to_lower().into_str().to_string();
34+
let kind = caps.name("kind").to_ascii().to_lower().into_str();
3535
let msg = caps.name("msg").trim().to_string();
3636

3737
debug!("line={} kind={} msg={}", line_num, kind, msg);

src/compiletest/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn make_new_path(path: &str) -> String {
4141
Some(curr) => {
4242
format!("{}{}{}", path, path_div(), curr)
4343
}
44-
None => path.to_str().to_string()
44+
None => path.to_str()
4545
}
4646
}
4747

src/doc/complement-cheatsheet.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Use [`ToStr`](std/to_str/trait.ToStr.html).
88

99
~~~
1010
let x: int = 42;
11-
let y: String = x.to_str().to_string();
11+
let y: String = x.to_str();
1212
~~~
1313

1414
**String to int**

src/doc/guide-tasks.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ fn stringifier(channel: &sync::DuplexStream<String, uint>) {
467467
let mut value: uint;
468468
loop {
469469
value = channel.recv();
470-
channel.send(value.to_str().to_string());
470+
channel.send(value.to_str());
471471
if value == 0 { break; }
472472
}
473473
}
@@ -492,7 +492,7 @@ extern crate sync;
492492
# let mut value: uint;
493493
# loop {
494494
# value = channel.recv();
495-
# channel.send(value.to_str().to_string());
495+
# channel.send(value.to_str());
496496
# if value == 0u { break; }
497497
# }
498498
# }

src/doc/rust.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3579,7 +3579,7 @@ trait Printable {
35793579
}
35803580
35813581
impl Printable for int {
3582-
fn to_string(&self) -> String { self.to_str().to_string() }
3582+
fn to_string(&self) -> String { self.to_str() }
35833583
}
35843584
35853585
fn print(a: Box<Printable>) {

src/libgetopts/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ impl Name {
222222

223223
fn to_str(&self) -> String {
224224
match *self {
225-
Short(ch) => ch.to_str().to_string(),
225+
Short(ch) => ch.to_str(),
226226
Long(ref s) => s.to_string()
227227
}
228228
}

src/libnum/complex.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ mod test {
349349
#[test]
350350
fn test_to_str() {
351351
fn test(c : Complex64, s: String) {
352-
assert_eq!(c.to_str().to_string(), s);
352+
assert_eq!(c.to_str(), s);
353353
}
354354
test(_0_0i, "0+0i".to_string());
355355
test(_1_0i, "1+0i".to_string());

src/libnum/rational.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ mod test {
559559
fn test_to_from_str() {
560560
fn test(r: Rational, s: String) {
561561
assert_eq!(FromStr::from_str(s.as_slice()), Some(r));
562-
assert_eq!(r.to_str().to_string(), s);
562+
assert_eq!(r.to_str(), s);
563563
}
564564
test(_1, "1/1".to_string());
565565
test(_0, "0/1".to_string());

src/libregex_macros/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ fn parse(cx: &mut ExtCtxt, tts: &[ast::TokenTree]) -> Option<String> {
620620
let regex = match entry.node {
621621
ast::ExprLit(lit) => {
622622
match lit.node {
623-
ast::LitStr(ref s, _) => s.to_str().to_string(),
623+
ast::LitStr(ref s, _) => s.to_str(),
624624
_ => {
625625
cx.span_err(entry.span, format!(
626626
"expected string literal but got `{}`",

src/librustc/driver/driver.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -533,15 +533,15 @@ impl pprust::PpAnn for IdentifiedAnnotation {
533533
match node {
534534
pprust::NodeItem(item) => {
535535
try!(pp::space(&mut s.s));
536-
s.synth_comment(item.id.to_str().to_string())
536+
s.synth_comment(item.id.to_str())
537537
}
538538
pprust::NodeBlock(blk) => {
539539
try!(pp::space(&mut s.s));
540540
s.synth_comment((format!("block {}", blk.id)).to_string())
541541
}
542542
pprust::NodeExpr(expr) => {
543543
try!(pp::space(&mut s.s));
544-
try!(s.synth_comment(expr.id.to_str().to_string()));
544+
try!(s.synth_comment(expr.id.to_str()));
545545
s.pclose()
546546
}
547547
pprust::NodePat(pat) => {

src/librustc/middle/liveness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl<'a> IrMaps<'a> {
324324
fn variable_name(&self, var: Variable) -> String {
325325
match self.var_kinds.get(var.get()) {
326326
&Local(LocalInfo { ident: nm, .. }) | &Arg(_, nm) => {
327-
token::get_ident(nm).get().to_str().to_string()
327+
token::get_ident(nm).get().to_str()
328328
},
329329
&ImplicitRet => "<implicit-ret>".to_string()
330330
}

src/librustc/middle/mem_categorization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,7 @@ impl Repr for InteriorKind {
13031303
fn repr(&self, _tcx: &ty::ctxt) -> String {
13041304
match *self {
13051305
InteriorField(NamedField(fld)) => {
1306-
token::get_name(fld).get().to_str().to_string()
1306+
token::get_name(fld).get().to_str()
13071307
}
13081308
InteriorField(PositionalField(i)) => format!("\\#{:?}", i),
13091309
InteriorElement(_) => "[]".to_string(),

src/librustc/middle/trans/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1927,7 +1927,7 @@ fn exported_name(ccx: &CrateContext, id: ast::NodeId,
19271927
_ => ccx.tcx.map.with_path(id, |mut path| {
19281928
if attr::contains_name(attrs, "no_mangle") {
19291929
// Don't mangle
1930-
path.last().unwrap().to_str().to_string()
1930+
path.last().unwrap().to_str()
19311931
} else {
19321932
match weak_lang_items::link_name(attrs) {
19331933
Some(name) => name.get().to_string(),

src/librustc/middle/typeck/infer/to_str.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ impl<V:Vid + ToStr,T:InferStr> InferStr for VarValue<V, T> {
7979

8080
impl InferStr for IntVarValue {
8181
fn inf_str(&self, _cx: &InferCtxt) -> String {
82-
self.to_str().to_string()
82+
self.to_str()
8383
}
8484
}
8585

8686
impl InferStr for ast::FloatTy {
8787
fn inf_str(&self, _cx: &InferCtxt) -> String {
88-
self.to_str().to_string()
88+
self.to_str()
8989
}
9090
}
9191

src/librustc/util/ppaux.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> String {
366366
ty_bare_fn(ref f) => {
367367
bare_fn_to_str(cx, f.fn_style, f.abi, None, &f.sig)
368368
}
369-
ty_infer(infer_ty) => infer_ty.to_str().to_string(),
369+
ty_infer(infer_ty) => infer_ty.to_str(),
370370
ty_err => "[type error]".to_string(),
371371
ty_param(param_ty {idx: id, def_id: did}) => {
372372
let ident = match cx.ty_param_defs.borrow().find(&did.node) {
@@ -753,7 +753,10 @@ impl Repr for ty::ItemVariances {
753753

754754
impl Repr for ty::Variance {
755755
fn repr(&self, _: &ctxt) -> String {
756-
self.to_str().to_string()
756+
// The first `.to_str()` returns a &'static str (it is not an implementation
757+
// of the ToStr trait). Because of that, we need to call `.to_str()` again
758+
// if we want to have a `String`.
759+
self.to_str().to_str()
757760
}
758761
}
759762

@@ -950,13 +953,13 @@ impl UserString for ast::Ident {
950953

951954
impl Repr for abi::Abi {
952955
fn repr(&self, _tcx: &ctxt) -> String {
953-
self.to_str().to_string()
956+
self.to_str()
954957
}
955958
}
956959

957960
impl UserString for abi::Abi {
958961
fn user_string(&self, _tcx: &ctxt) -> String {
959-
self.to_str().to_string()
962+
self.to_str()
960963
}
961964
}
962965

src/librustdoc/clean/inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ fn try_inline_def(cx: &core::DocContext,
9393
cx.inlined.borrow_mut().get_mut_ref().insert(did);
9494
ret.push(clean::Item {
9595
source: clean::Span::empty(),
96-
name: Some(fqn.last().unwrap().to_str().to_string()),
96+
name: Some(fqn.last().unwrap().to_str()),
9797
attrs: load_attrs(tcx, did),
9898
inner: inner,
9999
visibility: Some(ast::Public),

src/librustdoc/clean/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ impl Clean<TyParamBound> for ty::BuiltinBound {
526526
external_path("Share", &empty)),
527527
};
528528
let fqn = csearch::get_item_path(tcx, did);
529-
let fqn = fqn.move_iter().map(|i| i.to_str().to_string()).collect();
529+
let fqn = fqn.move_iter().map(|i| i.to_str()).collect();
530530
cx.external_paths.borrow_mut().get_mut_ref().insert(did,
531531
(fqn, TypeTrait));
532532
TraitBound(ResolvedPath {
@@ -545,7 +545,7 @@ impl Clean<TyParamBound> for ty::TraitRef {
545545
core::NotTyped(_) => return RegionBound,
546546
};
547547
let fqn = csearch::get_item_path(tcx, self.def_id);
548-
let fqn = fqn.move_iter().map(|i| i.to_str().to_string())
548+
let fqn = fqn.move_iter().map(|i| i.to_str())
549549
.collect::<Vec<String>>();
550550
let path = external_path(fqn.last().unwrap().as_slice(),
551551
&self.substs);
@@ -1239,7 +1239,7 @@ impl Clean<Type> for ty::t {
12391239
};
12401240
let fqn = csearch::get_item_path(tcx, did);
12411241
let fqn: Vec<String> = fqn.move_iter().map(|i| {
1242-
i.to_str().to_string()
1242+
i.to_str()
12431243
}).collect();
12441244
let kind = match ty::get(*self).sty {
12451245
ty::ty_struct(..) => TypeStruct,
@@ -1617,7 +1617,7 @@ impl Clean<BareFunctionDecl> for ast::BareFnTy {
16171617
type_params: Vec::new(),
16181618
},
16191619
decl: self.decl.clean(),
1620-
abi: self.abi.to_str().to_string(),
1620+
abi: self.abi.to_str(),
16211621
}
16221622
}
16231623
}
@@ -1891,12 +1891,12 @@ fn lit_to_str(lit: &ast::Lit) -> String {
18911891
ast::LitStr(ref st, _) => st.get().to_string(),
18921892
ast::LitBinary(ref data) => format!("{:?}", data.as_slice()),
18931893
ast::LitChar(c) => format!("'{}'", c),
1894-
ast::LitInt(i, _t) => i.to_str().to_string(),
1895-
ast::LitUint(u, _t) => u.to_str().to_string(),
1896-
ast::LitIntUnsuffixed(i) => i.to_str().to_string(),
1894+
ast::LitInt(i, _t) => i.to_str(),
1895+
ast::LitUint(u, _t) => u.to_str(),
1896+
ast::LitIntUnsuffixed(i) => i.to_str(),
18971897
ast::LitFloat(ref f, _t) => f.get().to_string(),
18981898
ast::LitFloatUnsuffixed(ref f) => f.get().to_string(),
1899-
ast::LitBool(b) => b.to_str().to_string(),
1899+
ast::LitBool(b) => b.to_str(),
19001900
ast::LitNil => "".to_string(),
19011901
}
19021902
}

src/librustdoc/html/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ impl fmt::Show for clean::Type {
401401
} else {
402402
let mut m = decl.bounds
403403
.iter()
404-
.map(|s| s.to_str().to_string());
404+
.map(|s| s.to_str());
405405
format!(
406406
": {}",
407407
m.collect::<Vec<String>>().connect(" + "))

src/librustdoc/html/markdown.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
208208
// Transform the contents of the header into a hyphenated string
209209
let id = (s.as_slice().words().map(|s| {
210210
match s.to_ascii_opt() {
211-
Some(s) => s.to_lower().into_str().to_string(),
211+
Some(s) => s.to_lower().into_str(),
212212
None => s.to_string()
213213
}
214214
}).collect::<Vec<String>>().connect("-")).to_string();

src/librustdoc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ fn json_input(input: &str) -> Result<Output, String> {
359359
}
360360
};
361361
match json::from_reader(&mut input) {
362-
Err(s) => Err(s.to_str().to_string()),
362+
Err(s) => Err(s.to_str()),
363363
Ok(json::Object(obj)) => {
364364
let mut obj = obj;
365365
// Make sure the schema is what we expect

src/libsyntax/ext/source_util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
125125
Some(src) => {
126126
// Add this input file to the code map to make it available as
127127
// dependency information
128-
let filename = file.display().to_str().to_string();
128+
let filename = file.display().to_str();
129129
let interned = token::intern_and_get_ident(src);
130130
cx.codemap().new_filemap(filename, src.to_string());
131131

src/libsyntax/ext/tt/macro_rules.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ pub fn add_new_extension(cx: &mut ExtCtxt,
252252

253253
box MacroRulesDefiner {
254254
def: RefCell::new(Some(MacroDef {
255-
name: token::get_ident(name).to_str().to_string(),
255+
name: token::get_ident(name).to_str(),
256256
ext: NormalTT(exp, Some(sp))
257257
}))
258258
} as Box<MacResult>

src/libsyntax/parse/token.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ pub fn to_str(t: &Token) -> String {
205205
ast_util::ForceSuffix),
206206
LIT_UINT(u, t) => ast_util::uint_ty_to_str(t, Some(u),
207207
ast_util::ForceSuffix),
208-
LIT_INT_UNSUFFIXED(i) => { (i as u64).to_str().to_string() }
208+
LIT_INT_UNSUFFIXED(i) => { (i as u64).to_str() }
209209
LIT_FLOAT(s, t) => {
210210
let mut body = String::from_str(get_ident(s).get());
211211
if body.as_slice().ends_with(".") {

src/libtest/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,7 @@ mod tests {
15021502
let filtered = filter_tests(&opts, tests);
15031503

15041504
assert_eq!(filtered.len(), 1);
1505-
assert_eq!(filtered.get(0).desc.name.to_str().to_string(),
1505+
assert_eq!(filtered.get(0).desc.name.to_str(),
15061506
"1".to_string());
15071507
assert!(filtered.get(0).desc.ignore == false);
15081508
}
@@ -1553,7 +1553,7 @@ mod tests {
15531553
"test::sort_tests".to_string());
15541554

15551555
for (a, b) in expected.iter().zip(filtered.iter()) {
1556-
assert!(*a == b.desc.name.to_str().to_string());
1556+
assert!(*a == b.desc.name.to_str());
15571557
}
15581558
}
15591559

src/libtime/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ pub fn strftime(format: &str, tm: &Tm) -> String {
10201020
'U' => format!("{:02d}", (tm.tm_yday - tm.tm_wday + 7) / 7),
10211021
'u' => {
10221022
let i = tm.tm_wday as int;
1023-
(if i == 0 { 7 } else { i }).to_str().to_string()
1023+
(if i == 0 { 7 } else { i }).to_str()
10241024
}
10251025
'V' => iso_week('V', tm),
10261026
'v' => {
@@ -1033,8 +1033,8 @@ pub fn strftime(format: &str, tm: &Tm) -> String {
10331033
format!("{:02d}",
10341034
(tm.tm_yday - (tm.tm_wday - 1 + 7) % 7 + 7) / 7)
10351035
}
1036-
'w' => (tm.tm_wday as int).to_str().to_string(),
1037-
'Y' => (tm.tm_year as int + 1900).to_str().to_string(),
1036+
'w' => (tm.tm_wday as int).to_str(),
1037+
'Y' => (tm.tm_year as int + 1900).to_str(),
10381038
'y' => format!("{:02d}", (tm.tm_year as int + 1900) % 100),
10391039
'Z' => "".to_string(), // FIXME(pcwalton): Implement this.
10401040
'z' => {

src/liburl/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ fn get_authority(rawurl: &str) ->
524524
Result<(Option<UserInfo>, String, Option<String>, String), String> {
525525
if !rawurl.starts_with("//") {
526526
// there is no authority.
527-
return Ok((None, "".to_string(), None, rawurl.to_str().to_string()));
527+
return Ok((None, "".to_string(), None, rawurl.to_str()));
528528
}
529529

530530
enum State {

src/test/bench/core-set.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ impl Results {
9090
let mut set = f();
9191
timed(&mut self.sequential_strings, || {
9292
for i in range(0u, num_keys) {
93-
set.insert(i.to_str().to_string());
93+
set.insert(i.to_str());
9494
}
9595

9696
for i in range(0u, num_keys) {
97-
assert!(set.contains(&i.to_str().to_string()));
97+
assert!(set.contains(&i.to_str()));
9898
}
9999
})
100100
}
@@ -103,7 +103,7 @@ impl Results {
103103
let mut set = f();
104104
timed(&mut self.random_strings, || {
105105
for _ in range(0, num_keys) {
106-
let s = rng.gen::<uint>().to_str().to_string();
106+
let s = rng.gen::<uint>().to_str();
107107
set.insert(s);
108108
}
109109
})
@@ -112,11 +112,11 @@ impl Results {
112112
{
113113
let mut set = f();
114114
for i in range(0u, num_keys) {
115-
set.insert(i.to_str().to_string());
115+
set.insert(i.to_str());
116116
}
117117
timed(&mut self.delete_strings, || {
118118
for i in range(0u, num_keys) {
119-
assert!(set.remove(&i.to_str().to_string()));
119+
assert!(set.remove(&i.to_str()));
120120
}
121121
})
122122
}

src/test/run-pass/monad.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl<A> option_monad<A> for Option<A> {
3838
}
3939

4040
fn transform(x: Option<int>) -> Option<String> {
41-
x.bind(|n| Some(*n + 1) ).bind(|n| Some(n.to_str().to_string()) )
41+
x.bind(|n| Some(*n + 1) ).bind(|n| Some(n.to_str()) )
4242
}
4343

4444
pub fn main() {

0 commit comments

Comments
 (0)