Skip to content

Invalid --crate-name should suggest a valid identifier #159485

Description

@estebank

Code

//@ compile-flags: --crate-name=my-crate
//~? ERROR invalid character '-' in crate name

fn main() {}

Current output

error: invalid character '-' in crate name: `my-crate`

Desired output

error: invalid character '-' in crate name: `my-crate`
 |
 = note: crate names must be a valid Rust identifier, so they can't have a `-` in them
 = help: you might have meant to use `--crate-name=my_crate`

Rationale and extra context

We already check for this in the parser, we should also account for it in the CLI.

Other cases

Rust Version

1.97

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-CLIArea: Command-line interface (CLI) to the compilerA-diagnosticsArea: Messages for errors, warnings, and lintsD-papercutDiagnostics: An error or lint that needs small tweaks.P-lowLow priorityT-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