From 8cd2008a8a468970a48381d10949c28d5c068891 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Wed, 30 May 2018 18:24:44 +0200 Subject: [PATCH] Replace cfg_attr(rustfmt... thingies --- clippy_lints/src/lib.rs | 1 + clippy_lints/src/loops.rs | 2 +- clippy_lints/src/matches.rs | 2 +- clippy_lints/src/methods.rs | 6 +++--- clippy_lints/src/non_expressive_names.rs | 2 +- tests/needless_continue_helpers.rs | 12 +++++++----- tests/trim_multiline.rs | 6 ++++-- 7 files changed, 18 insertions(+), 13 deletions(-) diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index f6a5559c3650..0a4858077581 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -11,6 +11,7 @@ #![allow(stable_features)] #![feature(iterator_find_map)] #![feature(macro_at_most_once_rep)] +#![feature(tool_attributes)] #![feature(rust_2018_preview)] extern crate cargo_metadata; diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 4d312b798183..fbe4eedcf346 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -1778,7 +1778,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarUsedAfterLoopVisitor<'a, 'tcx> { /// Return true if the type of expr is one that provides `IntoIterator` impls /// for `&T` and `&mut T`, such as `Vec`. -#[cfg_attr(rustfmt, rustfmt_skip)] +#[rustfmt::skip] fn is_ref_iterable_type(cx: &LateContext, e: &Expr) -> bool { // no walk_ptrs_ty: calling iter() on a reference can make sense because it // will allow further borrows afterwards diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index 8ab0482bacfd..bd8078c4a8c1 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -197,7 +197,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MatchPass { } } -#[cfg_attr(rustfmt, rustfmt_skip)] +#[rustfmt::skip] fn check_single_match(cx: &LateContext, ex: &Expr, arms: &[Arm], expr: &Expr) { if arms.len() == 2 && arms[0].pats.len() == 1 && arms[0].guard.is_none() && diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index 461efb27f280..7f91d6ca5027 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -1821,7 +1821,7 @@ enum Convention { StartsWith(&'static str), } -#[cfg_attr(rustfmt, rustfmt_skip)] +#[rustfmt::skip] const CONVENTIONS: [(Convention, &[SelfKind]); 6] = [ (Convention::Eq("new"), &[SelfKind::No]), (Convention::StartsWith("as_"), &[SelfKind::Ref, SelfKind::RefMut]), @@ -1831,7 +1831,7 @@ const CONVENTIONS: [(Convention, &[SelfKind]); 6] = [ (Convention::StartsWith("to_"), &[SelfKind::Ref]), ]; -#[cfg_attr(rustfmt, rustfmt_skip)] +#[rustfmt::skip] const TRAIT_METHODS: [(&str, usize, SelfKind, OutType, &str); 30] = [ ("add", 2, SelfKind::Value, OutType::Any, "std::ops::Add"), ("as_mut", 1, SelfKind::RefMut, OutType::Ref, "std::convert::AsMut"), @@ -1865,7 +1865,7 @@ const TRAIT_METHODS: [(&str, usize, SelfKind, OutType, &str); 30] = [ ("sub", 2, SelfKind::Value, OutType::Any, "std::ops::Sub"), ]; -#[cfg_attr(rustfmt, rustfmt_skip)] +#[rustfmt::skip] const PATTERN_METHODS: [(&str, usize); 17] = [ ("contains", 1), ("starts_with", 1), diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index 69a02b0c50d5..a94175da5d9a 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -88,7 +88,7 @@ struct SimilarNamesLocalVisitor<'a, 'tcx: 'a> { // this list contains lists of names that are allowed to be similar // the assumption is that no name is ever contained in multiple lists. -#[cfg_attr(rustfmt, rustfmt_skip)] +#[rustfmt::skip] const WHITELIST: &[&[&str]] = &[ &["parsed", "parser"], &["lhs", "rhs"], diff --git a/tests/needless_continue_helpers.rs b/tests/needless_continue_helpers.rs index 588dc741d03c..f608ef1ad021 100644 --- a/tests/needless_continue_helpers.rs +++ b/tests/needless_continue_helpers.rs @@ -1,3 +1,5 @@ +#![feature(tool_attributes)] + // Tests for the various helper functions used by the needless_continue // lint that don't belong in utils. @@ -5,7 +7,7 @@ extern crate clippy_lints; use clippy_lints::needless_continue::{erode_block, erode_from_back, erode_from_front}; #[test] -#[cfg_attr(rustfmt, rustfmt_skip)] +#[rustfmt::skip] fn test_erode_from_back() { let input = "\ { @@ -23,7 +25,7 @@ fn test_erode_from_back() { } #[test] -#[cfg_attr(rustfmt, rustfmt_skip)] +#[rustfmt::skip] fn test_erode_from_back_no_brace() { let input = "\ let x = 5; @@ -35,7 +37,7 @@ let y = something(); } #[test] -#[cfg_attr(rustfmt, rustfmt_skip)] +#[rustfmt::skip] fn test_erode_from_front() { let input = " { @@ -54,7 +56,7 @@ fn test_erode_from_front() { } #[test] -#[cfg_attr(rustfmt, rustfmt_skip)] +#[rustfmt::skip] fn test_erode_from_front_no_brace() { let input = " something(); @@ -70,7 +72,7 @@ fn test_erode_from_front_no_brace() { } #[test] -#[cfg_attr(rustfmt, rustfmt_skip)] +#[rustfmt::skip] fn test_erode_block() { let input = " diff --git a/tests/trim_multiline.rs b/tests/trim_multiline.rs index d6de36bfca73..a61eee409287 100644 --- a/tests/trim_multiline.rs +++ b/tests/trim_multiline.rs @@ -1,3 +1,5 @@ +#![feature(tool_attributes)] + /// test the multiline-trim function extern crate clippy_lints; @@ -13,7 +15,7 @@ fn test_single_line() { } #[test] -#[cfg_attr(rustfmt, rustfmt_skip)] +#[rustfmt::skip] fn test_block() { assert_eq!("\ if x { @@ -38,7 +40,7 @@ if x { } #[test] -#[cfg_attr(rustfmt, rustfmt_skip)] +#[rustfmt::skip] fn test_empty_line() { assert_eq!("\ if x {