Skip to content

Commit afeeaab

Browse files
committed
Mention tool lint attributes
1 parent 084fa05 commit afeeaab

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/attributes.md

+28
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,34 @@ pub mod m3 {
357357
}
358358
```
359359

360+
#### Tool lint attributes (`#[allow(clippy::foo)]`)
361+
362+
Tool lints let you use scoped lints, to `allow`, `warn`, `deny` or `forbid` lints of
363+
certain tools.
364+
365+
Currently `clippy` is the only available lint tool.
366+
367+
They only get checked when the associated tool is active, so if you try to use an `allow` attribute for a nonexistant tool lint, the compiler will not warn about the nonexistant lint until you use the tool.
368+
369+
Otherwise, they work just like regular lint attributes:
370+
371+
```rust
372+
// set the entire `pedantic` clippy lint group to warn
373+
#![warn(clippy::pedantic)]
374+
// silence warnings from the `filter_map` clippy lint
375+
#![allow(clippy::filter_map)]
376+
377+
fn main() {
378+
// ...
379+
}
380+
381+
// silence the `cmp_nan` clippy lint just for this function
382+
#[allow(clippy::cmp_nan)]
383+
fn foo() {
384+
// ...
385+
}
386+
```
387+
360388
#### `must_use`
361389

362390
The `must_use` attribute can be used on user-defined composite types

0 commit comments

Comments
 (0)