]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/middle/cfg/graphviz.rs
auto merge of #15421 : catharsis/rust/doc-ffi-minor-fixes, r=alexcrichton
[rust.git] / src / librustc / middle / cfg / graphviz.rs
index b8baeefd3d02efdfa8b8e0b75883b6bd5d969866..e9bcdff070de1764d9e8d0c47ce0c03b913364b9 100644 (file)
 pub struct LabelledCFG<'a>{
     pub ast_map: &'a ast_map::Map,
     pub cfg: &'a cfg::CFG,
-    pub name: StrBuf,
+    pub name: String,
 }
 
-fn replace_newline_with_backslash_l(s: StrBuf) -> StrBuf {
+fn replace_newline_with_backslash_l(s: String) -> String {
     // Replacing newlines with \\l causes each line to be left-aligned,
     // improving presentation of (long) pretty-printed expressions.
     if s.as_slice().contains("\n") {
@@ -37,12 +37,13 @@ fn replace_newline_with_backslash_l(s: StrBuf) -> StrBuf {
         // \l, not the line that follows; so, add \l at end of string
         // if not already present, ensuring last line gets left-aligned
         // as well.
-        let mut last_two : Vec<_> = s.chars().rev().take(2).collect();
+        let mut last_two: Vec<_> =
+            s.as_slice().chars().rev().take(2).collect();
         last_two.reverse();
         if last_two.as_slice() != ['\\', 'l'] {
             s = s.append("\\l");
         }
-        s.to_strbuf()
+        s.to_string()
     } else {
         s
     }
@@ -63,7 +64,7 @@ fn node_label(&'a self, &(i, n): &Node<'a>) -> dot::LabelText<'a> {
         } else if n.data.id == ast::DUMMY_NODE_ID {
             dot::LabelStr("(dummy_node)".into_maybe_owned())
         } else {
-            let s = self.ast_map.node_to_str(n.data.id);
+            let s = self.ast_map.node_to_string(n.data.id);
             // left-aligns the lines
             let s = replace_newline_with_backslash_l(s);
             dot::EscStr(s.into_maybe_owned())
@@ -71,7 +72,7 @@ fn node_label(&'a self, &(i, n): &Node<'a>) -> dot::LabelText<'a> {
     }
 
     fn edge_label(&self, e: &Edge<'a>) -> dot::LabelText<'a> {
-        let mut label = StrBuf::new();
+        let mut label = String::new();
         let mut put_one = false;
         for (i, &node_id) in e.data.exiting_scopes.iter().enumerate() {
             if put_one {
@@ -79,10 +80,12 @@ fn edge_label(&self, e: &Edge<'a>) -> dot::LabelText<'a> {
             } else {
                 put_one = true;
             }
-            let s = self.ast_map.node_to_str(node_id);
+            let s = self.ast_map.node_to_string(node_id);
             // left-aligns the lines
             let s = replace_newline_with_backslash_l(s);
-            label = label.append(format!("exiting scope_{} {}", i, s.as_slice()));
+            label = label.append(format!("exiting scope_{} {}",
+                                         i,
+                                         s.as_slice()).as_slice());
         }
         dot::EscStr(label.into_maybe_owned())
     }
@@ -114,3 +117,4 @@ fn edges(&self) -> dot::Edges<'a, Edge<'a>> { self.cfg.edges() }
     fn source(&self, edge: &Edge<'a>) -> Node<'a> { self.cfg.source(edge) }
     fn target(&self, edge: &Edge<'a>) -> Node<'a> { self.cfg.target(edge) }
 }
+