From a9634fcd013a31842e551ba30c25e389a5d67bbd Mon Sep 17 00:00:00 2001 From: flip1995 <9744647+flip1995@users.noreply.github.com> Date: Tue, 3 Jul 2018 13:52:11 +0200 Subject: [PATCH] Unstable book documentation of tool lints --- .../src/language-features/tool-lints.md | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/doc/unstable-book/src/language-features/tool-lints.md diff --git a/src/doc/unstable-book/src/language-features/tool-lints.md b/src/doc/unstable-book/src/language-features/tool-lints.md new file mode 100644 index 000000000000..5c0d33b5ab0c --- /dev/null +++ b/src/doc/unstable-book/src/language-features/tool-lints.md @@ -0,0 +1,35 @@ +# `tool_lints` + +The tracking issue for this feature is: [#44690] + +[#44690]: https://github.com/rust-lang/rust/issues/44690 + +------------------------ + +Tool lints let you use scoped lints, to `allow`, `warn`, `deny` or `forbid` lints of +certain tools. + +Currently `clippy` is the only available lint tool. + +It is recommended for lint tools to implement the scoped lints like this: + +- `#[_(TOOL_NAME::lintname)]`: for lint names +- `#[_(TOOL_NAME::lintgroup)]`: for groups of lints +- `#[_(TOOL_NAME::all)]`: for (almost[^1]) all lints + +## An example + +```rust +#![feature(tool_lints)] + +#![warn(clippy::pedantic)] + +#[allow(clippy::filter_map)] +fn main() { + let v = vec![0; 10]; + let _ = v.into_iter().filter(|&x| x < 1).map(|x| x + 1).collect::>(); + println!("No filter_map()!"); +} +``` + +[^1]: Some defined lint groups can be excluded here.