From 515847dad187c62701d77a9c368abe2d20e1d696 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Wed, 11 Mar 2020 06:35:07 +0900 Subject: [PATCH 1/2] Use `edition:2018` flag more widely --- tests/ui/doc_errors.rs | 2 +- tests/ui/issue_4266.rs | 2 +- tests/ui/macro_use_imports.rs | 2 +- tests/ui/methods.rs | 2 +- tests/ui/single_component_path_imports.fixed | 2 +- tests/ui/single_component_path_imports.rs | 2 +- tests/ui/use_self.fixed | 2 +- tests/ui/use_self.rs | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/ui/doc_errors.rs b/tests/ui/doc_errors.rs index 1401a658e03..445fc8d31d7 100644 --- a/tests/ui/doc_errors.rs +++ b/tests/ui/doc_errors.rs @@ -1,4 +1,4 @@ -// compile-flags: --edition 2018 +// edition:2018 #![warn(clippy::missing_errors_doc)] use std::io; diff --git a/tests/ui/issue_4266.rs b/tests/ui/issue_4266.rs index 1538abb1d77..8a9d5a3d1d5 100644 --- a/tests/ui/issue_4266.rs +++ b/tests/ui/issue_4266.rs @@ -1,4 +1,4 @@ -// compile-flags: --edition 2018 +// edition:2018 #![allow(dead_code)] async fn sink1<'a>(_: &'a str) {} // lint diff --git a/tests/ui/macro_use_imports.rs b/tests/ui/macro_use_imports.rs index 094dce17d4b..60c64ee8146 100644 --- a/tests/ui/macro_use_imports.rs +++ b/tests/ui/macro_use_imports.rs @@ -1,4 +1,4 @@ -// compile-flags: --edition 2018 +// edition:2018 #![warn(clippy::macro_use_imports)] use std::collections::HashMap; diff --git a/tests/ui/methods.rs b/tests/ui/methods.rs index bc448435829..2af33b26340 100644 --- a/tests/ui/methods.rs +++ b/tests/ui/methods.rs @@ -1,5 +1,5 @@ // aux-build:option_helpers.rs -// compile-flags: --edition 2018 +// edition:2018 #![warn(clippy::all, clippy::pedantic)] #![allow( diff --git a/tests/ui/single_component_path_imports.fixed b/tests/ui/single_component_path_imports.fixed index 9095069b093..a7a8499b58f 100644 --- a/tests/ui/single_component_path_imports.fixed +++ b/tests/ui/single_component_path_imports.fixed @@ -1,5 +1,5 @@ // run-rustfix -// compile-flags: --edition 2018 +// edition:2018 #![warn(clippy::single_component_path_imports)] #![allow(unused_imports)] diff --git a/tests/ui/single_component_path_imports.rs b/tests/ui/single_component_path_imports.rs index 1ebb3ee59b8..9a427e90ad3 100644 --- a/tests/ui/single_component_path_imports.rs +++ b/tests/ui/single_component_path_imports.rs @@ -1,5 +1,5 @@ // run-rustfix -// compile-flags: --edition 2018 +// edition:2018 #![warn(clippy::single_component_path_imports)] #![allow(unused_imports)] diff --git a/tests/ui/use_self.fixed b/tests/ui/use_self.fixed index 802de31b783..ebb3aa28daf 100644 --- a/tests/ui/use_self.fixed +++ b/tests/ui/use_self.fixed @@ -1,5 +1,5 @@ // run-rustfix -// compile-flags: --edition 2018 +// edition:2018 #![warn(clippy::use_self)] #![allow(dead_code)] diff --git a/tests/ui/use_self.rs b/tests/ui/use_self.rs index 605c4f8c41f..8a182192ab3 100644 --- a/tests/ui/use_self.rs +++ b/tests/ui/use_self.rs @@ -1,5 +1,5 @@ // run-rustfix -// compile-flags: --edition 2018 +// edition:2018 #![warn(clippy::use_self)] #![allow(dead_code)] From d4eb4968560456827e71cdf1a48b5a4585168ec5 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Wed, 11 Mar 2020 06:35:46 +0900 Subject: [PATCH 2/2] Improve documentation --- CONTRIBUTING.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b52266ac4f1..b1f9be44b73 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -54,7 +54,8 @@ and resolved paths. [`T-AST`] issues will generally need you to match against a predefined syntax structure. To figure out how this syntax structure is encoded in the AST, it is recommended to run `rustc -Z ast-json` on an example of the structure and compare with the [nodes in the AST docs]. -Usually the lint will end up to be a nested series of matches and ifs, [like so]. +Usually the lint will end up to be a nested series of matches and ifs, [like so][deep-nesting]. +But we can make it nest-less by using [if_chain] macro, [like this][nest-less]. [`E-medium`] issues are generally pretty easy too, though it's recommended you work on an E-easy issue first. They are mostly classified as [`E-medium`], since they might be somewhat involved code wise, @@ -71,7 +72,9 @@ an AST expression). `match_def_path()` in Clippy's `utils` module can also be us [`E-medium`]: https://github.com/rust-lang/rust-clippy/labels/E-medium [`ty`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty [nodes in the AST docs]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/ast/ -[like so]: https://github.com/rust-lang/rust-clippy/blob/de5ccdfab68a5e37689f3c950ed1532ba9d652a0/src/misc.rs#L34 +[deep-nesting]: https://github.com/rust-lang/rust-clippy/blob/557f6848bd5b7183f55c1e1522a326e9e1df6030/clippy_lints/src/mem_forget.rs#L29-L43 +[if_chain]: https://docs.rs/if_chain/*/if_chain +[nest-less]: https://github.com/rust-lang/rust-clippy/blob/557f6848bd5b7183f55c1e1522a326e9e1df6030/clippy_lints/src/bit_mask.rs#L124-L150 ## Writing code