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

Add warning checks to the complete template #19

Open
epage opened this issue Jul 13, 2019 · 5 comments
Open

Add warning checks to the complete template #19

epage opened this issue Jul 13, 2019 · 5 comments
Labels
enhancement New feature or request

Comments

@epage
Copy link
Contributor

epage commented Jul 13, 2019

Doing a cargo check with RUSTFLAGS="-D warnings" will fail the build on warnings.

The problems is new warnings can be added and break the build, so like clippy in #18, we should use a pinned version of rustc.

@epage epage added the enhancement New feature or request label Jul 13, 2019
@jonhoo
Copy link
Collaborator

jonhoo commented Jul 15, 2019

I'm personally strongly against making warnings errors. It means that, for example, a minor version release for a dependency that deprecates a method can cause your build to fail, even though the version bump was semver compatible. If authors specifically want no warnings, they should opt into that with

#![deny(warnings)]

in their src/lib.rs (or equivalent)

@epage
Copy link
Contributor Author

epage commented Jul 15, 2019

I'm strongly in favor of turning warnings into errors :)

  • Dependency warnings do not break your build.
    • However, Macros from dependencies can. There was a time that clap broke people.
  • Deprecation warnings from using a new rustc will also not break your build unless you opt-in to it that warning doing so
  • Warnings are just as valuable as clippy. If we have one, we should have the other.
  • #![deny(warnings)] is an anti-pattern that causes problems.
    • You cannot pin your Rust version causing you to be subject to breakage as new warnings are added.
    • It also impairs development iteration where warnings can be minor while you don't want them in master.

@jonhoo
Copy link
Collaborator

jonhoo commented Jul 15, 2019

Warnings as errors breaks safe semver updates, which is a deal-breaker for me (the example of dependency deprecations being one example, macros as you mention being another).

I'm not sure I know about the flag you mention so that new stable releases don't break your build with -D warnings?

I completely agree with you that your code should compile without warnings. The problem is that new warnings can appear without your code changing. For example, as discussed in another issue, this could absolutely cause a new contributor to see red CI unrelated to their current changes, such as if Cargo.lock is not checked in and CI uses a later minor version of a dependency that deprecates a method.

This all said, I think it might be okay to include a deny_warnings: true parameter to the cargo-check template (and thus also to stages) for people to opt in to it. I definitely think it should be false by default though.

@epage
Copy link
Contributor Author

epage commented Jul 16, 2019

So I've never run into a dependency deprecating something, only stdlib which has been handled by warning on MSRV only.

A way of handling this is by instead doing

RUSTFLAGS="-D warnings -A deprecated"

Outside of macros, deprecated is the only way I know of for a dependency to break you via warnings, so I think this should be sufficient.

@jonhoo
Copy link
Collaborator

jonhoo commented Jul 16, 2019

fwiw, #33 mostly addresses this by running a stage that treats all warnings as errors (including deprecations), but treat them as allowed failures (so they'll show up as yellow CI). I think that's a reasonable compromise?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants