diff --git a/clippy_lints/src/lib.register_all.rs b/clippy_lints/src/lib.register_all.rs index 0c6d01083c5..4691f957cb4 100644 --- a/clippy_lints/src/lib.register_all.rs +++ b/clippy_lints/src/lib.register_all.rs @@ -242,7 +242,7 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![ LintId::of(needless_bool::NEEDLESS_BOOL), LintId::of(needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE), LintId::of(needless_late_init::NEEDLESS_LATE_INIT), - LintId::of(needless_parens_on_range_literal::NEEDLESS_PARENS_ON_RANGE_LITERAL), + LintId::of(needless_parens_on_range_literals::NEEDLESS_PARENS_ON_RANGE_LITERALS), LintId::of(needless_question_mark::NEEDLESS_QUESTION_MARK), LintId::of(needless_update::NEEDLESS_UPDATE), LintId::of(neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD), diff --git a/clippy_lints/src/lib.register_lints.rs b/clippy_lints/src/lib.register_lints.rs index eb46a719bbf..efb073af6b6 100644 --- a/clippy_lints/src/lib.register_lints.rs +++ b/clippy_lints/src/lib.register_lints.rs @@ -408,7 +408,7 @@ store.register_lints(&[ needless_continue::NEEDLESS_CONTINUE, needless_for_each::NEEDLESS_FOR_EACH, needless_late_init::NEEDLESS_LATE_INIT, - needless_parens_on_range_literal::NEEDLESS_PARENS_ON_RANGE_LITERAL, + needless_parens_on_range_literals::NEEDLESS_PARENS_ON_RANGE_LITERALS, needless_pass_by_value::NEEDLESS_PASS_BY_VALUE, needless_question_mark::NEEDLESS_QUESTION_MARK, needless_update::NEEDLESS_UPDATE, diff --git a/clippy_lints/src/lib.register_style.rs b/clippy_lints/src/lib.register_style.rs index 37c55ae4916..b6992ae0ad2 100644 --- a/clippy_lints/src/lib.register_style.rs +++ b/clippy_lints/src/lib.register_style.rs @@ -91,7 +91,7 @@ store.register_group(true, "clippy::style", Some("clippy_style"), vec![ LintId::of(mut_mutex_lock::MUT_MUTEX_LOCK), LintId::of(mut_reference::UNNECESSARY_MUT_PASSED), LintId::of(needless_late_init::NEEDLESS_LATE_INIT), - LintId::of(needless_parens_on_range_literal::NEEDLESS_PARENS_ON_RANGE_LITERAL), + LintId::of(needless_parens_on_range_literals::NEEDLESS_PARENS_ON_RANGE_LITERALS), LintId::of(neg_multiply::NEG_MULTIPLY), LintId::of(new_without_default::NEW_WITHOUT_DEFAULT), LintId::of(non_copy_const::BORROW_INTERIOR_MUTABLE_CONST), diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 19e1247d642..a0a6bab407c 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -315,7 +315,7 @@ mod needless_borrowed_ref; mod needless_continue; mod needless_for_each; mod needless_late_init; -mod needless_parens_on_range_literal; +mod needless_parens_on_range_literals; mod needless_pass_by_value; mod needless_question_mark; mod needless_update; @@ -747,7 +747,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: store.register_early_pass(|| Box::new(collapsible_if::CollapsibleIf)); store.register_early_pass(|| Box::new(items_after_statements::ItemsAfterStatements)); store.register_early_pass(|| Box::new(precedence::Precedence)); - store.register_late_pass(|| Box::new(needless_parens_on_range_literal::NeedlessParensOnRangeLiteral)); + store.register_late_pass(|| Box::new(needless_parens_on_range_literals::NeedlessParensOnRangeLiterals)); store.register_early_pass(|| Box::new(needless_continue::NeedlessContinue)); store.register_early_pass(|| Box::new(redundant_else::RedundantElse)); store.register_late_pass(|| Box::new(create_dir::CreateDir)); diff --git a/clippy_lints/src/needless_parens_on_range_literal.rs b/clippy_lints/src/needless_parens_on_range_literals.rs similarity index 88% rename from clippy_lints/src/needless_parens_on_range_literal.rs rename to clippy_lints/src/needless_parens_on_range_literals.rs index b9f618d5f56..6e54b243c03 100644 --- a/clippy_lints/src/needless_parens_on_range_literal.rs +++ b/clippy_lints/src/needless_parens_on_range_literals.rs @@ -36,12 +36,12 @@ declare_clippy_lint! { /// } /// ``` #[clippy::version = "1.63.0"] - pub NEEDLESS_PARENS_ON_RANGE_LITERAL, + pub NEEDLESS_PARENS_ON_RANGE_LITERALS, style, - "needless parenthesis on range literal can be removed" + "needless parenthesis on range literals can be removed" } -declare_lint_pass!(NeedlessParensOnRangeLiteral => [NEEDLESS_PARENS_ON_RANGE_LITERAL]); +declare_lint_pass!(NeedlessParensOnRangeLiterals => [NEEDLESS_PARENS_ON_RANGE_LITERALS]); fn snippet_enclosed_in_parenthesis(snippet: &str) -> bool { snippet.starts_with('(') && snippet.ends_with(')') @@ -63,8 +63,8 @@ fn check_for_parens(cx: &LateContext<'_>, e: &Expr<'_>, is_start: bool) { if snippet_enclosed_in_parenthesis(&snippet(cx, e.span, "")); then { let mut applicability = Applicability::MachineApplicable; - span_lint_and_then(cx, NEEDLESS_PARENS_ON_RANGE_LITERAL, e.span, - "needless parenthesis on range literal can be removed", + span_lint_and_then(cx, NEEDLESS_PARENS_ON_RANGE_LITERALS, e.span, + "needless parenthesis on range literals can be removed", |diag| { let suggestion = snippet_with_applicability(cx, literal.span, "_", &mut applicability); diag.span_suggestion(e.span, "try", suggestion, applicability); @@ -73,7 +73,7 @@ fn check_for_parens(cx: &LateContext<'_>, e: &Expr<'_>, is_start: bool) { } } -impl<'tcx> LateLintPass<'tcx> for NeedlessParensOnRangeLiteral { +impl<'tcx> LateLintPass<'tcx> for NeedlessParensOnRangeLiterals { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { if let Some(higher::Range { start, end, .. }) = higher::Range::hir(expr) { if let Some(start) = start { diff --git a/tests/ui/almost_complete_letter_range.fixed b/tests/ui/almost_complete_letter_range.fixed index 83a6bf14c3f..e69b40f35f4 100644 --- a/tests/ui/almost_complete_letter_range.fixed +++ b/tests/ui/almost_complete_letter_range.fixed @@ -6,7 +6,7 @@ #![feature(stmt_expr_attributes)] #![warn(clippy::almost_complete_letter_range)] #![allow(ellipsis_inclusive_range_patterns)] -#![allow(clippy::needless_parens_on_range_literal)] +#![allow(clippy::needless_parens_on_range_literals)] macro_rules! a { () => { diff --git a/tests/ui/almost_complete_letter_range.rs b/tests/ui/almost_complete_letter_range.rs index a8da9266ad7..f2240981d45 100644 --- a/tests/ui/almost_complete_letter_range.rs +++ b/tests/ui/almost_complete_letter_range.rs @@ -6,7 +6,7 @@ #![feature(stmt_expr_attributes)] #![warn(clippy::almost_complete_letter_range)] #![allow(ellipsis_inclusive_range_patterns)] -#![allow(clippy::needless_parens_on_range_literal)] +#![allow(clippy::needless_parens_on_range_literals)] macro_rules! a { () => { diff --git a/tests/ui/needless_parens_on_range_literal.stderr b/tests/ui/needless_parens_on_range_literal.stderr deleted file mode 100644 index e971f9cd629..00000000000 --- a/tests/ui/needless_parens_on_range_literal.stderr +++ /dev/null @@ -1,40 +0,0 @@ -error: needless parenthesis on range literal can be removed - --> $DIR/needless_parens_on_range_literal.rs:8:13 - | -LL | let _ = ('a')..=('z'); - | ^^^^^ help: try: `'a'` - | - = note: `-D clippy::needless-parens-on-range-literal` implied by `-D warnings` - -error: needless parenthesis on range literal can be removed - --> $DIR/needless_parens_on_range_literal.rs:8:21 - | -LL | let _ = ('a')..=('z'); - | ^^^^^ help: try: `'z'` - -error: needless parenthesis on range literal can be removed - --> $DIR/needless_parens_on_range_literal.rs:9:18 - | -LL | let _ = 'a'..('z'); - | ^^^^^ help: try: `'z'` - -error: needless parenthesis on range literal can be removed - --> $DIR/needless_parens_on_range_literal.rs:11:19 - | -LL | let _ = (1.)..(2.); - | ^^^^ help: try: `2.` - -error: needless parenthesis on range literal can be removed - --> $DIR/needless_parens_on_range_literal.rs:12:13 - | -LL | let _ = ('a')..; - | ^^^^^ help: try: `'a'` - -error: needless parenthesis on range literal can be removed - --> $DIR/needless_parens_on_range_literal.rs:13:15 - | -LL | let _ = ..('z'); - | ^^^^^ help: try: `'z'` - -error: aborting due to 6 previous errors - diff --git a/tests/ui/needless_parens_on_range_literal.fixed b/tests/ui/needless_parens_on_range_literals.fixed similarity index 81% rename from tests/ui/needless_parens_on_range_literal.fixed rename to tests/ui/needless_parens_on_range_literals.fixed index e76189bd2a3..1bd75c806bc 100644 --- a/tests/ui/needless_parens_on_range_literal.fixed +++ b/tests/ui/needless_parens_on_range_literals.fixed @@ -1,7 +1,7 @@ // run-rustfix // edition:2018 -#![warn(clippy::needless_parens_on_range_literal)] +#![warn(clippy::needless_parens_on_range_literals)] #![allow(clippy::almost_complete_letter_range)] fn main() { diff --git a/tests/ui/needless_parens_on_range_literal.rs b/tests/ui/needless_parens_on_range_literals.rs similarity index 81% rename from tests/ui/needless_parens_on_range_literal.rs rename to tests/ui/needless_parens_on_range_literals.rs index aa4bcd40065..7abb8a1adc1 100644 --- a/tests/ui/needless_parens_on_range_literal.rs +++ b/tests/ui/needless_parens_on_range_literals.rs @@ -1,7 +1,7 @@ // run-rustfix // edition:2018 -#![warn(clippy::needless_parens_on_range_literal)] +#![warn(clippy::needless_parens_on_range_literals)] #![allow(clippy::almost_complete_letter_range)] fn main() { diff --git a/tests/ui/needless_parens_on_range_literals.stderr b/tests/ui/needless_parens_on_range_literals.stderr new file mode 100644 index 00000000000..505f7ac916d --- /dev/null +++ b/tests/ui/needless_parens_on_range_literals.stderr @@ -0,0 +1,40 @@ +error: needless parenthesis on range literals can be removed + --> $DIR/needless_parens_on_range_literals.rs:8:13 + | +LL | let _ = ('a')..=('z'); + | ^^^^^ help: try: `'a'` + | + = note: `-D clippy::needless-parens-on-range-literals` implied by `-D warnings` + +error: needless parenthesis on range literals can be removed + --> $DIR/needless_parens_on_range_literals.rs:8:21 + | +LL | let _ = ('a')..=('z'); + | ^^^^^ help: try: `'z'` + +error: needless parenthesis on range literals can be removed + --> $DIR/needless_parens_on_range_literals.rs:9:18 + | +LL | let _ = 'a'..('z'); + | ^^^^^ help: try: `'z'` + +error: needless parenthesis on range literals can be removed + --> $DIR/needless_parens_on_range_literals.rs:11:19 + | +LL | let _ = (1.)..(2.); + | ^^^^ help: try: `2.` + +error: needless parenthesis on range literals can be removed + --> $DIR/needless_parens_on_range_literals.rs:12:13 + | +LL | let _ = ('a')..; + | ^^^^^ help: try: `'a'` + +error: needless parenthesis on range literals can be removed + --> $DIR/needless_parens_on_range_literals.rs:13:15 + | +LL | let _ = ..('z'); + | ^^^^^ help: try: `'z'` + +error: aborting due to 6 previous errors +