]> git.lizzy.rs Git - rust.git/commitdiff
rustdoc: Use dyn keyword when rendering dynamic traits
authorOliver Middleton <olliemail27@gmail.com>
Sun, 14 Oct 2018 23:48:57 +0000 (00:48 +0100)
committerOliver Middleton <olliemail27@gmail.com>
Sun, 14 Oct 2018 23:48:57 +0000 (00:48 +0100)
The dyn keyword has been stable for a while now so rustdoc should start using it.

src/librustdoc/html/format.rs
src/test/rustdoc/assoc-consts.rs
src/test/rustdoc/inline_cross/issue-32881.rs
src/test/rustdoc/test-parens.rs

index 7643aade83b7df8f48c99db21990565fefe27631..445fc2e833a3f503b570edcbf1a3e2f959fdda3d 100644 (file)
@@ -553,6 +553,9 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
             f.write_str(name)
         }
         clean::ResolvedPath{ did, ref typarams, ref path, is_generic } => {
+            if typarams.is_some() {
+                f.write_str("dyn ")?;
+            }
             // Paths like T::Output and Self::Output should be rendered with all segments
             resolved_path(f, did, path, is_generic, use_absolute)?;
             tybounds(f, typarams)
index 71e7db5f4a543d08cda585497b0d1d546aea5dc9..cbb2a00214a5a30458589108ebba6ad49bc05323 100644 (file)
@@ -52,7 +52,7 @@ pub fn f(_: &(ToString + 'static)) {}
 
 impl Bar {
     // @has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.F"]' \
-    //      "const F: fn(_: &(ToString + 'static))"
+    //      "const F: fn(_: &(dyn ToString + 'static))"
     pub const F: fn(_: &(ToString + 'static)) = f;
 }
 
index 948061bdcbed58fef6bb39215c6081be9fc30121..c55a69bcb7bc5f5414bfa1052ac106f0fb40ed7b 100644 (file)
@@ -15,8 +15,8 @@
 extern crate rustdoc_trait_object_impl;
 
 // @has issue_32881/trait.Bar.html
-// @has - '//code' "impl<'a> Bar"
-// @has - '//code' "impl<'a> Debug for Bar"
+// @has - '//code' "impl<'a> dyn Bar"
+// @has - '//code' "impl<'a> Debug for dyn Bar"
 
 pub use rustdoc_trait_object_impl::Bar;
 
index 792dc9c218d56dae8752678c32b5d097d0307724..0c9452fa1e1af218b033fd8eec6231dca2b475dc 100644 (file)
@@ -11,5 +11,5 @@
 #![crate_name = "foo"]
 
 // @has foo/fn.foo.html
-// @has - '//*[@class="rust fn"]' "_: &(ToString + 'static)"
+// @has - '//*[@class="rust fn"]' "_: &(dyn ToString + 'static)"
 pub fn foo(_: &(ToString + 'static)) {}