Skip to content

Improve error reporting for #![feature(...)] in the wrong place #81370

Closed
@martindemello

Description

@martindemello

I spent a while wondering why I was getting this error

error[E0658]: use of unstable library feature 'array_map'
  --> src/board.rs:67:17
   |
67 |         offsets.map(|(dx, dy)| {
   |                 ^^^
   |
   = note: see issue #75243 <https://github.com/rust-lang/rust/issues/75243> for more information
   = help: add `#![feature(array_map)]` to the crate attributes to enable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.

even when I added !#[feature(array_map)] to the top of my file, and even when the same thing was working fine in main.rs. I finally found this stackoverflow post and this reddit thread that said if I were using cargo build I had to add the directive to lib.rs instead, after which everything worked.

I'm not sure where in the docs the best place for that would be (I had already read the section on attributes and crates in "rust by example" and not found the relevant hint), but it would be nice if it could be surfaced in the error message too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-confusingDiagnostics: Confusing error or lint that should be reworked.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.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