-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add trait alias support in rustdoc #58243
Conversation
09efb73
to
d55664c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me
src/librustdoc/clean/mod.rs
Outdated
impl Clean<Item> for doctree::TraitAlias { | ||
fn clean(&self, cx: &DocContext) -> Item { | ||
let attrs = self.attrs.clean(cx); | ||
let is_spotlight = attrs.has_doc_flag("spotlight"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check if spotlight actually works for trait impls using an aliased trait.
So, we should see what happens for:
#[doc(spotlight)]
trait Foo {}
trait Bar = Foo;
struct Ty;
impl Bar for Ty;
and
trait Foo {}
#[doc(spotlight)]
trait Bar = Foo;
struct Ty;
impl Bar for Ty;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't implement a trait alias directly. So I guess that spotlight doesn't make sense for a trait alias. I'll remove spotlight "support" for them.
src/librustdoc/html/render.rs
Outdated
@@ -1908,6 +1911,7 @@ impl fmt::Display for AllTypes { | |||
print_entries(f, &self.derives, "Derive Macros", "derives")?; | |||
print_entries(f, &self.functions, "Functions", "functions")?; | |||
print_entries(f, &self.typedefs, "Typedefs", "typedefs")?; | |||
print_entries(f, &self.trait_aliases, "Trait Aliases", "trait-alias")?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trait-aliases, to be consistent.
(should there be a hyphen at all?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a css class so I guess it's fine (but I'll keep the hyphen :) )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's nice to be consistent, also: y'all have theming support so the css classes do matter, if only a little bit
d55664c
to
b1d82ac
Compare
Updated. |
@bors r+ |
📌 Commit b1d82ac has been approved by |
…Manishearth Add trait alias support in rustdoc Fixes rust-lang#57595. r? @QuietMisdreavus
Rollup of 16 pull requests Successful merges: - #57259 (Update reference of rlibc crate to compiler-builtins crate) - #57740 (Use `to_ne_bytes` for converting IPv4Addr to octets) - #57926 (Tiny expansion to docs for `core::convert`.) - #58157 (Add Cargo.lock automatically adding message) - #58203 (rustdoc: display sugared return types for async functions) - #58243 (Add trait alias support in rustdoc) - #58262 (Add #[must_use] message to Fn* traits) - #58295 (std::sys::unix::stdio: explain why we do into_raw) - #58297 (Cleanup JS a bit) - #58317 (Some writing improvement, conciseness of intro) - #58324 (miri: give non-generic functions a stable address) - #58332 (operand-to-place copies should never be overlapping) - #58345 (When there are multiple filenames, print what got interpreted as filenames) - #58346 (rpath computation: explain why we pop()) - #58350 (Fix failing tidy (line endings on Windows)) - #58352 (miri value visitor: use `?` in macro) Failed merges: r? @ghost
Fixes #57595.
r? @QuietMisdreavus