Skip to content

Unhelpful error when Cargo.toml is missing edition key. #92422

Open
@jonhoo

Description

@jonhoo

Given the following code:

# Cargo.toml
[package]
name = "no-edition-diagnostics"
version = "0.1.0"
# note the lack of edition = ""

[dependencies]
anyhow = "1"
// src/lib.rs
use anyhow::*;

The current output is:

error[E0432]: unresolved import `anyhow`
 --> src/lib.rs:1:5
  |
1 | use anyhow::*;
  |     ^^^^^^ maybe a missing crate `anyhow`?

Ideally the output should look like:

error[E0432]: unresolved import `anyhow`
 --> src/lib.rs:1:5
  |
1 | use anyhow::*;
  |     ^^^^^^ maybe a missing crate `anyhow`?
               hint: try adding an `extern crate` or move to a newer Rust edition

Since the solution for this case is generally going to be one of those two.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyD-editionDiagnostics: An error or lint that should account for edition differences.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