Skip to content

E0583: Improve error message to help with use vs mod confusion #69492

Closed
@kornelski

Description

@kornelski

Feedback from a user forum thread. This code:

mod foo {
}

mod bar {
    mod foo;
}

currently suggests:

= help: name the file either foo.rs or foo/mod.rs inside the directory "src/bar"

This is awkwardly worded. It doesn't clearly explain that this syntax creates a new module. It doesn't guess that the user may have meant use crate::foo.

I suggest:

  1. Improve wording of the message. "To create a new module crate::bar::foo, create "src/bar/foo.rs" file" (to keep it simple, without also suggesting 2015-edition path).

  2. If there already is a module with that name, suggest use instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.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