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

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    P-lowLow priority
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    D-papercutDiagnostics: An error or lint that needs small tweaks.
    on Jul 18, 2026
  2. added
    A-CLIArea: Command-line interface (CLI) to the compiler
    on Jul 18, 2026
  3. added a commit that references this issue on Jul 20, 2026
    531ddf3
  4. added a commit that references this issue on Jul 20, 2026
    19d68d0
  5. added a commit that references this issue on Aug 17, 2026
    6e9d3cb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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