Skip to content

Rustc does not parse tool name for lints controlled by the command line #86628

Closed
@eholk

Description

@eholk
Contributor

Problem

This came up during the discussion of rust-lang/cargo#5034. Lints can be broken into rustc builtin lints, and lints supplied by a tool such as clippy. For clippy lints, they are prefixed by clippy::. The idea is that external lints are supposed to be ignored if the tool is not active. This works for lints controlled through attributes, such as #![allow(clippy::foo)].

Unfortunately the same thing doesn't work when allowing the lint through the command line, doing rustc -A clippy::foo.

Steps

  1. Run rustc -A clippy::foo test.rs

Possible Solution(s)

The problem is at:

let db = match self.check_lint_name(lint_name, None) {

There is a hard-coded None passed in as the tool name in check_lint_name.

Activity

eholk

eholk commented on Jun 25, 2021

@eholk
ContributorAuthor

I'm working on a fix at https://github.com/eholk/rust/tree/lint-tool. The fix there so far is doing an ad-hoc parsing, although it seems like it'd be better to reuse the rustc parser for paths, since that is how the attribute version is parsed. I'm going to clean it up some more, make sure to add tests, etc. before filing an PR.

eholk

eholk commented on Jun 25, 2021

@eholk
ContributorAuthor

@rustbot claim

inquisitivecrystal

inquisitivecrystal commented on Jun 28, 2021

@inquisitivecrystal
Contributor

@rustbot label A-lint T-compiler

added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
on Jun 28, 2021
added 2 commits that reference this issue on Jul 7, 2021

Rollup merge of rust-lang#86639 - eholk:lint-tool, r=petrochenkov

424498c

Rollup merge of rust-lang#86639 - eholk:lint-tool, r=petrochenkov

c2d3f5f
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-bugCategory: This is a bug.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

    @eholk@inquisitivecrystal@rustbot

    Issue actions

      Rustc does not parse tool name for lints controlled by the command line · Issue #86628 · rust-lang/rust