Skip to content

Commit 86d5a33

Browse files
committed
rustdoc: Use dyn keyword when rendering dynamic traits
The dyn keyword has been stable for a while now so rustdoc should start using it.
1 parent 14f42a7 commit 86d5a33

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

src/librustdoc/html/format.rs

+3
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,9 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
553553
f.write_str(name)
554554
}
555555
clean::ResolvedPath{ did, ref typarams, ref path, is_generic } => {
556+
if typarams.is_some() {
557+
f.write_str("dyn ")?;
558+
}
556559
// Paths like T::Output and Self::Output should be rendered with all segments
557560
resolved_path(f, did, path, is_generic, use_absolute)?;
558561
tybounds(f, typarams)

src/test/rustdoc/assoc-consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub fn f(_: &(ToString + 'static)) {}
5252

5353
impl Bar {
5454
// @has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.F"]' \
55-
// "const F: fn(_: &(ToString + 'static))"
55+
// "const F: fn(_: &(dyn ToString + 'static))"
5656
pub const F: fn(_: &(ToString + 'static)) = f;
5757
}
5858

src/test/rustdoc/inline_cross/issue-32881.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
extern crate rustdoc_trait_object_impl;
1616

1717
// @has issue_32881/trait.Bar.html
18-
// @has - '//code' "impl<'a> Bar"
19-
// @has - '//code' "impl<'a> Debug for Bar"
18+
// @has - '//code' "impl<'a> dyn Bar"
19+
// @has - '//code' "impl<'a> Debug for dyn Bar"
2020

2121
pub use rustdoc_trait_object_impl::Bar;
2222

src/test/rustdoc/test-parens.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
#![crate_name = "foo"]
1212

1313
// @has foo/fn.foo.html
14-
// @has - '//*[@class="rust fn"]' "_: &(ToString + 'static)"
14+
// @has - '//*[@class="rust fn"]' "_: &(dyn ToString + 'static)"
1515
pub fn foo(_: &(ToString + 'static)) {}

0 commit comments

Comments
 (0)