-
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
Switch rustdoc from clean::Stability
to rustc_attr::Stability
#77817
Conversation
This gives greater type safety and is less work to maintain on the rustdoc end.
compiler/rustc_attr/src/builtin.rs
Outdated
(Self::Unstable { .. }, Self::Unstable { .. }) => Some(cmp::Ordering::Equal), | ||
(Self::Stable { .. }, Self::Stable { .. }) => Some(cmp::Ordering::Equal), | ||
(Self::Unstable { .. }, Self::Stable { .. }) => Some(cmp::Ordering::Less), | ||
(Self::Stable { .. }, Self::Unstable { .. }) => Some(cmp::Ordering::Greater), |
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'd keep this bit in rustdoc (and remove the PartialOrd
impl from StabilityLevel
?).
I don't know what rustdoc rendering wants when sorting by stability, but it probably isn't something generally applicable.
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 this can be simplified to mem::discriminant(self).cmp(mem::discriminant(other))
.
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 this can be simplified to mem::discriminant(self).cmp(mem::discriminant(other)).
Does rustc guarantee that the order of the enums matches the order of the discriminants? I thought layout was unspecified.
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.
Yes, discriminant values are specified, see https://doc.rust-lang.org/reference/items/enumerations.html?highlight=discriminant#custom-discriminant-values-for-fieldless-enumerations for enums without data, and https://github.com/rust-lang/rfcs/blob/master/text/2363-arbitrary-enum-discriminant.md#semantics for enums with data.
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.
TIL, thanks!
LGTM modulo the ordering bit. |
Rustdoc's ordering requirements are probably not relevant to the rest of the compiler.
r? @petrochenkov @bors r+ |
📌 Commit 96b0446 has been approved by |
Switch rustdoc from `clean::Stability` to `rustc_attr::Stability` This gives greater type safety and is less work to maintain on the rustdoc end. It also makes rustdoc more consistent with rustc. Noticed this while working on rust-lang#76998. - Remove `clean::Stability` in favor of `rustc_attr::Stability` - Remove `impl Clean for Stability`; it's no longer necessary r? @GuillaumeGomez cc @petrochenkov
Rollup of 8 pull requests Successful merges: - rust-lang#77765 (Add LLVM flags to limit DWARF version to 2 on BSD) - rust-lang#77788 (BTreeMap: fix gdb provider on BTreeMap with ZST keys or values) - rust-lang#77795 (Codegen backend interface refactor) - rust-lang#77808 (Moved the main `impl` for FnCtxt to its own file.) - rust-lang#77817 (Switch rustdoc from `clean::Stability` to `rustc_attr::Stability`) - rust-lang#77829 (bootstrap: only use compiler-builtins-c if they exist) - rust-lang#77870 (Use intra-doc links for links to module-level docs) - rust-lang#77897 (Move `Strip` into a separate rustdoc pass) Failed merges: - rust-lang#77879 (Provide better documentation and help messages for x.py setup) - rust-lang#77902 (Include aarch64-pc-windows-msvc in the dist manifests) r? `@ghost`
Sort unstable items last in rustdoc, instead of first As far as I can tell, this is a bug introduced inadvertently by rust-lang#77817 in Rust 1.49. Older toolchains used to sort unstable items last. Notice how in the code before that PR, `(Unstable, Stable) => return Ordering::Greater` in src/librustdoc/html/render/mod.rs. Whereas after that PR, `(Unstable, Stable) => return Ordering::Less`. Compare https://doc.rust-lang.org/1.48.0/std/marker/index.html vs https://doc.rust-lang.org/1.49.0/std/marker/index.html.
Rollup merge of rust-lang#118224 - dtolnay:rustdocsortunstable, r=fmease Sort unstable items last in rustdoc, instead of first As far as I can tell, this is a bug introduced inadvertently by rust-lang#77817 in Rust 1.49. Older toolchains used to sort unstable items last. Notice how in the code before that PR, `(Unstable, Stable) => return Ordering::Greater` in src/librustdoc/html/render/mod.rs. Whereas after that PR, `(Unstable, Stable) => return Ordering::Less`. Compare https://doc.rust-lang.org/1.48.0/std/marker/index.html vs https://doc.rust-lang.org/1.49.0/std/marker/index.html.
This gives greater type safety and is less work to maintain on the rustdoc end. It also makes rustdoc more consistent with rustc.
Noticed this while working on #76998.
clean::Stability
in favor ofrustc_attr::Stability
impl Clean for Stability
; it's no longer necessaryr? @GuillaumeGomez
cc @petrochenkov