Skip to content

Commit 5da9e0b

Browse files
authored
Merge pull request #446 from Manishearth/tool-attrs
Mention tool lint attributes
2 parents d39911d + 277b344 commit 5da9e0b

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/attributes.md

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

360+
#### Tool lint attributes
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+
372+
```rust,ignore
373+
// set the entire `pedantic` clippy lint group to warn
374+
#![warn(clippy::pedantic)]
375+
// silence warnings from the `filter_map` clippy lint
376+
#![allow(clippy::filter_map)]
377+
378+
fn main() {
379+
// ...
380+
}
381+
382+
// silence the `cmp_nan` clippy lint just for this function
383+
#[allow(clippy::cmp_nan)]
384+
fn foo() {
385+
// ...
386+
}
387+
```
388+
360389
#### `must_use`
361390

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

0 commit comments

Comments
 (0)