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

Properly handle feature-gated lints #72694

Closed
LeSeulArtichaut opened this issue May 28, 2020 · 7 comments · Fixed by #72970
Closed

Properly handle feature-gated lints #72694

LeSeulArtichaut opened this issue May 28, 2020 · 7 comments · Fixed by #72970
Assignees
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@LeSeulArtichaut
Copy link
Contributor

LeSeulArtichaut commented May 28, 2020

At the moment, the unsafe_op_in_unsafe_fn lint is the only feature-gated lint. However, feature-gate checks are hard-coded for this lint. If more feature gated lints are be added in the future, having proper handling for feature-gated lint will be useful.

Here is a suggested implementation plan:

  • Add a feature_gate field of type Option<Symbol> for the rustc_session::lint::Lint struct, which has a Some value if the lint is feature-gated, None otherwise.
  • Tweak the rustc_session::declare_lint! macro to allow specifying the feature gate when applicable, akin to future_incompatible.
  • When registering lints on the command line or for attributes, check if they are feature gated, and report errors accordingly. Basically, re-writing check_gated_link should be enough.
  • As rustdoc allows all lints as if they were passed on the command line, prevent rustdoc from allowing feature gated lints.

This issue has been assigned to @OddCoincidence via this comment.

@LeSeulArtichaut LeSeulArtichaut added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-cleanup Category: PRs that clean code up or issues documenting cleanup. labels May 28, 2020
@LeSeulArtichaut LeSeulArtichaut self-assigned this May 28, 2020
@JohnTitor JohnTitor added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 28, 2020
@nikomatsakis
Copy link
Contributor

This implementation plan looks good to me -- if you think @LeSeulArtichaut that you'd like to mentor the issue, maybe tag it with E-easy and E-mentor! I'd probably extend the description above with

  • some links into the code to help people find the functions in question
  • a reference to your existing hard-coded support for unsafe_op_in_unsafe_fn lint, which I think is basically the model that we want to follow.

@LeSeulArtichaut LeSeulArtichaut added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels May 28, 2020
@LeSeulArtichaut LeSeulArtichaut removed their assignment May 28, 2020
@rajatppn
Copy link

Hi, I would like to take this up if possible. I'm new to contributing to rust

@LeSeulArtichaut
Copy link
Contributor Author

@rajatppn That's great! I edited the original post to give you links to the code you'll need to edit. I'd recommand that you base your work on #71862 so that you can immediately make changes for unsafe_op_in_unsafe_fn and use that as a test.

@LeSeulArtichaut
Copy link
Contributor Author

Also, to show that you're working on an issue, you can send @rustbot claim, which will assign the issue to you.

@OddCoincidence
Copy link
Contributor

@rajatppn Are you still working on this? If not, I'd like to claim it.

@carsonmyers
Copy link

I'm also interested, looking for a first ticket

@LeSeulArtichaut
Copy link
Contributor Author

I'll assign this to @OddCoincidence (who opened a PR) for triage purposes.
@rustbot assign @OddCoincidence

@carsonmyers Good luck on finding a first issue! If you don't find anything, you can probably go in the Rust Zulip instance and ask for issues, @DPC will probably happily to find you one 😄

@rustbot rustbot self-assigned this Jun 4, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Jun 6, 2020
… r=petrochenkov

Properly handle feature-gated lints

Closes rust-lang#72694
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Jun 6, 2020
… r=petrochenkov

Properly handle feature-gated lints

Closes rust-lang#72694
@bors bors closed this as completed in 1ff0ba0 Jun 7, 2020
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-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants