Fix misnomer braces -> parenthesis

This commit is contained in:
Dennis Luxen 2022-06-04 19:37:28 +02:00
parent 8bc1be17d6
commit 5948959c7e
12 changed files with 38 additions and 38 deletions

View file

@ -3596,7 +3596,7 @@ Released 2018-09-13
[`needless_bool`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_bool
[`needless_borrow`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
[`needless_borrowed_reference`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference
[`needless_braces_on_range_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_braces_on_range_literal
[`needless_parens_on_range_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_parens_on_range_literal
[`needless_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_collect
[`needless_continue`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_continue
[`needless_doctest_main`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_doctest_main

View file

@ -241,7 +241,7 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
LintId::of(needless_bool::BOOL_COMPARISON),
LintId::of(needless_bool::NEEDLESS_BOOL),
LintId::of(needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE),
LintId::of(needless_braces_on_range_literal::NEEDLESS_BRACES_ON_RANGE_LITERAL),
LintId::of(needless_parens_on_range_literal::NEEDLESS_PARENS_ON_RANGE_LITERAL),
LintId::of(needless_late_init::NEEDLESS_LATE_INIT),
LintId::of(needless_question_mark::NEEDLESS_QUESTION_MARK),
LintId::of(needless_update::NEEDLESS_UPDATE),

View file

@ -405,7 +405,7 @@ store.register_lints(&[
needless_bool::BOOL_COMPARISON,
needless_bool::NEEDLESS_BOOL,
needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
needless_braces_on_range_literal::NEEDLESS_BRACES_ON_RANGE_LITERAL,
needless_parens_on_range_literal::NEEDLESS_PARENS_ON_RANGE_LITERAL,
needless_continue::NEEDLESS_CONTINUE,
needless_for_each::NEEDLESS_FOR_EACH,
needless_late_init::NEEDLESS_LATE_INIT,

View file

@ -90,7 +90,7 @@ store.register_group(true, "clippy::style", Some("clippy_style"), vec![
LintId::of(misc_early::REDUNDANT_PATTERN),
LintId::of(mut_mutex_lock::MUT_MUTEX_LOCK),
LintId::of(mut_reference::UNNECESSARY_MUT_PASSED),
LintId::of(needless_braces_on_range_literal::NEEDLESS_BRACES_ON_RANGE_LITERAL),
LintId::of(needless_parens_on_range_literal::NEEDLESS_PARENS_ON_RANGE_LITERAL),
LintId::of(needless_late_init::NEEDLESS_LATE_INIT),
LintId::of(neg_multiply::NEG_MULTIPLY),
LintId::of(new_without_default::NEW_WITHOUT_DEFAULT),

View file

@ -312,10 +312,10 @@ mod needless_arbitrary_self_type;
mod needless_bitwise_bool;
mod needless_bool;
mod needless_borrowed_ref;
mod needless_braces_on_range_literal;
mod needless_continue;
mod needless_for_each;
mod needless_late_init;
mod needless_parens_on_range_literal;
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_early_pass(|| Box::new(needless_braces_on_range_literal::NeedlessBracesOnRangeLiteral));
store.register_early_pass(|| Box::new(needless_parens_on_range_literal::NeedlessParensOnRangeLiteral));
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));

View file

@ -1,4 +1,4 @@
//! Checks for braces on literals in range statements
//! Checks for parantheses on literals in range statements
//!
//! For example, the lint would catch
//!
@ -25,28 +25,28 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
declare_clippy_lint! {
/// ### What it does
/// The lint checks for braces on literals in range statements that are
/// The lint checks for parenthesis on literals in range statements that are
/// superflous.
///
/// ### Why is this bad?
/// Having superflous braces makes the code less legible as the impose an
/// Having superflous parenthesis makes the code less legible as the impose an
/// overhead when reading.
#[clippy::version = "1.63.0"]
pub NEEDLESS_BRACES_ON_RANGE_LITERAL,
pub NEEDLESS_PARENS_ON_RANGE_LITERAL,
style,
"needless braces on range literal can be removed"
"needless parenthesis on range literal can be removed"
}
declare_lint_pass!(NeedlessBracesOnRangeLiteral => [NEEDLESS_BRACES_ON_RANGE_LITERAL]);
declare_lint_pass!(NeedlessParensOnRangeLiteral => [NEEDLESS_PARENS_ON_RANGE_LITERAL]);
fn check_for_braces(cx: &EarlyContext<'_>, e: &Expr) {
fn check_for_parens(cx: &EarlyContext<'_>, e: &Expr) {
if_chain! {
if let ExprKind::Paren(ref start_statement) = &e.kind;
if let ExprKind::Lit(ref literal) = start_statement.kind;
then {
span_lint_and_then(cx, NEEDLESS_BRACES_ON_RANGE_LITERAL, e.span,
"needless braces on range literal can be removed",
span_lint_and_then(cx, NEEDLESS_PARENS_ON_RANGE_LITERAL, e.span,
"needless parenthesis on range literal can be removed",
|diag| {
if let Some(suggestion) = snippet_opt(cx, literal.span) {
diag.span_suggestion(e.span, "try", suggestion, Applicability::MachineApplicable);
@ -56,11 +56,11 @@ fn check_for_braces(cx: &EarlyContext<'_>, e: &Expr) {
}
}
impl EarlyLintPass for NeedlessBracesOnRangeLiteral {
impl EarlyLintPass for NeedlessParensOnRangeLiteral {
fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &Expr) {
if let ExprKind::Range(Some(start), Some(end), _) = &e.kind {
check_for_braces(cx, start);
check_for_braces(cx, end);
check_for_parens(cx, start);
check_for_parens(cx, end);
}
}
}

View file

@ -6,7 +6,7 @@
#![feature(stmt_expr_attributes)]
#![warn(clippy::almost_complete_letter_range)]
#![allow(ellipsis_inclusive_range_patterns)]
#![allow(clippy::needless_braces_on_range_literal)]
#![allow(clippy::needless_parens_on_range_literal)]
macro_rules! a {
() => {

View file

@ -6,7 +6,7 @@
#![feature(stmt_expr_attributes)]
#![warn(clippy::almost_complete_letter_range)]
#![allow(ellipsis_inclusive_range_patterns)]
#![allow(clippy::needless_braces_on_range_literal)]
#![allow(clippy::needless_parens_on_range_literal)]
macro_rules! a {
() => {

View file

@ -1,16 +0,0 @@
error: needless braces on range literal can be removed
--> $DIR/needless_braces_on_range_literal.rs:8:13
|
LL | let _ = ('a')..=('z');
| ^^^^^ help: try: `'a'`
|
= note: `-D clippy::needless-braces-on-range-literal` implied by `-D warnings`
error: needless braces on range literal can be removed
--> $DIR/needless_braces_on_range_literal.rs:8:21
|
LL | let _ = ('a')..=('z');
| ^^^^^ help: try: `'z'`
error: aborting due to 2 previous errors

View file

@ -1,7 +1,7 @@
// run-rustfix
// edition:2018
#![warn(clippy::needless_braces_on_range_literal)]
#![warn(clippy::needless_parens_on_range_literal)]
#![allow(clippy::almost_complete_letter_range)]
fn main() {

View file

@ -1,7 +1,7 @@
// run-rustfix
// edition:2018
#![warn(clippy::needless_braces_on_range_literal)]
#![warn(clippy::needless_parens_on_range_literal)]
#![allow(clippy::almost_complete_letter_range)]
fn main() {

View file

@ -0,0 +1,16 @@
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: aborting due to 2 previous errors