Skip to content

Check crate root for docs in missing_doc lint. #10665

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

Closed
wants to merge 1 commit into from
Closed

Check crate root for docs in missing_doc lint. #10665

wants to merge 1 commit into from

Conversation

emberian
Copy link
Member

Because the root module isn't actually an item, we need to do some hackish
handling of it.

Closes #10656.

if !cx.tcx.sess.opts.test {
// `#[doc(hidden)]` disables missing_doc check.
if !cx.is_doc_hidden {
if !crate.attrs.iter().any(|a| a.node.is_sugared_doc) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, does this detect #[doc="foo"]?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dunno. Does it detect it in check_missing_doc_attrs?

On Tue, Nov 26, 2013 at 1:20 AM, Huon Wilson notifications@github.comwrote:

In src/librustc/middle/lint.rs:

@@ -1256,6 +1256,21 @@ pub fn check_crate(tcx: ty::ctxt,
v.visited_outermost = true;
visit::walk_crate(v, crate, ());
}
+

  •    // this basically duplicates check_missing_doc_attrs from above, minus the visibility test.
    
  •    // If we're building a test harness, then warning about
    
  •    // documentation is probably not really relevant right now.
    
  •    if !cx.tcx.sess.opts.test {
    
  •        // `#[doc(hidden)]` disables missing_doc check.
    
  •        if !cx.is_doc_hidden {
    
  •            if !crate.attrs.iter().any(|a| a.node.is_sugared_doc) {
    

Hm, does this detect #[doc="foo"]?


Reply to this email directly or view it on GitHubhttps://github.com//pull/10665/files#r7916305
.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know; that may be wrong too. (I would check but I'm rustc-less at the moment.)

Corey Richardson notifications@github.com wrote:

@@ -1256,6 +1256,21 @@ pub fn check_crate(tcx: ty::ctxt,
v.visited_outermost = true;
visit::walk_crate(v, crate, ());
}
+

  •    // this basically duplicates check_missing_doc_attrs from
    
    above, minus the visibility test.
    +
  •    // If we're building a test harness, then warning about
    
  •    // documentation is probably not really relevant right now.
    
  •    if !cx.tcx.sess.opts.test {
    
  •        // `#[doc(hidden)]` disables missing_doc check.
    
  •        if !cx.is_doc_hidden {
    
  •            if !crate.attrs.iter().any(|a|
    
    a.node.is_sugared_doc) {

Dunno. Does it detect it in check_missing_doc_attrs?

On Tue, Nov 26, 2013 at 1:20 AM, Huon Wilson
notifications@github.comwrote:

In src/librustc/middle/lint.rs:

@@ -1256,6 +1256,21 @@ pub fn check_crate(tcx: ty::ctxt,
v.visited_outermost = true;
visit::walk_crate(v, crate, ());
}
+

  •    // this basically duplicates check_missing_doc_attrs from
    
    above, minus the visibility test.
    +
  •    // If we're building a test harness, then warning about
    
  •    // documentation is probably not really relevant right
    
    now.
  •    if !cx.tcx.sess.opts.test {
    
  •        // `#[doc(hidden)]` disables missing_doc check.
    
  •        if !cx.is_doc_hidden {
    
  •            if !crate.attrs.iter().any(|a|
    
    a.node.is_sugared_doc) {

Hm, does this detect #[doc="foo"]?


Reply to this email directly or view it on
GitHubhttps://github.com//pull/10665/files#r7916305
.


Reply to this email directly or view it on GitHub:
https://github.com/mozilla/rust/pull/10665/files#r7916311

Because the root module isn't actually an item, we need to do some hackish
handling of it.

Closes #10656.
bors added a commit that referenced this pull request Dec 6, 2013
Because the root module isn't actually an item, we need to do some hackish
handling of it.

Closes #10656.
@bors bors closed this Dec 6, 2013
flip1995 pushed a commit to flip1995/rust that referenced this pull request May 5, 2023
…r=giraffate

Don't apply `string_lit_as_bytes` if in macro expansion

The following code will emit a warning on both w! and h!, despite there being nothing the user (or library author) could do about it:
```rust
#![warn(clippy::string_lit_as_bytes)]

use windows::w;
use windows::h;

fn main() {
    let _w = w!("example");
    let _h = h!("example");
}
```
This is because windows-rs will create a binding `const INPUT: &[u8] = $s.as_bytes()`, and changing this to b"$s" is, well, suboptimal. I don't know enough about Rust to know if this is something that can be detected though if it can be I'm happy with closing this in favor of implementing that.

I'm not sure whether this is how it should be done though, as this simply tells clippy to not invoke this even if it's applicable (this also affects the other string lints, but didn't cause any tests to fail).

changelog: [`string_lit_as_bytes`]: Don't lint if in external macro
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 this pull request may close these issues.

missing doc lint doesn't check crate doc
3 participants