Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow turning Cargo.toml warnings into errors #2568

Closed
deepak opened this issue Apr 13, 2016 · 4 comments
Closed

Allow turning Cargo.toml warnings into errors #2568

deepak opened this issue Apr 13, 2016 · 4 comments
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-enhancement Category: enhancement

Comments

@deepak
Copy link

deepak commented Apr 13, 2016

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

@alexcrichton alexcrichton added the A-new-subcommand Area: new subcommand label Apr 13, 2016
@alexcrichton
Copy link
Member

Sounds plausible to me! Right now we definitely don't indicate via the exit code anything about warnings, but we do so for errors! I'd be fine adding a dedicated command the specifically checked the syntax with perhaps more helpful error messages and more info communicated in the error code.

@epage
Copy link
Contributor

epage commented May 24, 2023

#12115 will unblock cargo having lint levels which would allow failing on different warnings

@epage epage changed the title Feature request: subcommand to lint format of Cargo file Allow turning Cargo.toml warnings into errors Sep 27, 2023
@epage epage added A-lints Area: rustc lint configuration C-enhancement Category: enhancement and removed A-new-subcommand Area: new subcommand labels Sep 27, 2023
@stinodego
Copy link

I would really love this option. As a maintainer of a big open source repository, PRs often get merged that introduce Cargo warnings like the one stated in this post. It's very annoying to have to go back and fix the issues each time. I'd like to be able to configure my CI to fail on Cargo warnings.

@epage
Copy link
Contributor

epage commented Oct 20, 2023

Lost track of this issue. We ended up creating #12235 which has more discussion, so I'm closing in favor of that other issue.

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Oct 20, 2023
@epage epage added A-diagnostics Area: Error and warning messages generated by Cargo itself. and removed A-lints Area: rustc lint configuration labels Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-enhancement Category: enhancement
Projects
None yet
Development

No branches or pull requests

4 participants