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

Disallow build warnings for Rust #4703

Merged
merged 4 commits into from
Apr 22, 2024
Merged

Disallow build warnings for Rust #4703

merged 4 commits into from
Apr 22, 2024

Conversation

dskloetd
Copy link
Contributor

@dskloetd dskloetd commented Apr 9, 2024

Motivation

Build warnings are distracting and confusing.

There is one type of build warning that can start appearing without any changes in the code: future incompatibility.
When there is a breaking change in a future version of a dependency, this will start causing build warnings without changes in the repository. We need to disable these warning in order to safely disallow any build warnings in Rust and prevent the introduction of new warnings.

Changes

  1. Add RUSTFLAGS="-D warnings" in front of cargo test in CI to disallow build warning.
  2. Disable the "future incompatibility" warning by adding a config.toml file.
  3. Fix a warning by removing unused use candid::types::number; from rs/backend/src/accounts_store/schema/proxy/tests.rs.
  4. Fix a warning by removing unused schema_label from rs/backend/src/state/partitions.rs

Tests

CI passes

Todos

  • Add entry to changelog (if necessary).

@dskloetd dskloetd marked this pull request as ready for review April 9, 2024 14:23
@dskloetd dskloetd requested a review from a team as a code owner April 9, 2024 14:23
bitdivine
bitdivine previously approved these changes Apr 10, 2024
Copy link
Member

@bitdivine bitdivine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that rust warns if a crate has breaking changes in a future version of Rust, even if that future version is not being used. That means that code that compiles with no warnings one day can issue warnings the next.

It is nice to get rid of warnings and the cleanup is legitimate and appreciated, but be aware that with this flag set you may get CI breaking suddenly without warning if you do this.... which is why it is not done yet. It's up to you.

Yes, I have had sealed docker builds, meant to produce the same artefacts for the next 20 years, break suddenly because of this :-D One needs to pull out the network cable, so to speak.

@dskloetd
Copy link
Contributor Author

Thanks for the heads up! I'll have to think about this. Is it not possible to disable that behavior?

@dskloetd
Copy link
Contributor Author

Looks like there is a way to disable it:
https://doc.rust-lang.org/cargo/reference/future-incompat-report.html#configuration

So the decision is whether we value not having warnings or knowing about future breakages.

@bitdivine
Copy link
Member

bitdivine commented Apr 10, 2024

Yes, as linked, and as you found. :-) IMO it would have been better if they had made it possible to make that an info rather than a warning. First world problems...

Copy link
Contributor

@mstrasinskis mstrasinskis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rubber stamp, thanks!

@dskloetd dskloetd added this pull request to the merge queue Apr 22, 2024
Merged via the queue into main with commit 3f00741 Apr 22, 2024
51 checks passed
@dskloetd dskloetd deleted the kloet/no-rust-warnings branch April 22, 2024 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants