From ab10b1ed292be48ac4d4cbe31da811035d284e85 Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Thu, 6 Jun 2013 20:44:30 +0530 Subject: [PATCH 1/2] libstd: fix comment in to_str impl of tuple There is a pointer to #4760, which is a closed issue. The real issue is the more general problem described in #4653. Correct the comment. Signed-off-by: Ramkumar Ramachandra --- src/libstd/to_str.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/to_str.rs b/src/libstd/to_str.rs index 3cc64147964cb..d15c0a31f5f0c 100644 --- a/src/libstd/to_str.rs +++ b/src/libstd/to_str.rs @@ -91,7 +91,7 @@ impl ToStr for HashSet { impl ToStr for (A, B) { #[inline(always)] fn to_str(&self) -> ~str { - // FIXME(#4760): this causes an llvm assertion + // FIXME(#4653): this causes an llvm assertion //let &(ref a, ref b) = self; match *self { (ref a, ref b) => { @@ -104,7 +104,7 @@ impl ToStr for (A, B) { impl ToStr for (A, B, C) { #[inline(always)] fn to_str(&self) -> ~str { - // FIXME(#4760): this causes an llvm assertion + // FIXME(#4653): this causes an llvm assertion //let &(ref a, ref b, ref c) = self; match *self { (ref a, ref b, ref c) => { From 01c4f11cf82f0b4cf5468f2e41d2ef9e351b7a08 Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Thu, 6 Jun 2013 20:47:04 +0530 Subject: [PATCH 2/2] libstd: use fmt! in to_str impl for (one|two)-tuple The three-tuple uses fmt!, and there's no reason to hand-concatenate strings. Signed-off-by: Ramkumar Ramachandra --- src/libstd/to_str.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/to_str.rs b/src/libstd/to_str.rs index d15c0a31f5f0c..bfda92d46a284 100644 --- a/src/libstd/to_str.rs +++ b/src/libstd/to_str.rs @@ -44,7 +44,7 @@ impl ToStr for (A,) { fn to_str(&self) -> ~str { match *self { (ref a,) => { - ~"(" + a.to_str() + ",)" + fmt!("(%s,)", (*a).to_str()) } } } @@ -95,7 +95,7 @@ impl ToStr for (A, B) { //let &(ref a, ref b) = self; match *self { (ref a, ref b) => { - ~"(" + a.to_str() + ", " + b.to_str() + ")" + fmt!("(%s, %s)", (*a).to_str(), (*b).to_str()) } } }