Skip to content

Suggest workspace shorthands for boolean dependencie #15505

@borngraced

Description

@borngraced

Error complains about a boolean but only mentions version strings or tables with version = "x.y.z" when you accidentally write:

[dependencies]
crc32fast = true

Cargo reports:

invalid type: boolean `true`, expected a version string like "0.9.8"
or a detailed dependency like { version = "0.9.8" }
in `dependencies.crc32fast`

It would be more helpful if the error message also suggested the workspace shorthand. Both of these are valid ways to pull from your workspace

crc32fast = { workspace = true }
crc32fast.workspace = true

Proposed behavior:

When a boolean is found, append a note pointing out the two valid workspace forms

invalid type: boolean `true`, expected a version string like "0.9.8"
or a detailed dependency like { version = "0.9.8" }
in `dependencies.crc32fast`.

if you meant to use a workspace member, you can write
  crc32fast = { workspace = true }
or
  crc32fast.workspace = true

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-crate-dependenciesArea: [dependencies] of any kindA-diagnosticsArea: Error and warning messages generated by Cargo itself.A-manifestArea: Cargo.toml issuesA-workspace-inheritanceArea: workspace inheritance RFC 2906C-enhancementCategory: enhancementS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions