Skip to content

Invalid crate type should helpfully suggest valid crate type #53958

Closed

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.

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    on Sep 5, 2018
  2. phansch commented on Sep 5, 2018

    @phansch
    Contributor

    I would like to work on this.

    From a first look, I would re-use

    pub fn find_best_match_for_name<'a, T>(iter_names: T,

    somewhere around here:

    session.buffer_lint(
    lint::builtin::UNKNOWN_CRATE_TYPES,
    ast::CRATE_NODE_ID,
    a.span,
    "invalid `crate_type` value",
    );

  3. added a commit that references this issue on Sep 14, 2018
    d51c364
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-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