Skip to content

Commit

Permalink
Rollup merge of rust-lang#55077 - ollie27:rustdoc_dyn_trait, r=QuietM…
Browse files Browse the repository at this point in the history
…isdreavus

rustdoc: Use dyn keyword when rendering dynamic traits

The dyn keyword has been stable for a while now so rustdoc should start using it.

r? @QuietMisdreavus
  • Loading branch information
kennytm committed Oct 18, 2018
2 parents 7538c62 + 86d5a33 commit ed68f1a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/assoc-consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/rustdoc/inline_cross/issue-32881.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

2 changes: 1 addition & 1 deletion src/test/rustdoc/test-parens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {}

0 comments on commit ed68f1a

Please sign in to comment.