-
Notifications
You must be signed in to change notification settings - Fork 13k
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
rustdoc: Add support for #[rustc_must_implement_one_of]
#99235
rustdoc: Add support for #[rustc_must_implement_one_of]
#99235
Conversation
Some changes occurred in HTML/CSS themes. Some changes occurred in src/librustdoc/clean/types.rs cc @camelid Some changes occurred in HTML/CSS/JS. cc @GuillaumeGomez, @Folyd, @jsha A change occurred in the Ayu theme. cc @Cldfire |
(rust-highfive has picked a reviewer for you, use r? to override) |
src/librustdoc/clean/inline.rs
Outdated
@@ -216,6 +216,7 @@ pub(crate) fn build_external_trait(cx: &mut DocContext<'_>, did: DefId) -> clean | |||
let (generics, supertrait_bounds) = separate_supertrait_bounds(generics); | |||
let is_auto = cx.tcx.trait_is_auto(did); | |||
clean::Trait { | |||
def_id: did, |
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.
I wonder: if we have the trait DefId
, I think most (if not all) other fields can be computed on demand, no?
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.
Probably? What is the purpose of clean types anyway? 🤔
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.
Types "cleaned up" for rustdoc use. :)
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 just feels (from an outside perspective) that a lot of this can be replaced by DefId
newtypes + getters 😅
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.
unsafety
or is_auto
for example. :)
Well, can be done later on.
Also: please add a test in |
This comment has been minimized.
This comment has been minimized.
df48600
to
fd980c0
Compare
Took me a while to figure out how to do rustdoc tests, but I added the test 😄 |
This comment has been minimized.
This comment has been minimized.
if let Some(list) = must_implement_one_of_functions.as_deref() { | ||
write!( | ||
w, | ||
"<div class=\"stab must_implement\">At least one of {} methods is required.</div>", |
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.
There can be one method right? If so, the s
at the end of methods
should be conditional.
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.
Also, can you add backticks around each method name please? Makes it easier to read it in a console.
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.
There can be one method right? If so, the s at the end of methods should be conditional.
No, there are always at least two methods.
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.
Oh indeed. So my first comment can be ignored. Remains the second one. ;)
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.
Like that a81b4304e0d5668e74fd62443faf44da8a2083c8?
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.
Yup!
This comment has been minimized.
This comment has been minimized.
@@ -158,6 +158,7 @@ details.undocumented > summary::before { | |||
.stab.empty-impl { background: #FFF5D6; border-color: #FFC600; } | |||
.stab.unstable { background: #FFF5D6; border-color: #FFC600; } | |||
.stab.deprecated { background: #ffc4c4; border-color: #db7b7b; } | |||
.stab.must_implement { background: #F3DFFF; border-color: #b07bdb; } |
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 need to add this into ayu.css
as well.
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 was already there though. Adding .stab.must_implement{}
fixed the issue, seems like a bug in the checker...
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.
No, the rule isn't the same so to speak. They needed to be all split (hence why it was unhappy). The joy of CSS. :)
Looks all good to me. Please add the missing CSS rule in the ayu theme and it should be good to go! |
☔ The latest upstream changes (presumably #99598) made this pull request unmergeable. Please resolve the merge conflicts. |
a81b430
to
7f1af42
Compare
This comment has been minimized.
This comment has been minimized.
Can someone explain why the tests fail/how to fix them? I don't really get gui tests 😅 |
All the GUI tests are failing because there is a change in the body width. Basically, you broke the layout. 😆 |
Thanks! @bors r+ rollup |
…askrgr Rollup of 6 pull requests Successful merges: - rust-lang#99235 (rustdoc: Add support for `#[rustc_must_implement_one_of]`) - rust-lang#99716 (remove useless mut from examples) - rust-lang#99724 (Fix some broken link fragments.) - rust-lang#99729 (Remove unused tuple fields) - rust-lang#99757 (Make `transmute_copy` docs read better) - rust-lang#99758 (remove useless `#[allow]` in a test) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This PR adds support for
#[rustc_must_implement_one_of]
attribute added in #92164. There is a desire to eventually use this attribute ofRead
, so making it show up in docs is a good thing.I "stole" the styling from cfg notes, not sure what would be a proper styling. Currently it looks like this:
Code to reproduce