-
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] doesn't document method implemented in const
item blocks.
#83026
Comments
jonas-schievink
added
the
T-rustdoc
Relevant to the rustdoc team, which will review and decide on the PR/issue.
label
Mar 11, 2021
That PR is the underscore const itself (see screenshot), not method impls defined inside of the const definition. If it also hides associated methods that come from inside the const definition, that was not intentional. |
I tested with the following small change and the associated method - const _: () = {
+ pub const K: () = { |
jyn514
changed the title
[rustdoc] doesn't document method implemented in
[rustdoc] doesn't document method implemented in Mar 30, 2021
const _:() = {}
blocks.const
item blocks.
Aaron1011
pushed a commit
to Aaron1011/rust
that referenced
this issue
Jan 6, 2023
…st-expr, r=notriddle Fix impl block in const expr Fixes rust-lang#83026. The problem was that we didn't visit block expressions. Considering how big the [walk_expr](https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_hir/intravisit.rs.html#678) function is, I decided to instead implement the `hir` visitor on the struct. It also answers the question which was in a comment for `RustdocVisitor`: we should have used a visitor instead of our ad-hoc implementation. Adding this visitor also added some extra checks that weren't present before (check changes in `rustdoc-ui` tests). r? `@notriddle`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rustdoc doesn't document method implemented in
const _:() = {}
blocks.(They don't show up at all.)
Minified example:
I expected to see this happen:
A::new
to show up in rustdoc (without any doc comment)Instead, this happened:
A::new
is not visible at all in the generated documentation.Why is it important that rustdoc documents such items.
const _:() = {}
blocks are currently the only way to have scopes on top-level items which are necessaryfor producing cleaner code by e.g. grouping imports with impl. blocks or easily feature gating multiple
impl's and imports without needing to repeat the
#[cfg(...)]
on each item (making changes easy to accidentally partial brake code by forgetting a place where it changed).I personally did run into this when I had a large amount of methods and traits implemented very similar on two types, where for various reasons a shared trait was not possible (and not appropriate either). I used
const _:()={}
to make sure the imports for the many method and trait impl.s do stay inside of the macro and do not pollute the outer scope. As far as I know this trick is also not uncommon for proc-macros.Meta
appears on 1.47, stable, beta, nightly:
The text was updated successfully, but these errors were encountered: