Skip to content
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

Use rustc_lint::builtin::has_doc #7247

Closed
camsteffen opened this issue May 19, 2021 · 4 comments · Fixed by #7281
Closed

Use rustc_lint::builtin::has_doc #7247

camsteffen opened this issue May 19, 2021 · 4 comments · Fixed by #7281

Comments

@camsteffen
Copy link
Contributor

See rust-lang/rust#85457 (comment)

@jyn514
Copy link
Member

jyn514 commented Jun 4, 2021

This is still not the same behavior of has_doc:

fn has_doc(sess: &Session, attr: &ast::Attribute) -> bool {
    if attr.is_doc_comment() {
        return true;
    }

    if !sess.check_name(attr, sym::doc) {
        return false;
    }

    if attr.value_str().is_some() {
        return true;
    }

    if let Some(list) = attr.meta_item_list() {
        for meta in list {
            if meta.has_name(sym::hidden) {
                return true;
            }
        }
    }

    false
}

Seems not great for them to be inconsistent.

@jyn514
Copy link
Member

jyn514 commented Jun 4, 2021

Hmm, I take it back, clippy just checks for doc(hidden) seperately: https://github.com/camsteffen/rust-clippy/blob/c21b965d43d5584c3e0df219e6638494d2dc3ea9/clippy_lints/src/missing_doc.rs#L87
I guess it's not a big deal; you could remove doc_hidden_stack if you made this cleanup though.

Also, I suspect clippy has the same bug as rustdoc when items under a hidden module are re-exported: rust-lang/rust#59368

@camsteffen
Copy link
Contributor Author

I'm not sure if there is something actionable here? Maybe there is still room for sharing code but it seems insignificant. I don't know how that bug would apply to the Clippy lint.

@jyn514
Copy link
Member

jyn514 commented Jun 4, 2021

@camsteffen here is how I think the false negative would show up:

#[doc(hidden)]
pub mod inner {
  pub struct MissingDocs;
}

pub use inner::MissingDocs; // should warn about an undocumented struct, but does not.

It doesn't matter until the rustdoc bug is fixed, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants