about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librusti/rusti.rc2
-rw-r--r--src/libstd/str.rs24
2 files changed, 23 insertions, 3 deletions
diff --git a/src/librusti/rusti.rc b/src/librusti/rusti.rc
index 06ec6769385..0af6ed724e1 100644
--- a/src/librusti/rusti.rc
+++ b/src/librusti/rusti.rc
@@ -370,7 +370,7 @@ fn run_cmd(repl: &mut Repl, _in: @io::Reader, _out: @io::Writer,
                     if arg.ends_with(".rs") || arg.ends_with(".rc") {
                     (arg.slice_to(arg.len() - 3).to_owned(), copy *arg)
                 } else {
-                    (copy *arg, arg + ".rs")
+                    (copy *arg, *arg + ".rs")
                 };
                 match compile_crate(filename, copy repl.binary) {
                     Some(_) => loaded_crates.push(crate),
diff --git a/src/libstd/str.rs b/src/libstd/str.rs
index 1ab07003b6e..21f747317f4 100644
--- a/src/libstd/str.rs
+++ b/src/libstd/str.rs
@@ -913,10 +913,12 @@ pub mod traits {
     use cmp::{TotalOrd, Ordering, Less, Equal, Greater, Eq, Ord, Equiv, TotalEq};
     use super::{Str, eq_slice};
 
-    impl<'self> Add<&'self str,~str> for ~str {
+    impl<'self> Add<&'self str,~str> for &'self str {
         #[inline(always)]
         fn add(&self, rhs: & &'self str) -> ~str {
-            self.append((*rhs))
+            let mut ret = self.to_owned();
+            ret.push_str(*rhs);
+            ret
         }
     }
 
@@ -3138,6 +3140,24 @@ mod tests {
     }
 
     #[test]
+    fn test_add() {
+        macro_rules! t (
+            ($s1:expr, $s2:expr, $e:expr) => {
+                assert_eq!($s1 + $s2, $e);
+                assert_eq!($s1.to_owned() + $s2, $e);
+                assert_eq!($s1.to_managed() + $s2, $e);
+            }
+        );
+
+        t!("foo",  "bar", ~"foobar");
+        t!("foo", @"bar", ~"foobar");
+        t!("foo", ~"bar", ~"foobar");
+        t!("ศไทย中",  "华Việt Nam", ~"ศไทย中华Việt Nam");
+        t!("ศไทย中", @"华Việt Nam", ~"ศไทย中华Việt Nam");
+        t!("ศไทย中", ~"华Việt Nam", ~"ศไทย中华Việt Nam");
+    }
+
+    #[test]
     fn test_iterator() {
         use iterator::*;
         let s = ~"ศไทย中华Việt Nam";