Skip to content

Extend allow/warn/etc attributes to be applicable to individual use declarations #10534

Closed
@pnkfelix

Description

@pnkfelix

Right now, the allow/warn/deny/forbid attributes can only be applied to entire modules.

It would be nice to be able to apply the attributes to individual use declarations, to be able to say, e.g., "I know that this particular import is not currently used in the module, and I do not want to be warned about it; but I do not want to turn off warnings for other imports in the module."

Concrete example:

mod a { pub static x: int = 3; pub static y: int = 4; }

mod b {
    use a::x; // I want to be warned about this one ...
    #[allow(unused_imports)]
    use a::y; // ... but not about this one.
}

mod c {
    #[allow(unused_imports)];
    use a::x; // Insufficient because I get no warning about `x` here.
    use a::y;
}

fn main() {}

(Also, the fact that the syntax is currently accepted when applied to individual use declarations, as above, but seems to be a no-op, is probably also suboptimal. But of course, I would fix the problem by making it have an effect, as described by this ticket.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions