Skip to content

Warn or error on multiple-mod code duplication #5765

Closed
@Kimundi

Description

@Kimundi

Sometimes people use multiple mod statements that refer to the same file in order to access that files content as a module in different modules/files, thinking all those instances would be identical. But in reality that just duplicates all definitions in the file at different places in the module hierarchy, which leads to confusing errors like two presumably identical types not being identical etc.

I think two mod statements in a crate that refer to the same file should at least emit a code duplication warning, if not an error, because it's almost never what you want.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-resolveArea: Name/path resolution done by `rustc_resolve` specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions