mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 23:24:24 +00:00
Subsume ref_in_deref
into needless_borrow
This commit is contained in:
parent
9e9110e4f3
commit
c61514086d
22 changed files with 68 additions and 197 deletions
|
@ -3227,7 +3227,6 @@ Released 2018-09-13
|
|||
[`redundant_slicing`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_slicing
|
||||
[`redundant_static_lifetimes`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes
|
||||
[`ref_binding_to_reference`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_binding_to_reference
|
||||
[`ref_in_deref`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_in_deref
|
||||
[`ref_option_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_option_ref
|
||||
[`regex_macro`]: https://rust-lang.github.io/rust-clippy/master/index.html#regex_macro
|
||||
[`repeat_once`]: https://rust-lang.github.io/rust-clippy/master/index.html#repeat_once
|
||||
|
|
|
@ -247,7 +247,6 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
|
|||
LintId::of(redundant_slicing::REDUNDANT_SLICING),
|
||||
LintId::of(redundant_static_lifetimes::REDUNDANT_STATIC_LIFETIMES),
|
||||
LintId::of(reference::DEREF_ADDROF),
|
||||
LintId::of(reference::REF_IN_DEREF),
|
||||
LintId::of(regex::INVALID_REGEX),
|
||||
LintId::of(repeat_once::REPEAT_ONCE),
|
||||
LintId::of(returns::LET_AND_RETURN),
|
||||
|
|
|
@ -71,7 +71,6 @@ store.register_group(true, "clippy::complexity", Some("clippy_complexity"), vec!
|
|||
LintId::of(redundant_closure_call::REDUNDANT_CLOSURE_CALL),
|
||||
LintId::of(redundant_slicing::REDUNDANT_SLICING),
|
||||
LintId::of(reference::DEREF_ADDROF),
|
||||
LintId::of(reference::REF_IN_DEREF),
|
||||
LintId::of(repeat_once::REPEAT_ONCE),
|
||||
LintId::of(strings::STRING_FROM_UTF8_AS_BYTES),
|
||||
LintId::of(strlen_on_c_strings::STRLEN_ON_C_STRINGS),
|
||||
|
|
|
@ -423,7 +423,6 @@ store.register_lints(&[
|
|||
redundant_static_lifetimes::REDUNDANT_STATIC_LIFETIMES,
|
||||
ref_option_ref::REF_OPTION_REF,
|
||||
reference::DEREF_ADDROF,
|
||||
reference::REF_IN_DEREF,
|
||||
regex::INVALID_REGEX,
|
||||
regex::TRIVIAL_REGEX,
|
||||
repeat_once::REPEAT_ONCE,
|
||||
|
|
|
@ -703,7 +703,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
|
|||
store.register_late_pass(|| Box::new(mut_key::MutableKeyType));
|
||||
store.register_late_pass(|| Box::new(modulo_arithmetic::ModuloArithmetic));
|
||||
store.register_early_pass(|| Box::new(reference::DerefAddrOf));
|
||||
store.register_early_pass(|| Box::new(reference::RefInDeref));
|
||||
store.register_early_pass(|| Box::new(double_parens::DoubleParens));
|
||||
store.register_late_pass(|| Box::new(to_string_in_display::ToStringInDisplay::new()));
|
||||
store.register_early_pass(|| Box::new(unsafe_removed_from_name::UnsafeNameRemoval));
|
||||
|
@ -935,6 +934,7 @@ pub fn register_renamed(ls: &mut rustc_lint::LintStore) {
|
|||
ls.register_renamed("clippy::if_let_some_result", "clippy::match_result_ok");
|
||||
ls.register_renamed("clippy::disallowed_type", "clippy::disallowed_types");
|
||||
ls.register_renamed("clippy::disallowed_method", "clippy::disallowed_methods");
|
||||
ls.register_renamed("clippy::ref_in_deref", "clippy::needless_borrow");
|
||||
|
||||
// uplifted lints
|
||||
ls.register_renamed("clippy::invalid_ref", "invalid_value");
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||
use clippy_utils::source::{snippet_opt, snippet_with_applicability};
|
||||
use clippy_utils::sugg::Sugg;
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::{Expr, ExprKind, Mutability, UnOp};
|
||||
use rustc_errors::Applicability;
|
||||
|
@ -104,59 +103,3 @@ impl EarlyLintPass for DerefAddrOf {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// ### What it does
|
||||
/// Checks for references in expressions that use
|
||||
/// auto dereference.
|
||||
///
|
||||
/// ### Why is this bad?
|
||||
/// The reference is a no-op and is automatically
|
||||
/// dereferenced by the compiler and makes the code less clear.
|
||||
///
|
||||
/// ### Example
|
||||
/// ```rust
|
||||
/// struct Point(u32, u32);
|
||||
/// let point = Point(30, 20);
|
||||
/// let x = (&point).0;
|
||||
/// ```
|
||||
/// Use instead:
|
||||
/// ```rust
|
||||
/// # struct Point(u32, u32);
|
||||
/// # let point = Point(30, 20);
|
||||
/// let x = point.0;
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub REF_IN_DEREF,
|
||||
complexity,
|
||||
"Use of reference in auto dereference expression."
|
||||
}
|
||||
|
||||
declare_lint_pass!(RefInDeref => [REF_IN_DEREF]);
|
||||
|
||||
impl EarlyLintPass for RefInDeref {
|
||||
fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &Expr) {
|
||||
if_chain! {
|
||||
if let ExprKind::Field(ref object, _) = e.kind;
|
||||
if let ExprKind::Paren(ref parened) = object.kind;
|
||||
if let ExprKind::AddrOf(_, _, ref inner) = parened.kind;
|
||||
then {
|
||||
let applicability = if inner.span.from_expansion() {
|
||||
Applicability::MaybeIncorrect
|
||||
} else {
|
||||
Applicability::MachineApplicable
|
||||
};
|
||||
let sugg = Sugg::ast(cx, inner, "_").maybe_par();
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
REF_IN_DEREF,
|
||||
object.span,
|
||||
"creating a reference that is immediately dereferenced",
|
||||
"try this",
|
||||
sugg.to_string(),
|
||||
applicability,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
#![warn(clippy::borrow_interior_mutable_const)]
|
||||
#![allow(
|
||||
clippy::declare_interior_mutable_const,
|
||||
clippy::ref_in_deref,
|
||||
clippy::needless_borrow
|
||||
)]
|
||||
#![allow(clippy::declare_interior_mutable_const, clippy::needless_borrow)]
|
||||
#![allow(const_item_mutation)]
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> $DIR/others.rs:58:5
|
||||
--> $DIR/others.rs:54:5
|
||||
|
|
||||
LL | ATOMIC.store(1, Ordering::SeqCst); //~ ERROR interior mutability
|
||||
| ^^^^^^
|
||||
|
@ -8,7 +8,7 @@ LL | ATOMIC.store(1, Ordering::SeqCst); //~ ERROR interior mutability
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> $DIR/others.rs:59:16
|
||||
--> $DIR/others.rs:55:16
|
||||
|
|
||||
LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR interior mutability
|
||||
| ^^^^^^
|
||||
|
@ -16,7 +16,7 @@ LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR interior mutabi
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> $DIR/others.rs:62:22
|
||||
--> $DIR/others.rs:58:22
|
||||
|
|
||||
LL | let _once_ref = &ONCE_INIT; //~ ERROR interior mutability
|
||||
| ^^^^^^^^^
|
||||
|
@ -24,7 +24,7 @@ LL | let _once_ref = &ONCE_INIT; //~ ERROR interior mutability
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> $DIR/others.rs:63:25
|
||||
--> $DIR/others.rs:59:25
|
||||
|
|
||||
LL | let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability
|
||||
| ^^^^^^^^^
|
||||
|
@ -32,7 +32,7 @@ LL | let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> $DIR/others.rs:64:27
|
||||
--> $DIR/others.rs:60:27
|
||||
|
|
||||
LL | let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability
|
||||
| ^^^^^^^^^
|
||||
|
@ -40,7 +40,7 @@ LL | let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> $DIR/others.rs:65:26
|
||||
--> $DIR/others.rs:61:26
|
||||
|
|
||||
LL | let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability
|
||||
| ^^^^^^^^^
|
||||
|
@ -48,7 +48,7 @@ LL | let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> $DIR/others.rs:76:14
|
||||
--> $DIR/others.rs:72:14
|
||||
|
|
||||
LL | let _ = &ATOMIC_TUPLE; //~ ERROR interior mutability
|
||||
| ^^^^^^^^^^^^
|
||||
|
@ -56,7 +56,7 @@ LL | let _ = &ATOMIC_TUPLE; //~ ERROR interior mutability
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> $DIR/others.rs:77:14
|
||||
--> $DIR/others.rs:73:14
|
||||
|
|
||||
LL | let _ = &ATOMIC_TUPLE.0; //~ ERROR interior mutability
|
||||
| ^^^^^^^^^^^^
|
||||
|
@ -64,7 +64,7 @@ LL | let _ = &ATOMIC_TUPLE.0; //~ ERROR interior mutability
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> $DIR/others.rs:78:19
|
||||
--> $DIR/others.rs:74:19
|
||||
|
|
||||
LL | let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR interior mutability
|
||||
| ^^^^^^^^^^^^
|
||||
|
@ -72,7 +72,7 @@ LL | let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR interior mutability
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> $DIR/others.rs:79:14
|
||||
--> $DIR/others.rs:75:14
|
||||
|
|
||||
LL | let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability
|
||||
| ^^^^^^^^^^^^
|
||||
|
@ -80,7 +80,7 @@ LL | let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> $DIR/others.rs:80:13
|
||||
--> $DIR/others.rs:76:13
|
||||
|
|
||||
LL | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR interior mutability
|
||||
| ^^^^^^^^^^^^
|
||||
|
@ -88,7 +88,7 @@ LL | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR interior mu
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> $DIR/others.rs:86:13
|
||||
--> $DIR/others.rs:82:13
|
||||
|
|
||||
LL | let _ = ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability
|
||||
| ^^^^^^^^^^^^
|
||||
|
@ -96,7 +96,7 @@ LL | let _ = ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> $DIR/others.rs:91:5
|
||||
--> $DIR/others.rs:87:5
|
||||
|
|
||||
LL | CELL.set(2); //~ ERROR interior mutability
|
||||
| ^^^^
|
||||
|
@ -104,7 +104,7 @@ LL | CELL.set(2); //~ ERROR interior mutability
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> $DIR/others.rs:92:16
|
||||
--> $DIR/others.rs:88:16
|
||||
|
|
||||
LL | assert_eq!(CELL.get(), 6); //~ ERROR interior mutability
|
||||
| ^^^^
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// run-rustfix
|
||||
|
||||
#![allow(unused_variables, clippy::clone_double_ref)]
|
||||
#![allow(unused_variables, clippy::clone_double_ref, clippy::needless_borrow)]
|
||||
#![warn(clippy::explicit_deref_methods)]
|
||||
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// run-rustfix
|
||||
|
||||
#![allow(unused_variables, clippy::clone_double_ref)]
|
||||
#![allow(unused_variables, clippy::clone_double_ref, clippy::needless_borrow)]
|
||||
#![warn(clippy::explicit_deref_methods)]
|
||||
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
// run-rustfix
|
||||
|
||||
#![allow(clippy::print_literal, clippy::redundant_clone, clippy::to_string_in_format_args)]
|
||||
#![allow(
|
||||
clippy::print_literal,
|
||||
clippy::redundant_clone,
|
||||
clippy::to_string_in_format_args,
|
||||
clippy::needless_borrow
|
||||
)]
|
||||
#![warn(clippy::useless_format)]
|
||||
|
||||
struct Foo(pub String);
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
// run-rustfix
|
||||
|
||||
#![allow(clippy::print_literal, clippy::redundant_clone, clippy::to_string_in_format_args)]
|
||||
#![allow(
|
||||
clippy::print_literal,
|
||||
clippy::redundant_clone,
|
||||
clippy::to_string_in_format_args,
|
||||
clippy::needless_borrow
|
||||
)]
|
||||
#![warn(clippy::useless_format)]
|
||||
|
||||
struct Foo(pub String);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:13:5
|
||||
--> $DIR/format.rs:18:5
|
||||
|
|
||||
LL | format!("foo");
|
||||
| ^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()`
|
||||
|
@ -7,19 +7,19 @@ LL | format!("foo");
|
|||
= note: `-D clippy::useless-format` implied by `-D warnings`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:14:5
|
||||
--> $DIR/format.rs:19:5
|
||||
|
|
||||
LL | format!("{{}}");
|
||||
| ^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"{}".to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:15:5
|
||||
--> $DIR/format.rs:20:5
|
||||
|
|
||||
LL | format!("{{}} abc {{}}");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"{} abc {}".to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:16:5
|
||||
--> $DIR/format.rs:21:5
|
||||
|
|
||||
LL | / format!(
|
||||
LL | | r##"foo {{}}
|
||||
|
@ -34,79 +34,79 @@ LL ~ " bar"##.to_string();
|
|||
|
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:21:13
|
||||
--> $DIR/format.rs:26:13
|
||||
|
|
||||
LL | let _ = format!("");
|
||||
| ^^^^^^^^^^^ help: consider using `String::new()`: `String::new()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:23:5
|
||||
--> $DIR/format.rs:28:5
|
||||
|
|
||||
LL | format!("{}", "foo");
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:27:5
|
||||
--> $DIR/format.rs:32:5
|
||||
|
|
||||
LL | format!("{:+}", "foo"); // Warn when the format makes no difference.
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:28:5
|
||||
--> $DIR/format.rs:33:5
|
||||
|
|
||||
LL | format!("{:<}", "foo"); // Warn when the format makes no difference.
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:33:5
|
||||
--> $DIR/format.rs:38:5
|
||||
|
|
||||
LL | format!("{}", arg);
|
||||
| ^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `arg.to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:37:5
|
||||
--> $DIR/format.rs:42:5
|
||||
|
|
||||
LL | format!("{:+}", arg); // Warn when the format makes no difference.
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `arg.to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:38:5
|
||||
--> $DIR/format.rs:43:5
|
||||
|
|
||||
LL | format!("{:<}", arg); // Warn when the format makes no difference.
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `arg.to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:65:5
|
||||
--> $DIR/format.rs:70:5
|
||||
|
|
||||
LL | format!("{}", 42.to_string());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `42.to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:67:5
|
||||
--> $DIR/format.rs:72:5
|
||||
|
|
||||
LL | format!("{}", x.display().to_string());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.display().to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:71:18
|
||||
--> $DIR/format.rs:76:18
|
||||
|
|
||||
LL | let _ = Some(format!("{}", a + "bar"));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `a + "bar"`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:75:22
|
||||
--> $DIR/format.rs:80:22
|
||||
|
|
||||
LL | let _s: String = format!("{}", &*v.join("/n"));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `(&*v.join("/n")).to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:81:13
|
||||
--> $DIR/format.rs:86:13
|
||||
|
|
||||
LL | let _ = format!("{x}");
|
||||
| ^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:83:13
|
||||
--> $DIR/format.rs:88:13
|
||||
|
|
||||
LL | let _ = format!("{y}", y = x);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.to_string()`
|
||||
|
|
|
@ -1,17 +1,3 @@
|
|||
error: creating a reference that is immediately dereferenced
|
||||
--> $DIR/needless_borrow.rs:72:13
|
||||
|
|
||||
LL | let _ = (&x).0;
|
||||
| ^^^^ help: try this: `x`
|
||||
|
|
||||
= note: `-D clippy::ref-in-deref` implied by `-D warnings`
|
||||
|
||||
error: creating a reference that is immediately dereferenced
|
||||
--> $DIR/needless_borrow.rs:74:22
|
||||
|
|
||||
LL | let _ = unsafe { (&*x).0 };
|
||||
| ^^^^^ help: try this: `(*x)`
|
||||
|
||||
error: this expression creates a reference which is immediately dereferenced by the compiler
|
||||
--> $DIR/needless_borrow.rs:9:15
|
||||
|
|
||||
|
@ -128,5 +114,5 @@ error: this expression borrows a value the compiler would automatically borrow
|
|||
LL | let _ = unsafe { (&*x).0 };
|
||||
| ^^^^^ help: change this to: `(*x)`
|
||||
|
||||
error: aborting due to 21 previous errors
|
||||
error: aborting due to 19 previous errors
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ const fn issue6067() {
|
|||
None::<()>.is_none();
|
||||
}
|
||||
|
||||
#[allow(clippy::deref_addrof, dead_code)]
|
||||
#[allow(clippy::deref_addrof, dead_code, clippy::needless_borrow)]
|
||||
fn issue7921() {
|
||||
if (&None::<()>).is_none() {}
|
||||
if (&None::<()>).is_none() {}
|
||||
|
|
|
@ -96,7 +96,7 @@ const fn issue6067() {
|
|||
};
|
||||
}
|
||||
|
||||
#[allow(clippy::deref_addrof, dead_code)]
|
||||
#[allow(clippy::deref_addrof, dead_code, clippy::needless_borrow)]
|
||||
fn issue7921() {
|
||||
if let None = *(&None::<()>) {}
|
||||
if let None = *&None::<()> {}
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#![warn(clippy::match_result_ok)]
|
||||
#![warn(clippy::disallowed_types)]
|
||||
#![warn(clippy::disallowed_methods)]
|
||||
#![warn(clippy::needless_borrow)]
|
||||
// uplifted lints
|
||||
#![warn(invalid_value)]
|
||||
#![warn(array_into_iter)]
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#![warn(clippy::if_let_some_result)]
|
||||
#![warn(clippy::disallowed_type)]
|
||||
#![warn(clippy::disallowed_method)]
|
||||
#![warn(clippy::ref_in_deref)]
|
||||
// uplifted lints
|
||||
#![warn(clippy::invalid_ref)]
|
||||
#![warn(clippy::into_iter_on_array)]
|
||||
|
|
|
@ -138,59 +138,65 @@ error: lint `clippy::disallowed_method` has been renamed to `clippy::disallowed_
|
|||
LL | #![warn(clippy::disallowed_method)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_methods`
|
||||
|
||||
error: lint `clippy::ref_in_deref` has been renamed to `clippy::needless_borrow`
|
||||
--> $DIR/rename.rs:57:9
|
||||
|
|
||||
LL | #![warn(clippy::ref_in_deref)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::needless_borrow`
|
||||
|
||||
error: lint `clippy::invalid_ref` has been renamed to `invalid_value`
|
||||
--> $DIR/rename.rs:58:9
|
||||
--> $DIR/rename.rs:59:9
|
||||
|
|
||||
LL | #![warn(clippy::invalid_ref)]
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_value`
|
||||
|
||||
error: lint `clippy::into_iter_on_array` has been renamed to `array_into_iter`
|
||||
--> $DIR/rename.rs:59:9
|
||||
--> $DIR/rename.rs:60:9
|
||||
|
|
||||
LL | #![warn(clippy::into_iter_on_array)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `array_into_iter`
|
||||
|
||||
error: lint `clippy::unused_label` has been renamed to `unused_labels`
|
||||
--> $DIR/rename.rs:60:9
|
||||
--> $DIR/rename.rs:61:9
|
||||
|
|
||||
LL | #![warn(clippy::unused_label)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unused_labels`
|
||||
|
||||
error: lint `clippy::drop_bounds` has been renamed to `drop_bounds`
|
||||
--> $DIR/rename.rs:61:9
|
||||
--> $DIR/rename.rs:62:9
|
||||
|
|
||||
LL | #![warn(clippy::drop_bounds)]
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: use the new name: `drop_bounds`
|
||||
|
||||
error: lint `clippy::temporary_cstring_as_ptr` has been renamed to `temporary_cstring_as_ptr`
|
||||
--> $DIR/rename.rs:62:9
|
||||
--> $DIR/rename.rs:63:9
|
||||
|
|
||||
LL | #![warn(clippy::temporary_cstring_as_ptr)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `temporary_cstring_as_ptr`
|
||||
|
||||
error: lint `clippy::panic_params` has been renamed to `non_fmt_panics`
|
||||
--> $DIR/rename.rs:63:9
|
||||
--> $DIR/rename.rs:64:9
|
||||
|
|
||||
LL | #![warn(clippy::panic_params)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panics`
|
||||
|
||||
error: lint `clippy::unknown_clippy_lints` has been renamed to `unknown_lints`
|
||||
--> $DIR/rename.rs:64:9
|
||||
--> $DIR/rename.rs:65:9
|
||||
|
|
||||
LL | #![warn(clippy::unknown_clippy_lints)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unknown_lints`
|
||||
|
||||
error: lint `clippy::invalid_atomic_ordering` has been renamed to `invalid_atomic_ordering`
|
||||
--> $DIR/rename.rs:65:9
|
||||
--> $DIR/rename.rs:66:9
|
||||
|
|
||||
LL | #![warn(clippy::invalid_atomic_ordering)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_atomic_ordering`
|
||||
|
||||
error: lint `clippy::mem_discriminant_non_enum` has been renamed to `enum_intrinsics_non_enums`
|
||||
--> $DIR/rename.rs:66:9
|
||||
--> $DIR/rename.rs:67:9
|
||||
|
|
||||
LL | #![warn(clippy::mem_discriminant_non_enum)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `enum_intrinsics_non_enums`
|
||||
|
||||
error: aborting due to 32 previous errors
|
||||
error: aborting due to 33 previous errors
|
||||
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(stmt_expr_attributes)]
|
||||
#![allow(unused_variables, dead_code)]
|
||||
|
||||
struct Outer {
|
||||
inner: u32,
|
||||
}
|
||||
|
||||
#[deny(clippy::ref_in_deref)]
|
||||
fn main() {
|
||||
let outer = Outer { inner: 0 };
|
||||
let inner = outer.inner;
|
||||
}
|
||||
|
||||
struct Apple;
|
||||
impl Apple {
|
||||
fn hello(&self) {}
|
||||
}
|
||||
struct Package(pub *const Apple);
|
||||
fn foobar(package: *const Package) {
|
||||
unsafe { &*(*package).0 }.hello();
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(stmt_expr_attributes)]
|
||||
#![allow(unused_variables, dead_code)]
|
||||
|
||||
struct Outer {
|
||||
inner: u32,
|
||||
}
|
||||
|
||||
#[deny(clippy::ref_in_deref)]
|
||||
fn main() {
|
||||
let outer = Outer { inner: 0 };
|
||||
let inner = (&outer).inner;
|
||||
}
|
||||
|
||||
struct Apple;
|
||||
impl Apple {
|
||||
fn hello(&self) {}
|
||||
}
|
||||
struct Package(pub *const Apple);
|
||||
fn foobar(package: *const Package) {
|
||||
unsafe { &*(&*package).0 }.hello();
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
error: creating a reference that is immediately dereferenced
|
||||
--> $DIR/unnecessary_ref.rs:13:17
|
||||
|
|
||||
LL | let inner = (&outer).inner;
|
||||
| ^^^^^^^^ help: try this: `outer`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/unnecessary_ref.rs:10:8
|
||||
|
|
||||
LL | #[deny(clippy::ref_in_deref)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: creating a reference that is immediately dereferenced
|
||||
--> $DIR/unnecessary_ref.rs:22:16
|
||||
|
|
||||
LL | unsafe { &*(&*package).0 }.hello();
|
||||
| ^^^^^^^^^^^ help: try this: `(*package)`
|
||||
|
|
||||
= note: `-D clippy::ref-in-deref` implied by `-D warnings`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
Loading…
Reference in a new issue