]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/crateid.rs
libsyntax: Fix errors arising from the automated `~[T]` conversion
[rust.git] / src / libsyntax / crateid.rs
index f3dcd61f2405795c4f48c16f5c4bce66ae32f6c8..e5136b7081b336e940bc1b1c02fd3cac2b096c0d 100644 (file)
@@ -19,6 +19,7 @@
 /// to be `0.0`.
 
 use std::from_str::FromStr;
+use std::vec_ng::Vec;
 
 #[deriving(Clone, Eq)]
 pub struct CrateId {
@@ -49,7 +50,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 impl FromStr for CrateId {
     fn from_str(s: &str) -> Option<CrateId> {
         let pieces: Vec<&str> = s.splitn('#', 1).collect();
-        let path = pieces[0].to_owned();
+        let path = pieces.get(0).to_owned();
 
         if path.starts_with("/") || path.ends_with("/") ||
             path.starts_with(".") || path.is_empty() {
@@ -57,16 +58,18 @@ fn from_str(s: &str) -> Option<CrateId> {
         }
 
         let path_pieces: Vec<&str> = path.rsplitn('/', 1).collect();
-        let inferred_name = path_pieces[0];
+        let inferred_name = *path_pieces.get(0);
 
         let (name, version) = if pieces.len() == 1 {
             (inferred_name.to_owned(), None)
         } else {
-            let hash_pieces: Vec<&str> = pieces[1].splitn(':', 1).collect();
+            let hash_pieces: Vec<&str> = pieces.get(1)
+                                               .splitn(':', 1)
+                                               .collect();
             let (hash_name, hash_version) = if hash_pieces.len() == 1 {
-                ("", hash_pieces[0])
+                ("", *hash_pieces.get(0))
             } else {
-                (hash_pieces[0], hash_pieces[1])
+                (*hash_pieces.get(0), *hash_pieces.get(1))
             };
 
             let name = if !hash_name.is_empty() {
@@ -89,7 +92,7 @@ fn from_str(s: &str) -> Option<CrateId> {
         };
 
         Some(CrateId {
-            path: path,
+            path: path.clone(),
             name: name,
             version: version,
         })