Skip to content

Lint attributes on function args have no effect #61238

Closed
@oli-obk

Description

@oli-obk

In order for the lint attributes to actually have an effect, we need to change ast::visit and hir::intravisit significantly before even being able to adjust LateLintPass and EarlyLintPass to handle the attributes.

The current schemes for iterating over the pattern of the argument and the type of the argument vary significantly between functions, methods extern functions, closures, .... I'm not sure if they can be unified easily, since extern functions don't allow patterns as arguments, but I think there should be a visit_argument method which all of the sites should call. In case attributes aren't allowed in extern functions, this should be possible, otherwise we'll have to figure out something.

After that, the *LintPass traits need a new check_argument method, too and before invocing said method, a with_lint_attrs call needs to be nested around the check_argument and walk_argument method calls.

Originally posted by @oli-obk in #60669 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.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

    No branches or pull requests

    Issue actions