Skip to content

Allow turning Cargo.toml warnings into errors #2568

@deepak

Description

@deepak

subcommand to lint format of Cargo file
and an option for all commands to fail early if format is invalid

I have not found an actual usecase to justify this
but have been learning rust and maybe this will be useful for noobs to double-check

the smallest valid Cargo.toml file is

[package]

name = "hello_world"
version = "0.0.1"
authors = [ "name <email@example.com>" ]

now let us say we leave out the name.
cargo build will throw an error

failed to parse manifest at `/src/hello-rust/Cargo.toml`

Caused by:
  expected a value of type `string` for the key `package.name`

will throw a warning for unused keys as well

[package]

name = "hello_world"
version = "0.0.1"
users = [ "name <email@example.com>" ]

warning "unused manifest key: package.users"

but exit status is zero and everything works

also no error is thrown for an unused section. example:

[package]

name = "hello_world"
version = "0.0.1"
authors = [ "Deepak Kannan <kannan.deepak@gmail.com>" ]

[dependency]

should have been dependencies rather than dependency above

PS: I have been using cargo build for all these examples.
but am not sure, if the config is checked for unused params by each sub-command

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Error and warning messages generated by Cargo itself.C-enhancementCategory: enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions