about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2017-03-19 20:51:13 -0400
committerGitHub <noreply@github.com>2017-03-19 20:51:13 -0400
commitd49f86901cf1128cdc00b7a1b276f6bf266bf937 (patch)
treeef03d7fdd32204abf7e236da22fb99f85fe7922e /src
parentde724ba9a6cb1aa07d4725c536d949735d0cf12b (diff)
parent5364acb41870eca5b7b41c7980851e6a524c4ca3 (diff)
downloadrust-d49f86901cf1128cdc00b7a1b276f6bf266bf937.tar.gz
rust-d49f86901cf1128cdc00b7a1b276f6bf266bf937.zip
Rollup merge of #40587 - GuillaumeGomez:rustdoc-const-display, r=frewsxcv
Fix invalid debug display for associated consts

Fixes #40568.

r? @rust-lang/docs

cc @SergioBenitez
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/clean/mod.rs8
-rw-r--r--src/librustdoc/html/format.rs4
-rw-r--r--src/test/rustdoc/const-doc.rs31
3 files changed, 37 insertions, 6 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index eff848be2b8..f3ea6c4467c 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -2241,11 +2241,11 @@ pub enum PathParameters {
     AngleBracketed {
         lifetimes: Vec<Lifetime>,
         types: Vec<Type>,
-        bindings: Vec<TypeBinding>
+        bindings: Vec<TypeBinding>,
     },
     Parenthesized {
         inputs: Vec<Type>,
-        output: Option<Type>
+        output: Option<Type>,
     }
 }
 
@@ -2260,14 +2260,14 @@ impl Clean<PathParameters> for hir::PathParameters {
                         data.lifetimes.clean(cx)
                     },
                     types: data.types.clean(cx),
-                    bindings: data.bindings.clean(cx)
+                    bindings: data.bindings.clean(cx),
                 }
             }
 
             hir::ParenthesizedParameters(ref data) => {
                 PathParameters::Parenthesized {
                     inputs: data.inputs.clean(cx),
-                    output: data.output.clean(cx)
+                    output: data.output.clean(cx),
                 }
             }
         }
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index fc5507d4d55..a255ba0ad4e 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -481,7 +481,7 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
         if is_not_debug {
             write!(w, "{:#}{:#}", HRef::new(did, &last.name), last.params)?;
         } else {
-            write!(w, "{:?}{:?}", HRef::new(did, &last.name), last.params)?;
+            write!(w, "{:?}{}", HRef::new(did, &last.name), last.params)?;
         }
     } else {
         if is_not_debug {
@@ -507,7 +507,7 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
             } else {
                 format!("{:?}", HRef::new(did, &last.name))
             };
-            write!(w, "{}{:?}", path, last.params)?;
+            write!(w, "{}{}", path, last.params)?;
         }
     }
     Ok(())
diff --git a/src/test/rustdoc/const-doc.rs b/src/test/rustdoc/const-doc.rs
new file mode 100644
index 00000000000..9f70fe43175
--- /dev/null
+++ b/src/test/rustdoc/const-doc.rs
@@ -0,0 +1,31 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(associated_consts)]
+
+use std::marker::PhantomData;
+
+pub struct Foo<'a> {
+    f: PhantomData<&'a u32>,
+}
+
+pub struct ContentType {
+    pub ttype: Foo<'static>,
+    pub subtype: Foo<'static>,
+    pub params: Option<Foo<'static>>,
+}
+
+impl ContentType {
+    // @has const_doc/struct.ContentType.html
+    // @has  - '//*[@class="docblock"]' 'Any: ContentType = ContentType{ttype: Foo{f: '
+    pub const Any: ContentType = ContentType { ttype: Foo { f: PhantomData, },
+                                               subtype: Foo { f: PhantomData, },
+                                               params: None, };
+}