]> git.lizzy.rs Git - rust.git/blobdiff - src/librustdoc/html/render.rs
remove unnecessary parentheses from range notation
[rust.git] / src / librustdoc / html / render.rs
index 3accbbfb1a2e79124d91709b8404b667905a9371..403bd1c29617ac33f0e19833113f607118d30ff2 100644 (file)
@@ -821,7 +821,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
         if let clean::ImplItem(ref i) = item.inner {
             match i.trait_ {
                 Some(clean::ResolvedPath{ did, .. }) => {
-                    let v = self.implementors.entry(&did).get().unwrap_or_else(
+                    let v = self.implementors.entry(did).get().unwrap_or_else(
                         |vacant_entry| vacant_entry.insert(Vec::with_capacity(1)));
                     v.push(Implementor {
                         def_id: item.def_id,
@@ -842,7 +842,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
                 clean::StructFieldItem(..) |
                 clean::VariantItem(..) => {
                     ((Some(*self.parent_stack.last().unwrap()),
-                      Some(self.stack[..self.stack.len() - 1])),
+                      Some(&self.stack[..self.stack.len() - 1])),
                      false)
                 }
                 clean::MethodItem(..) => {
@@ -853,13 +853,13 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
                         let did = *last;
                         let path = match self.paths.get(&did) {
                             Some(&(_, ItemType::Trait)) =>
-                                Some(self.stack[..self.stack.len() - 1]),
+                                Some(&self.stack[..self.stack.len() - 1]),
                             // The current stack not necessarily has correlation for
                             // where the type was defined. On the other hand,
                             // `paths` always has the right information if present.
                             Some(&(ref fqp, ItemType::Struct)) |
                             Some(&(ref fqp, ItemType::Enum)) =>
-                                Some(fqp[..fqp.len() - 1]),
+                                Some(&fqp[..fqp.len() - 1]),
                             Some(..) => Some(self.stack.as_slice()),
                             None => None
                         };
@@ -1011,7 +1011,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
                         };
 
                         if let Some(did) = did {
-                            let v = self.impls.entry(&did).get().unwrap_or_else(
+                            let v = self.impls.entry(did).get().unwrap_or_else(
                                 |vacant_entry| vacant_entry.insert(Vec::with_capacity(1)));
                             v.push(Impl {
                                 impl_: i,
@@ -1051,7 +1051,7 @@ fn recurse<T, F>(&mut self, s: String, f: F) -> T where
         F: FnOnce(&mut Context) -> T,
     {
         if s.len() == 0 {
-            panic!("Unexpected empty destination: {}", self.current);
+            panic!("Unexpected empty destination: {:?}", self.current);
         }
         let prev = self.dst.clone();
         self.dst.push(s.as_slice());
@@ -1185,7 +1185,7 @@ fn render(w: io::File, cx: &Context, it: &clean::Item,
                                            .collect::<String>();
                 match cache().paths.get(&it.def_id) {
                     Some(&(ref names, _)) => {
-                        for name in names[..names.len() - 1].iter() {
+                        for name in (&names[..names.len() - 1]).iter() {
                             url.push_str(name.as_slice());
                             url.push_str("/");
                         }
@@ -1260,7 +1260,7 @@ fn build_sidebar(&self, m: &clean::Module) -> HashMap<String, Vec<String>> {
                 Some(ref s) => s.to_string(),
             };
             let short = short.to_string();
-            let v = map.entry(&short).get().unwrap_or_else(
+            let v = map.entry(short).get().unwrap_or_else(
                 |vacant_entry| vacant_entry.insert(Vec::with_capacity(1)));
             v.push(myname);
         }
@@ -1351,8 +1351,7 @@ fn href(&self, cx: &Context) -> Option<String> {
 }
 
 
-
-impl<'a> fmt::Show for Item<'a> {
+impl<'a> fmt::String for Item<'a> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         // Write the breadcrumb trail header for the top
         try!(write!(fmt, "\n<h1 class='fqn'><span class='in-band'>"));
@@ -1542,7 +1541,7 @@ fn cmp(i1: &clean::Item, i2: &clean::Item, idx1: uint, idx2: uint) -> Ordering {
 
     indices.sort_by(|&i1, &i2| cmp(&items[i1], &items[i2], i1, i2));
 
-    debug!("{}", indices);
+    debug!("{:?}", indices);
     let mut curty = None;
     for &idx in indices.iter() {
         let myitem = &items[idx];
@@ -1626,7 +1625,8 @@ fn cmp(i1: &clean::Item, i2: &clean::Item, idx1: uint, idx2: uint) -> Ordering {
 }
 
 struct Initializer<'a>(&'a str);
-impl<'a> fmt::Show for Initializer<'a> {
+
+impl<'a> fmt::String for Initializer<'a> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let Initializer(s) = *self;
         if s.len() == 0 { return Ok(()); }
@@ -2127,7 +2127,7 @@ fn doctraititem(w: &mut fmt::Formatter, item: &clean::Item, dox: bool)
                 try!(assoc_type(w, item, typaram));
                 try!(write!(w, "</code></h4>\n"));
             }
-            _ => panic!("can't make docs for trait item with name {}", item.name)
+            _ => panic!("can't make docs for trait item with name {:?}", item.name)
         }
         match item.doc_value() {
             Some(s) if dox => {
@@ -2188,7 +2188,7 @@ fn item_typedef(w: &mut fmt::Formatter, it: &clean::Item,
     document(w, it)
 }
 
-impl<'a> fmt::Show for Sidebar<'a> {
+impl<'a> fmt::String for Sidebar<'a> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         let cx = self.cx;
         let it = self.item;
@@ -2243,7 +2243,7 @@ fn block(w: &mut fmt::Formatter, short: &str, longty: &str,
     }
 }
 
-impl<'a> fmt::Show for Source<'a> {
+impl<'a> fmt::String for Source<'a> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         let Source(s) = *self;
         let lines = s.lines().count();
@@ -2253,9 +2253,9 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
             cols += 1;
             tmp /= 10;
         }
-        try!(write!(fmt, "<pre class='line-numbers'>"));
+        try!(write!(fmt, "<pre class=\"line-numbers\">"));
         for i in range(1, lines + 1) {
-            try!(write!(fmt, "<span id='{0}'>{0:1$}</span>\n", i, cols));
+            try!(write!(fmt, "<span id=\"{0}\">{0:1$}</span>\n", i, cols));
         }
         try!(write!(fmt, "</pre>"));
         try!(write!(fmt, "{}", highlight::highlight(s.as_slice(), None, None)));
@@ -2267,7 +2267,7 @@ fn item_macro(w: &mut fmt::Formatter, it: &clean::Item,
               t: &clean::Macro) -> fmt::Result {
     try!(w.write_str(highlight::highlight(t.source.as_slice(),
                                           Some("macro"),
-                                          None)[]));
+                                          None).as_slice()));
     document(w, it)
 }