rustdoc: render doc(hidden) as a code attribute#151001
rustdoc: render doc(hidden) as a code attribute#151001rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Conversation
|
rustbot has assigned @GuillaumeGomez. Use |
719dca9 to
d88a903
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
b6e120a to
273d673
Compare
This comment has been minimized.
This comment has been minimized.
src/librustdoc/html/render/mod.rs
Outdated
| let mut render_attr = |attr: &str| -> fmt::Result { | ||
| if !wrote_any { | ||
| if let Some(open_tag) = open_tag { | ||
| w.write_str(open_tag)?; | ||
| } | ||
| wrote_any = true; | ||
| } | ||
| render_code_attribute(prefix, attr, w) | ||
| }; |
There was a problem hiding this comment.
In case open_tag is None, we could remove the need for the if check by creating two different closures:
| let mut render_attr = |attr: &str| -> fmt::Result { | |
| if !wrote_any { | |
| if let Some(open_tag) = open_tag { | |
| w.write_str(open_tag)?; | |
| } | |
| wrote_any = true; | |
| } | |
| render_code_attribute(prefix, attr, w) | |
| }; | |
| let mut render_attr: FnMut(&str) -> fmt::Result = if let Some(open_tag) = open_tag { | |
| |attr: &str| -> fmt::Result { | |
| if !wrote_any { | |
| w.write_str(open_tag)?; | |
| wrote_any = true; | |
| } | |
| render_code_attribute(prefix, attr, w) | |
| } | |
| } else { | |
| |attr: &str| -> fmt::Result { | |
| render_code_attribute(prefix, attr, w) | |
| } | |
| }; |
Not sure it compiles but with a few tweaks it should (or use functions instead, it works too).
There was a problem hiding this comment.
Using two closures in an if expression does not compile because each closure has a unique anonymous type. So I need boxing or enum to make one concrete type which adds allocation or extra codes.
I used the empty string instead, WDYT?
let open_tag = open_tag.unwrap_or("");
let mut render_attr = |attr: &str| -> fmt::Result {
if !wrote_any {
w.write_str(open_tag)?;
wrote_any = true;
}
render_code_attribute(prefix, attr, w)
};
There was a problem hiding this comment.
The problem is also that it adds more checks. Did you try with functions instead of closures?
There was a problem hiding this comment.
Hmm i tried it but using function does not reduce the checks, it only changes the style.
I moved the <dt><code> write into render_attributes_in_code_with_options by adding an open_tag parameter.
68fa0af to
3fb84f0
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bff7096 to
713a0f2
Compare
|
Some changes occurred in src/tools/cargo cc @ehuss |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
713a0f2 to
7c54229
Compare
This comment has been minimized.
This comment has been minimized.
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
bddcba7 to
43477d6
Compare
This comment has been minimized.
This comment has been minimized.
|
Looks all good to me, thanks! Please squash your commits and then I'll r+ it. |
Move `#[doc(hidden)]` into the shared code-attribute renderer so it matches the styling and placement of other attributes in rustdoc HTML.
8ae2687 to
b4c4d95
Compare
|
@GuillaumeGomez Thanks! |
|
Thanks! @bors r+ rollup |
…uwer Rollup of 11 pull requests Successful merges: - #151001 (rustdoc: render doc(hidden) as a code attribute) - #151042 (fix fallback impl for select_unpredictable intrinsic) - #151220 (option: Use Option::map in Option::cloned) - #151260 (Handle unevaluated ConstKind in in_operand) - #151296 (MGCA: Fix incorrect pretty printing of valtree arrays) - #151423 (Move assert_matches to planned stable path) - #151441 (Fix ICE: Don't try to evaluate type_consts when eagerly collecting items) - #151465 (codegen: clarify some variable names around function calls) - #151468 (fix `f16` doctest FIXMEs) - #151469 (llvm: Tolerate dead_on_return attribute changes) - #151476 (Avoid `-> ()` in derived functions.) r? @ghost
…uwer Rollup of 11 pull requests Successful merges: - #151001 (rustdoc: render doc(hidden) as a code attribute) - #151042 (fix fallback impl for select_unpredictable intrinsic) - #151220 (option: Use Option::map in Option::cloned) - #151260 (Handle unevaluated ConstKind in in_operand) - #151296 (MGCA: Fix incorrect pretty printing of valtree arrays) - #151423 (Move assert_matches to planned stable path) - #151441 (Fix ICE: Don't try to evaluate type_consts when eagerly collecting items) - #151465 (codegen: clarify some variable names around function calls) - #151468 (fix `f16` doctest FIXMEs) - #151469 (llvm: Tolerate dead_on_return attribute changes) - #151476 (Avoid `-> ()` in derived functions.) r? @ghost
…uwer Rollup of 11 pull requests Successful merges: - #151001 (rustdoc: render doc(hidden) as a code attribute) - #151042 (fix fallback impl for select_unpredictable intrinsic) - #151220 (option: Use Option::map in Option::cloned) - #151260 (Handle unevaluated ConstKind in in_operand) - #151296 (MGCA: Fix incorrect pretty printing of valtree arrays) - #151423 (Move assert_matches to planned stable path) - #151441 (Fix ICE: Don't try to evaluate type_consts when eagerly collecting items) - #151465 (codegen: clarify some variable names around function calls) - #151468 (fix `f16` doctest FIXMEs) - #151469 (llvm: Tolerate dead_on_return attribute changes) - #151476 (Avoid `-> ()` in derived functions.) r? @ghost
…uwer Rollup of 11 pull requests Successful merges: - rust-lang/rust#151001 (rustdoc: render doc(hidden) as a code attribute) - rust-lang/rust#151042 (fix fallback impl for select_unpredictable intrinsic) - rust-lang/rust#151220 (option: Use Option::map in Option::cloned) - rust-lang/rust#151260 (Handle unevaluated ConstKind in in_operand) - rust-lang/rust#151296 (MGCA: Fix incorrect pretty printing of valtree arrays) - rust-lang/rust#151423 (Move assert_matches to planned stable path) - rust-lang/rust#151441 (Fix ICE: Don't try to evaluate type_consts when eagerly collecting items) - rust-lang/rust#151465 (codegen: clarify some variable names around function calls) - rust-lang/rust#151468 (fix `f16` doctest FIXMEs) - rust-lang/rust#151469 (llvm: Tolerate dead_on_return attribute changes) - rust-lang/rust#151476 (Avoid `-> ()` in derived functions.) r? @ghost
Move
#[doc(hidden)]into the shared code-attribute renderer so it matches the styling and placement of other attributes in rustdoc HTML.Closes #132304