Skip to content

Commit ce1eeb9

Browse files
committed
New anti-pattern: deny warnings
1 parent d827cec commit ce1eeb9

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ language.
5757
* TODO wildcard matches
5858
* TODO taking an enum rather than having multiple functions
5959
* TODO `unwrap()`ing every `Result` instead of forwarding it
60-
60+
* [`#![deny(warnings)]`}}(anti_patterns/deny-warnings.md)
6161

6262

6363
## Contributing

anti_patterns/deny-warnings.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# `#![deny(warnings)]`
2+
3+
## Description
4+
5+
A well-intentioned crate author wants to ensure their code builds without
6+
warnings. So they annotate their crate root with
7+
8+
## Example
9+
10+
```rust
11+
#![deny(warnings)]
12+
13+
// All is well.
14+
```
15+
16+
## Drawbacks
17+
18+
Until, say, the language changes, and as part of the transition, a lint is
19+
introduced that `warn`s, and Boom! The code no longer builds. Or someone tries
20+
to compile the code with additional lints (e.g. [clippy]), only to find out
21+
that they have to remove the annotation first.
22+
23+
## Alternatives
24+
25+
Our plucky developer hero should have used
26+
`RUSTFLAGS="-D warnings" cargo build"` to build their crate, removing
27+
the need for the annotation in their code.
28+
29+
## See also
30+
31+
- Type `rustc -W help` for a list of lints on your system. Also type
32+
`rustc --help` for a general list of options
33+
- [clippy] is a collection of lints for better Rust code
34+
35+
[clippy]: https://github.com/Manishearth/rust-clippy

0 commit comments

Comments
 (0)