Skip to content

Invalid crate type should helpfully suggest valid crate type #53958

Closed
@Havvy

Description

@Havvy

Errornous code: Yes, it's only a single line

#![crate_type = "proc_macro"]

Current output:

   Compiling playground v0.0.1 (file:///playground)
error: invalid `crate_type` value
 --> src/lib.rs:1:1
  |
1 | #![crate_type = "proc_macro"]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: #[deny(unknown_crate_types)] on by default

error: aborting due to previous error

error: Could not compile `playground`.

Expected:

   Compiling playground v0.0.1 (file:///playground)
error: invalid `crate_type` value
 --> src/lib.rs:1:1
  |
1 | #![crate_type = "proc_macro"]
  |                 ^^^^^^^^^^^^ did you mean "proc-macro"?
  |
  = note: #[deny(unknown_crate_types)] on by default

error: aborting due to previous error

error: Could not compile `playground`.

The change here is that the error is on the value of the attribute and it asks the "did you mean" question that you get when you mistype a variable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions