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

pub with macro 2.0 breaks docs #45266

Closed
valff opened this issue Oct 13, 2017 · 5 comments
Closed

pub with macro 2.0 breaks docs #45266

valff opened this issue Oct 13, 2017 · 5 comments
Assignees
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-macros-2.0 Area: Declarative macros 2.0 (#39412) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@valff
Copy link
Contributor

valff commented Oct 13, 2017

Using pub qualifier with declarative macros 2.0 breaks the missing_docs lint for private items, as well as exposes them with rustdoc.

The following code shouldn't produce warnings (playground):

//! ...
#![feature(decl_macro)]
#![warn(missing_docs)]

/// ...
pub mod foo {
  // Try to comment out the macro, and warnings will be disappeared.
  pub macro bar() { println!("bar"); }
  
  #[allow(dead_code)]
  fn baz() {}
}

fn main() {}

rustc --version --verbose:

rustc 1.22.0-nightly (dcbbfb6e8 2017-10-12)
binary: rustc
commit-hash: dcbbfb6e807fdff9c9ba80073bb755f9d9d95e31
commit-date: 2017-10-12
host: x86_64-unknown-linux-gnu
release: 1.22.0-nightly
LLVM version: 4.0
@kennytm kennytm added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-macros-2.0 Area: Declarative macros 2.0 (#39412) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 13, 2017
@petrochenkov
Copy link
Contributor

petrochenkov commented Oct 13, 2017

The reason is that everything reachable from a public macro 2.0 is currently very pessimistically marked as reachable from the outer world (this affects linking in the first place, but also lints like missing docs, missing Copy/Debug impls, etc).

The solution could be to mark as reachable only items actually leaked by the macro (this can be hard), or to introduce one more gradation of reachability and suppress lints for it.

@jseyfried jseyfried self-assigned this Dec 1, 2017
@matthewjasper matthewjasper added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Sep 15, 2019
@matthewjasper
Copy link
Contributor

This appears to have been fixed by #63114

@workingjubilee
Copy link
Member

Appears to still emit warnings in playground as of Now, not fixed?

@beepster4096
Copy link
Contributor

Right now, it works without errors

@valff
Copy link
Contributor Author

valff commented Feb 22, 2021

It's fixed now, thanks! The current warning is legitimate and unrelated to the issue.

@valff valff closed this as completed Feb 22, 2021
@fmease fmease added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. and removed A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. labels Dec 21, 2024
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. A-macros-2.0 Area: Declarative macros 2.0 (#39412) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. 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

8 participants