-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Fix rustdoc formatting of impls #27103
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
Conversation
Some cases displayed negative impls as positive, and some were missing where clauses. This factors all the impl formatting into one function so the different cases can't get out of sync again.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @cmr (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
librustdoc has no stability guarantees, so that's fine. code looks good to me, but I'd like someone else to sign off on it too. |
Could you add tests for this? The rustdoc test suite isn't terribly well-documented, but see https://github.com/rust-lang/rust/tree/master/src/test/rustdoc for some examples. The script that runs the rustdoc tests is called htmldocck.py. Please ask questions if you have any! |
I've added a test covering two of the three cases where impls are currently printed. I think the third is only used for cross-crate implementations of traits, so I'm not sure if there's an easy way to test that. (They all use the same formatting code now, so I don't think it's all that important to test the last case.) |
Thanks so much! Yeah, cross-crate rustdoc tests are a pain (and unfortunately, also the kind of docs that break the most often). What you want to do for those is write a crate file in Here's an example: rustdoc test crate: https://github.com/rust-lang/rust/blob/master/src/test/rustdoc/default-impl.rs |
Looks great to me as well, thanks @wthrowe! r=me if a test like @tomjakubowski mentioned is added. |
Thanks for the tips! Here's another test! |
This fixes a couple of bugs visible on https://doc.rust-lang.org/nightly/std/marker/trait.Sync.html . For example: * `impl<T> Sync for *const T` should read `impl<T> !Sync for *const T` * `impl<T> !Sync for Weak<T>` should read `impl<T> !Sync for Weak<T> where T: ?Sized` This does change a struct in librustdoc and it seems that almost everything there is marked public, so if librustdoc has stability guarantees that could be a problem. If it is, I'll find a way to rework the change to avoid modifying public structures.
💔 Test failed - auto-linux-64-x-android-t |
Ah right I believe that all cross-crate rustdoc tests need some special sauce for android, I believe you can fix this by just adding |
See if that does it. |
This fixes a couple of bugs visible on https://doc.rust-lang.org/nightly/std/marker/trait.Sync.html . For example: * `impl<T> Sync for *const T` should read `impl<T> !Sync for *const T` * `impl<T> !Sync for Weak<T>` should read `impl<T> !Sync for Weak<T> where T: ?Sized` This does change a struct in librustdoc and it seems that almost everything there is marked public, so if librustdoc has stability guarantees that could be a problem. If it is, I'll find a way to rework the change to avoid modifying public structures.
This fixes a couple of bugs visible on https://doc.rust-lang.org/nightly/std/marker/trait.Sync.html . For example:
impl<T> Sync for *const T
should readimpl<T> !Sync for *const T
impl<T> !Sync for Weak<T>
should readimpl<T> !Sync for Weak<T> where T: ?Sized
This does change a struct in librustdoc and it seems that almost everything there is marked public, so if librustdoc has stability guarantees that could be a problem. If it is, I'll find a way to rework the change to avoid modifying public structures.