Skip to content

Doc links should count as a "use" with respect to the unused_imports lint #79542

Closed
@sfackler

Description

@sfackler
use std::collections::HashMap;

/// [`HashMap`]
pub fn foo() {}

Compiling this will warn about the HashMap import being unused, but it is required for the doc link to work. It would be nice if rustc handled this like Java's compiler does, where a doc link acts as a use of an import even when not building documentation. You can work around this with [HashMap](std::collections::HashMap) but long imports in the doc block can get a bit gross.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.E-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc 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