Skip to content

Properly handle feature-gated lints #72694

Closed
@LeSeulArtichaut

Description

@LeSeulArtichaut
Contributor

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.

Activity

added
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
C-cleanupCategory: PRs that clean code up or issues documenting cleanup.
on May 28, 2020
added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on May 28, 2020
nikomatsakis

nikomatsakis commented on May 28, 2020

@nikomatsakis
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.
added
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
on May 28, 2020
removed their assignment
on May 28, 2020
rajatppn

rajatppn commented on May 28, 2020

@rajatppn

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

LeSeulArtichaut

LeSeulArtichaut commented on May 28, 2020

@LeSeulArtichaut
ContributorAuthor

@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

LeSeulArtichaut commented on May 29, 2020

@LeSeulArtichaut
ContributorAuthor

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

OddCoincidence

OddCoincidence commented on May 30, 2020

@OddCoincidence
Contributor

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

carsonmyers

carsonmyers commented on Jun 3, 2020

@carsonmyers

I'm also interested, looking for a first ticket

6 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-cleanupCategory: PRs that clean code up or issues documenting cleanup.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @nikomatsakis@carsonmyers@rajatppn@JohnTitor@LeSeulArtichaut

    Issue actions

      Properly handle feature-gated lints · Issue #72694 · rust-lang/rust