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

cannot use #![deny(missing_docs)] with external derive macro #78490

Open
EverlastingBugstopper opened this issue Oct 28, 2020 · 4 comments
Open
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@EverlastingBugstopper
Copy link

I tried this code (graphql_client v0.9)

use graphql_client::*;

#[derive(GraphQLQuery)]
#[graphql(
    query_path = "src/query/schema/get.graphql",
    schema_path = "schema.graphql",
    response_derives = "PartialEq, Debug, Serialize, Deserialize",
    deprecated = "warn"
)]
/// Documentation for this struct
pub struct GetSchemaQuery;

I expected to see a successful build.

Instead, the build failed and complained about missing docs for a struct that originated in a derive macro.

Full build output

$ RUST_BACKTRACE=1 cargo build --package rover-client
   Compiling rover-client v0.0.0 (/home/avery/Documents/work/rover/crates/rover-client)
error: missing documentation for a module
 --> crates/rover-client/src/query/schema/get.rs:9:10
  |
9 | #[derive(GraphQLQuery)]
  |          ^^^^^^^^^^^^
  |
note: the lint level is defined here
 --> crates/rover-client/src/lib.rs:1:9
  |
1 | #![deny(missing_docs)]
  |         ^^^^^^^^^^^^
  = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: missing documentation for a constant
 --> crates/rover-client/src/query/schema/get.rs:9:10
  |
9 | #[derive(GraphQLQuery)]
  |          ^^^^^^^^^^^^
  |
  = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: missing documentation for a struct
 --> crates/rover-client/src/query/schema/get.rs:9:10
  |
9 | #[derive(GraphQLQuery)]
  |          ^^^^^^^^^^^^
  |
  = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: missing documentation for a struct field
 --> crates/rover-client/src/query/schema/get.rs:9:10
  |
9 | #[derive(GraphQLQuery)]
  |          ^^^^^^^^^^^^
  |
  = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 4 previous errors

error: could not compile `rover-client`.

To learn more, run the command again with --verbose.

@jyn514
Copy link
Member

jyn514 commented Oct 28, 2020

@EverlastingBugstopper that seems like expected behavior. If your proc-macro generates a struct you don't want to be linted, you can add allow(missing_docs) in the proc-macro.

@jyn514 jyn514 added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 28, 2020
@EverlastingBugstopper
Copy link
Author

EverlastingBugstopper commented Oct 28, 2020

What would that look like? The proc macro is not owned by me and is brought in by a dependency. I am documenting the struct here with my own note "Documentation for this struct" but I guess it isn't recognized? Perhaps this is just a misunderstanding on my part as to what the macro itself is actually doing under the hood.

edit: if i try this code i still get the compilation error

use graphql_client::*;

#[allow(missing_docs)]
#[derive(GraphQLQuery)]
#[graphql(
    query_path = "src/query/schema/get.graphql",
    schema_path = "schema.graphql",
    response_derives = "PartialEq, Debug, Serialize, Deserialize",
    deprecated = "warn"
)]
/// Documentation for this struct
pub struct GetSchemaQuery;

@jyn514
Copy link
Member

jyn514 commented Oct 28, 2020

I think this is a bug with the author of the proc-macro, really. I guess you could make a case for silencing all warnings from items generated by a proc-macro? Not sure how that would work.

@EverlastingBugstopper
Copy link
Author

yeah i would just assume that the lint would only apply to the code that i write and not the code that is in a dependency (even if that dependency technically generates code in my codebase). maybe that was an explicit decision but it seems like a bug from my point of view.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants