1
Fork 0

Add version = "Two" to rustfmt.toml

Ignore UI tests since this change makes rustfmt less friendly with UI
test comments.
This commit is contained in:
Cameron Steffen 2021-03-01 11:53:33 -06:00
parent 5ae1e17e81
commit ada8c72f3f
52 changed files with 232 additions and 510 deletions

View file

@ -123,13 +123,13 @@ fn check_interior_types(cx: &LateContext<'_>, ty_causes: &[GeneratorInteriorType
} }
if is_refcell_ref(cx, adt.did) { if is_refcell_ref(cx, adt.did) {
span_lint_and_note( span_lint_and_note(
cx, cx,
AWAIT_HOLDING_REFCELL_REF, AWAIT_HOLDING_REFCELL_REF,
ty_cause.span, ty_cause.span,
"this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await", "this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await",
ty_cause.scope_span.or(Some(span)), ty_cause.scope_span.or(Some(span)),
"these are all the await points this ref is held through", "these are all the await points this ref is held through",
); );
} }
} }
} }

View file

@ -145,11 +145,7 @@ fn count_digits(s: &str) -> usize {
.take_while(|c| *c != 'e' && *c != 'E') .take_while(|c| *c != 'e' && *c != 'E')
.fold(0, |count, c| { .fold(0, |count, c| {
// leading zeros // leading zeros
if c == '0' && count == 0 { if c == '0' && count == 0 { count } else { count + 1 }
count
} else {
count + 1
}
}) })
} }

View file

@ -89,11 +89,7 @@ impl Finiteness {
impl From<bool> for Finiteness { impl From<bool> for Finiteness {
#[must_use] #[must_use]
fn from(b: bool) -> Self { fn from(b: bool) -> Self {
if b { if b { Infinite } else { Finite }
Infinite
} else {
Finite
}
} }
} }

View file

@ -139,7 +139,7 @@ fn show_lint(cx: &LateContext<'_>, item: &ImplItem<'_>) {
self_type.to_string() self_type.to_string()
), ),
None, None,
&format!("remove the inherent method from type `{}`", self_type.to_string()) &format!("remove the inherent method from type `{}`", self_type.to_string()),
); );
} else { } else {
span_lint_and_help( span_lint_and_help(

View file

@ -3158,11 +3158,7 @@ fn detect_iter_and_into_iters<'tcx>(block: &'tcx Block<'tcx>, identifier: Ident)
seen_other: false, seen_other: false,
}; };
visitor.visit_block(block); visitor.visit_block(block);
if visitor.seen_other { if visitor.seen_other { None } else { Some(visitor.uses) }
None
} else {
Some(visitor.uses)
}
} }
fn shorten_needless_collect_span(expr: &Expr<'_>) -> Span { fn shorten_needless_collect_span(expr: &Expr<'_>) -> Span {

View file

@ -73,11 +73,7 @@ impl<'a, 'tcx> MutArgVisitor<'a, 'tcx> {
} }
fn expr_span(&self) -> Option<Span> { fn expr_span(&self) -> Option<Span> {
if self.found { if self.found { self.expr_span } else { None }
self.expr_span
} else {
None
}
} }
} }

View file

@ -416,11 +416,7 @@ fn erode_from_back(s: &str) -> String {
break; break;
} }
} }
if ret.is_empty() { if ret.is_empty() { s.to_string() } else { ret }
s.to_string()
} else {
ret
}
} }
fn span_of_first_expr_in_block(block: &ast::Block) -> Option<Span> { fn span_of_first_expr_in_block(block: &ast::Block) -> Option<Span> {

View file

@ -69,15 +69,11 @@ fn get_open_options(cx: &LateContext<'_>, argument: &Expr<'_>, options: &mut Vec
.. ..
} = *span } = *span
{ {
if lit { if lit { Argument::True } else { Argument::False }
Argument::True
} else {
Argument::False
}
} else { } else {
return; // The function is called with a literal // The function is called with a literal which is not a boolean literal.
// which is not a boolean literal. This is theoretically // This is theoretically possible, but not very likely.
// possible, but not very likely. return;
} }
}, },
_ => Argument::Unknown, _ => Argument::Unknown,

View file

@ -25,11 +25,7 @@ pub fn until(s: &str) -> usize {
return i; return i;
} }
} }
if up { if up { last_i } else { s.len() }
last_i
} else {
s.len()
}
} }
/// Returns index of the last camel-case component of `s`. /// Returns index of the last camel-case component of `s`.

View file

@ -1563,12 +1563,12 @@ pub fn is_trait_impl_item(cx: &LateContext<'_>, hir_id: HirId) -> bool {
/// ``` /// ```
pub fn fn_has_unsatisfiable_preds(cx: &LateContext<'_>, did: DefId) -> bool { pub fn fn_has_unsatisfiable_preds(cx: &LateContext<'_>, did: DefId) -> bool {
use rustc_trait_selection::traits; use rustc_trait_selection::traits;
let predicates = let predicates = cx
cx.tcx .tcx
.predicates_of(did) .predicates_of(did)
.predicates .predicates
.iter() .iter()
.filter_map(|(p, _)| if p.is_global() { Some(*p) } else { None }); .filter_map(|(p, _)| if p.is_global() { Some(*p) } else { None });
traits::impossible_predicates( traits::impossible_predicates(
cx.tcx, cx.tcx,
traits::elaborate_predicates(cx.tcx, predicates) traits::elaborate_predicates(cx.tcx, predicates)

View file

@ -36,11 +36,7 @@ fn extract_clone_suggestions<'tcx>(
abort: false, abort: false,
}; };
visitor.visit_body(body); visitor.visit_body(body);
if visitor.abort { if visitor.abort { None } else { Some(visitor.spans) }
None
} else {
Some(visitor.spans)
}
} }
struct PtrCloneVisitor<'a, 'tcx> { struct PtrCloneVisitor<'a, 'tcx> {

View file

@ -4,3 +4,4 @@ match_block_trailing_comma = true
wrap_comments = true wrap_comments = true
edition = "2018" edition = "2018"
error_on_line_overflow = true error_on_line_overflow = true
version = "Two"

View file

@ -98,7 +98,9 @@ fn lint_message_convention() {
eprintln!("\n\n"); eprintln!("\n\n");
}); });
eprintln!("\n\n\nLint message should not start with a capital letter and should not have punctuation at the end of the message unless multiple sentences are needed."); eprintln!(
"\n\n\nLint message should not start with a capital letter and should not have punctuation at the end of the message unless multiple sentences are needed."
);
eprintln!("Check out the rustc-dev-guide for more information:"); eprintln!("Check out the rustc-dev-guide for more information:");
eprintln!("https://rustc-dev-guide.rust-lang.org/diagnostics.html#diagnostic-structure\n\n\n"); eprintln!("https://rustc-dev-guide.rust-lang.org/diagnostics.html#diagnostic-structure\n\n\n");

View file

@ -16,7 +16,8 @@ enum Flags {
FIN, FIN,
} }
struct GCCLLVMSomething; // linted with cfg option, beware that lint suggests `GccllvmSomething` instead of // linted with cfg option, beware that lint suggests `GccllvmSomething` instead of
// `GccLlvmSomething` // `GccLlvmSomething`
struct GCCLLVMSomething;
fn main() {} fn main() {}

View file

@ -61,9 +61,9 @@ LL | FIN,
| ^^^ help: consider making the acronym lowercase, except the initial letter: `Fin` | ^^^ help: consider making the acronym lowercase, except the initial letter: `Fin`
error: name `GCCLLVMSomething` contains a capitalized acronym error: name `GCCLLVMSomething` contains a capitalized acronym
--> $DIR/upper_case_acronyms.rs:19:8 --> $DIR/upper_case_acronyms.rs:21:8
| |
LL | struct GCCLLVMSomething; // linted with cfg option, beware that lint suggests `GccllvmSomething` instead of LL | struct GCCLLVMSomething;
| ^^^^^^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `GccllvmSomething` | ^^^^^^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `GccllvmSomething`
error: aborting due to 11 previous errors error: aborting due to 11 previous errors

View file

@ -23,11 +23,7 @@ macro_rules! try_err {
pub fn try_err_fn() -> Result<i32, i32> { pub fn try_err_fn() -> Result<i32, i32> {
let err: i32 = 1; let err: i32 = 1;
// To avoid warnings during rustfix // To avoid warnings during rustfix
if true { if true { Err(err)? } else { Ok(2) }
Err(err)?
} else {
Ok(2)
}
} }
}; };
} }

View file

@ -4,9 +4,7 @@
#![warn(clippy::nonminimal_bool)] #![warn(clippy::nonminimal_bool)]
macro_rules! blocky { macro_rules! blocky {
() => {{ () => {{ true }};
true
}};
} }
macro_rules! blocky_too { macro_rules! blocky_too {
@ -34,20 +32,12 @@ fn condition_has_block() -> i32 {
} }
fn condition_has_block_with_single_expression() -> i32 { fn condition_has_block_with_single_expression() -> i32 {
if true { if true { 6 } else { 10 }
6
} else {
10
}
} }
fn condition_is_normal() -> i32 { fn condition_is_normal() -> i32 {
let x = 3; let x = 3;
if x == 3 { if x == 3 { 6 } else { 10 }
6
} else {
10
}
} }
fn condition_is_unsafe_block() { fn condition_is_unsafe_block() {
@ -61,14 +51,15 @@ fn condition_is_unsafe_block() {
fn block_in_assert() { fn block_in_assert() {
let opt = Some(42); let opt = Some(42);
assert!(opt assert!(
.as_ref() opt.as_ref()
.map(|val| { .map(|val| {
let mut v = val * 2; let mut v = val * 2;
v -= 1; v -= 1;
v * 3 v * 3
}) })
.is_some()); .is_some()
);
} }
fn main() {} fn main() {}

View file

@ -4,9 +4,7 @@
#![warn(clippy::nonminimal_bool)] #![warn(clippy::nonminimal_bool)]
macro_rules! blocky { macro_rules! blocky {
() => {{ () => {{ true }};
true
}};
} }
macro_rules! blocky_too { macro_rules! blocky_too {
@ -34,20 +32,12 @@ fn condition_has_block() -> i32 {
} }
fn condition_has_block_with_single_expression() -> i32 { fn condition_has_block_with_single_expression() -> i32 {
if { true } { if { true } { 6 } else { 10 }
6
} else {
10
}
} }
fn condition_is_normal() -> i32 { fn condition_is_normal() -> i32 {
let x = 3; let x = 3;
if true && x == 3 { if true && x == 3 { 6 } else { 10 }
6
} else {
10
}
} }
fn condition_is_unsafe_block() { fn condition_is_unsafe_block() {
@ -61,14 +51,15 @@ fn condition_is_unsafe_block() {
fn block_in_assert() { fn block_in_assert() {
let opt = Some(42); let opt = Some(42);
assert!(opt assert!(
.as_ref() opt.as_ref()
.map(|val| { .map(|val| {
let mut v = val * 2; let mut v = val * 2;
v -= 1; v -= 1;
v * 3 v * 3
}) })
.is_some()); .is_some()
);
} }
fn main() {} fn main() {}

View file

@ -1,5 +1,5 @@
error: in an `if` condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let` error: in an `if` condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let`
--> $DIR/blocks_in_if_conditions.rs:26:5 --> $DIR/blocks_in_if_conditions.rs:24:5
| |
LL | / if { LL | / if {
LL | | let x = 3; LL | | let x = 3;
@ -17,15 +17,15 @@ LL | }; if res {
| |
error: omit braces around single expression condition error: omit braces around single expression condition
--> $DIR/blocks_in_if_conditions.rs:37:8 --> $DIR/blocks_in_if_conditions.rs:35:8
| |
LL | if { true } { LL | if { true } { 6 } else { 10 }
| ^^^^^^^^ help: try: `true` | ^^^^^^^^ help: try: `true`
error: this boolean expression can be simplified error: this boolean expression can be simplified
--> $DIR/blocks_in_if_conditions.rs:46:8 --> $DIR/blocks_in_if_conditions.rs:40:8
| |
LL | if true && x == 3 { LL | if true && x == 3 { 6 } else { 10 }
| ^^^^^^^^^^^^^^ help: try: `x == 3` | ^^^^^^^^^^^^^^ help: try: `x == 3`
| |
= note: `-D clippy::nonminimal-bool` implied by `-D warnings` = note: `-D clippy::nonminimal-bool` implied by `-D warnings`

View file

@ -66,14 +66,16 @@ fn main() {
} }
if x.is_ok() { if x.is_ok() {
x = Err(()); x = Err(());
x.unwrap(); // not unnecessary because of mutation of x // not unnecessary because of mutation of x
// it will always panic but the lint is not smart enough to see this (it only // it will always panic but the lint is not smart enough to see this (it only
// checks if conditions). // checks if conditions).
x.unwrap();
} else { } else {
x = Ok(()); x = Ok(());
x.unwrap_err(); // not unnecessary because of mutation of x // not unnecessary because of mutation of x
// it will always panic but the lint is not smart enough to see this (it // it will always panic but the lint is not smart enough to see this (it
// only checks if conditions). // only checks if conditions).
x.unwrap_err();
} }
assert!(x.is_ok(), "{:?}", x.unwrap_err()); // ok, it's a common test pattern assert!(x.is_ok(), "{:?}", x.unwrap_err()); // ok, it's a common test pattern

View file

@ -8,6 +8,7 @@ impl dyn TT {
fn func(&self) {} fn func(&self) {}
} }
#[rustfmt::skip]
fn main() { fn main() {
let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types
//[nll]~^ ERROR: borrowed data escapes outside of closure //[nll]~^ ERROR: borrowed data escapes outside of closure

View file

@ -1,13 +1,13 @@
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/ice-6256.rs:12:28 --> $DIR/ice-6256.rs:13:28
| |
LL | let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types LL | let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types
| ^^^^ lifetime mismatch | ^^^^ lifetime mismatch
| |
= note: expected reference `&(dyn TT + 'static)` = note: expected reference `&(dyn TT + 'static)`
found reference `&dyn TT` found reference `&dyn TT`
note: the anonymous lifetime #1 defined on the body at 12:13... note: the anonymous lifetime #1 defined on the body at 13:13...
--> $DIR/ice-6256.rs:12:13 --> $DIR/ice-6256.rs:13:13
| |
LL | let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types LL | let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,11 +1,7 @@
#![warn(clippy::dbg_macro)] #![warn(clippy::dbg_macro)]
fn foo(n: u32) -> u32 { fn foo(n: u32) -> u32 {
if let Some(n) = dbg!(n.checked_sub(4)) { if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n }
n
} else {
n
}
} }
fn factorial(n: u32) -> u32 { fn factorial(n: u32) -> u32 {

View file

@ -1,17 +1,17 @@
error: `dbg!` macro is intended as a debugging tool error: `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:4:22 --> $DIR/dbg_macro.rs:4:22
| |
LL | if let Some(n) = dbg!(n.checked_sub(4)) { LL | if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n }
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
| |
= note: `-D clippy::dbg-macro` implied by `-D warnings` = note: `-D clippy::dbg-macro` implied by `-D warnings`
help: ensure to avoid having uses of it in version control help: ensure to avoid having uses of it in version control
| |
LL | if let Some(n) = n.checked_sub(4) { LL | if let Some(n) = n.checked_sub(4) { n } else { n }
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
error: `dbg!` macro is intended as a debugging tool error: `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:12:8 --> $DIR/dbg_macro.rs:8:8
| |
LL | if dbg!(n <= 1) { LL | if dbg!(n <= 1) {
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
@ -22,7 +22,7 @@ LL | if n <= 1 {
| ^^^^^^ | ^^^^^^
error: `dbg!` macro is intended as a debugging tool error: `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:13:9 --> $DIR/dbg_macro.rs:9:9
| |
LL | dbg!(1) LL | dbg!(1)
| ^^^^^^^ | ^^^^^^^
@ -33,7 +33,7 @@ LL | 1
| |
error: `dbg!` macro is intended as a debugging tool error: `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:15:9 --> $DIR/dbg_macro.rs:11:9
| |
LL | dbg!(n * factorial(n - 1)) LL | dbg!(n * factorial(n - 1))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -44,7 +44,7 @@ LL | n * factorial(n - 1)
| |
error: `dbg!` macro is intended as a debugging tool error: `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:20:5 --> $DIR/dbg_macro.rs:16:5
| |
LL | dbg!(42); LL | dbg!(42);
| ^^^^^^^^ | ^^^^^^^^
@ -55,7 +55,7 @@ LL | 42;
| ^^ | ^^
error: `dbg!` macro is intended as a debugging tool error: `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:21:5 --> $DIR/dbg_macro.rs:17:5
| |
LL | dbg!(dbg!(dbg!(42))); LL | dbg!(dbg!(dbg!(42)));
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
@ -66,7 +66,7 @@ LL | dbg!(dbg!(42));
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
error: `dbg!` macro is intended as a debugging tool error: `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:22:14 --> $DIR/dbg_macro.rs:18:14
| |
LL | foo(3) + dbg!(factorial(4)); LL | foo(3) + dbg!(factorial(4));
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^

View file

@ -48,25 +48,7 @@ fn main() {
println!( println!(
"[{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}], [{:?}]", "[{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}], [{:?}]",
s1, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19,
s2,
s3,
s4,
s5,
s6,
s7,
s8,
s9,
s10,
s11,
s12,
s13,
s14,
s15,
s16,
s17,
s18,
s19,
); );
} }

View file

@ -48,25 +48,7 @@ fn main() {
println!( println!(
"[{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}], [{:?}]", "[{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}], [{:?}]",
s1, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19,
s2,
s3,
s4,
s5,
s6,
s7,
s8,
s9,
s10,
s11,
s12,
s13,
s14,
s15,
s16,
s17,
s18,
s19,
); );
} }

View file

@ -30,11 +30,7 @@ pub fn inner_body(opt: Option<u32>) {
/// This needs to be documented /// This needs to be documented
pub fn unreachable_and_panic() { pub fn unreachable_and_panic() {
if true { if true { unreachable!() } else { panic!() }
unreachable!()
} else {
panic!()
}
} }
/// This is documented /// This is documented
@ -84,11 +80,7 @@ pub fn todo_documented() {
/// ///
/// We still need to do this part /// We still need to do this part
pub fn unreachable_amd_panic_documented() { pub fn unreachable_amd_panic_documented() {
if true { if true { unreachable!() } else { panic!() }
unreachable!()
} else {
panic!()
}
} }
/// This is okay because it is private /// This is okay because it is private

View file

@ -67,19 +67,15 @@ error: docs for function which may panic missing `# Panics` section
--> $DIR/doc_panics.rs:32:1 --> $DIR/doc_panics.rs:32:1
| |
LL | / pub fn unreachable_and_panic() { LL | / pub fn unreachable_and_panic() {
LL | | if true { LL | | if true { unreachable!() } else { panic!() }
LL | | unreachable!()
LL | | } else {
LL | | panic!()
LL | | }
LL | | } LL | | }
| |_^ | |_^
| |
note: first possible panic found here note: first possible panic found here
--> $DIR/doc_panics.rs:36:9 --> $DIR/doc_panics.rs:33:39
| |
LL | panic!() LL | if true { unreachable!() } else { panic!() }
| ^^^^^^^^ | ^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 5 previous errors error: aborting due to 5 previous errors

View file

@ -21,19 +21,11 @@ where
} }
fn eq_fl(x: f32, y: f32) -> bool { fn eq_fl(x: f32, y: f32) -> bool {
if x.is_nan() { if x.is_nan() { y.is_nan() } else { x == y } // no error, inside "eq" fn
y.is_nan()
} else {
x == y
} // no error, inside "eq" fn
} }
fn fl_eq(x: f32, y: f32) -> bool { fn fl_eq(x: f32, y: f32) -> bool {
if x.is_nan() { if x.is_nan() { y.is_nan() } else { x == y } // no error, inside "eq" fn
y.is_nan()
} else {
x == y
} // no error, inside "eq" fn
} }
struct X { struct X {

View file

@ -1,5 +1,5 @@
error: strict comparison of `f32` or `f64` error: strict comparison of `f32` or `f64`
--> $DIR/float_cmp.rs:66:5 --> $DIR/float_cmp.rs:58:5
| |
LL | ONE as f64 != 2.0; LL | ONE as f64 != 2.0;
| ^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(ONE as f64 - 2.0).abs() > error_margin` | ^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(ONE as f64 - 2.0).abs() > error_margin`
@ -8,7 +8,7 @@ LL | ONE as f64 != 2.0;
= note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin`
error: strict comparison of `f32` or `f64` error: strict comparison of `f32` or `f64`
--> $DIR/float_cmp.rs:71:5 --> $DIR/float_cmp.rs:63:5
| |
LL | x == 1.0; LL | x == 1.0;
| ^^^^^^^^ help: consider comparing them within some margin of error: `(x - 1.0).abs() < error_margin` | ^^^^^^^^ help: consider comparing them within some margin of error: `(x - 1.0).abs() < error_margin`
@ -16,7 +16,7 @@ LL | x == 1.0;
= note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin`
error: strict comparison of `f32` or `f64` error: strict comparison of `f32` or `f64`
--> $DIR/float_cmp.rs:74:5 --> $DIR/float_cmp.rs:66:5
| |
LL | twice(x) != twice(ONE as f64); LL | twice(x) != twice(ONE as f64);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(twice(x) - twice(ONE as f64)).abs() > error_margin` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(twice(x) - twice(ONE as f64)).abs() > error_margin`
@ -24,7 +24,7 @@ LL | twice(x) != twice(ONE as f64);
= note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin`
error: strict comparison of `f32` or `f64` error: strict comparison of `f32` or `f64`
--> $DIR/float_cmp.rs:94:5 --> $DIR/float_cmp.rs:86:5
| |
LL | NON_ZERO_ARRAY[i] == NON_ZERO_ARRAY[j]; LL | NON_ZERO_ARRAY[i] == NON_ZERO_ARRAY[j];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(NON_ZERO_ARRAY[i] - NON_ZERO_ARRAY[j]).abs() < error_margin` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(NON_ZERO_ARRAY[i] - NON_ZERO_ARRAY[j]).abs() < error_margin`
@ -32,7 +32,7 @@ LL | NON_ZERO_ARRAY[i] == NON_ZERO_ARRAY[j];
= note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin`
error: strict comparison of `f32` or `f64` arrays error: strict comparison of `f32` or `f64` arrays
--> $DIR/float_cmp.rs:99:5 --> $DIR/float_cmp.rs:91:5
| |
LL | a1 == a2; LL | a1 == a2;
| ^^^^^^^^ | ^^^^^^^^
@ -40,7 +40,7 @@ LL | a1 == a2;
= note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin`
error: strict comparison of `f32` or `f64` error: strict comparison of `f32` or `f64`
--> $DIR/float_cmp.rs:100:5 --> $DIR/float_cmp.rs:92:5
| |
LL | a1[0] == a2[0]; LL | a1[0] == a2[0];
| ^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(a1[0] - a2[0]).abs() < error_margin` | ^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(a1[0] - a2[0]).abs() < error_margin`

View file

@ -8,11 +8,7 @@ const ONE: f32 = 1.0;
const TWO: f32 = 2.0; const TWO: f32 = 2.0;
fn eq_one(x: f32) -> bool { fn eq_one(x: f32) -> bool {
if x.is_nan() { if x.is_nan() { false } else { x == ONE } // no error, inside "eq" fn
false
} else {
x == ONE
} // no error, inside "eq" fn
} }
fn main() { fn main() {

View file

@ -1,5 +1,5 @@
error: strict comparison of `f32` or `f64` constant error: strict comparison of `f32` or `f64` constant
--> $DIR/float_cmp_const.rs:20:5 --> $DIR/float_cmp_const.rs:16:5
| |
LL | 1f32 == ONE; LL | 1f32 == ONE;
| ^^^^^^^^^^^ help: consider comparing them within some margin of error: `(1f32 - ONE).abs() < error_margin` | ^^^^^^^^^^^ help: consider comparing them within some margin of error: `(1f32 - ONE).abs() < error_margin`
@ -8,7 +8,7 @@ LL | 1f32 == ONE;
= note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin`
error: strict comparison of `f32` or `f64` constant error: strict comparison of `f32` or `f64` constant
--> $DIR/float_cmp_const.rs:21:5 --> $DIR/float_cmp_const.rs:17:5
| |
LL | TWO == ONE; LL | TWO == ONE;
| ^^^^^^^^^^ help: consider comparing them within some margin of error: `(TWO - ONE).abs() < error_margin` | ^^^^^^^^^^ help: consider comparing them within some margin of error: `(TWO - ONE).abs() < error_margin`
@ -16,7 +16,7 @@ LL | TWO == ONE;
= note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin`
error: strict comparison of `f32` or `f64` constant error: strict comparison of `f32` or `f64` constant
--> $DIR/float_cmp_const.rs:22:5 --> $DIR/float_cmp_const.rs:18:5
| |
LL | TWO != ONE; LL | TWO != ONE;
| ^^^^^^^^^^ help: consider comparing them within some margin of error: `(TWO - ONE).abs() > error_margin` | ^^^^^^^^^^ help: consider comparing them within some margin of error: `(TWO - ONE).abs() > error_margin`
@ -24,7 +24,7 @@ LL | TWO != ONE;
= note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin`
error: strict comparison of `f32` or `f64` constant error: strict comparison of `f32` or `f64` constant
--> $DIR/float_cmp_const.rs:23:5 --> $DIR/float_cmp_const.rs:19:5
| |
LL | ONE + ONE == TWO; LL | ONE + ONE == TWO;
| ^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(ONE + ONE - TWO).abs() < error_margin` | ^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(ONE + ONE - TWO).abs() < error_margin`
@ -32,7 +32,7 @@ LL | ONE + ONE == TWO;
= note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin`
error: strict comparison of `f32` or `f64` constant error: strict comparison of `f32` or `f64` constant
--> $DIR/float_cmp_const.rs:25:5 --> $DIR/float_cmp_const.rs:21:5
| |
LL | x as f32 == ONE; LL | x as f32 == ONE;
| ^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x as f32 - ONE).abs() < error_margin` | ^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x as f32 - ONE).abs() < error_margin`
@ -40,7 +40,7 @@ LL | x as f32 == ONE;
= note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin`
error: strict comparison of `f32` or `f64` constant error: strict comparison of `f32` or `f64` constant
--> $DIR/float_cmp_const.rs:28:5 --> $DIR/float_cmp_const.rs:24:5
| |
LL | v == ONE; LL | v == ONE;
| ^^^^^^^^ help: consider comparing them within some margin of error: `(v - ONE).abs() < error_margin` | ^^^^^^^^ help: consider comparing them within some margin of error: `(v - ONE).abs() < error_margin`
@ -48,7 +48,7 @@ LL | v == ONE;
= note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin`
error: strict comparison of `f32` or `f64` constant error: strict comparison of `f32` or `f64` constant
--> $DIR/float_cmp_const.rs:29:5 --> $DIR/float_cmp_const.rs:25:5
| |
LL | v != ONE; LL | v != ONE;
| ^^^^^^^^ help: consider comparing them within some margin of error: `(v - ONE).abs() > error_margin` | ^^^^^^^^ help: consider comparing them within some margin of error: `(v - ONE).abs() > error_margin`
@ -56,7 +56,7 @@ LL | v != ONE;
= note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin`
error: strict comparison of `f32` or `f64` constant arrays error: strict comparison of `f32` or `f64` constant arrays
--> $DIR/float_cmp_const.rs:61:5 --> $DIR/float_cmp_const.rs:57:5
| |
LL | NON_ZERO_ARRAY == NON_ZERO_ARRAY2; LL | NON_ZERO_ARRAY == NON_ZERO_ARRAY2;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -42,43 +42,23 @@ fn fake_nabs3(a: A) -> A {
} }
fn not_fake_abs1(num: f64) -> f64 { fn not_fake_abs1(num: f64) -> f64 {
if num > 0.0 { if num > 0.0 { num } else { -num - 1f64 }
num
} else {
-num - 1f64
}
} }
fn not_fake_abs2(num: f64) -> f64 { fn not_fake_abs2(num: f64) -> f64 {
if num > 0.0 { if num > 0.0 { num + 1.0 } else { -(num + 1.0) }
num + 1.0
} else {
-(num + 1.0)
}
} }
fn not_fake_abs3(num1: f64, num2: f64) -> f64 { fn not_fake_abs3(num1: f64, num2: f64) -> f64 {
if num1 > 0.0 { if num1 > 0.0 { num2 } else { -num2 }
num2
} else {
-num2
}
} }
fn not_fake_abs4(a: A) -> f64 { fn not_fake_abs4(a: A) -> f64 {
if a.a > 0.0 { if a.a > 0.0 { a.b } else { -a.b }
a.b
} else {
-a.b
}
} }
fn not_fake_abs5(a: A) -> f64 { fn not_fake_abs5(a: A) -> f64 {
if a.a > 0.0 { if a.a > 0.0 { a.a } else { -a.b }
a.a
} else {
-a.b
}
} }
fn main() { fn main() {

View file

@ -7,59 +7,31 @@ struct A {
} }
fn fake_abs1(num: f64) -> f64 { fn fake_abs1(num: f64) -> f64 {
if num >= 0.0 { if num >= 0.0 { num } else { -num }
num
} else {
-num
}
} }
fn fake_abs2(num: f64) -> f64 { fn fake_abs2(num: f64) -> f64 {
if 0.0 < num { if 0.0 < num { num } else { -num }
num
} else {
-num
}
} }
fn fake_abs3(a: A) -> f64 { fn fake_abs3(a: A) -> f64 {
if a.a > 0.0 { if a.a > 0.0 { a.a } else { -a.a }
a.a
} else {
-a.a
}
} }
fn fake_abs4(num: f64) -> f64 { fn fake_abs4(num: f64) -> f64 {
if 0.0 >= num { if 0.0 >= num { -num } else { num }
-num
} else {
num
}
} }
fn fake_abs5(a: A) -> f64 { fn fake_abs5(a: A) -> f64 {
if a.a < 0.0 { if a.a < 0.0 { -a.a } else { a.a }
-a.a
} else {
a.a
}
} }
fn fake_nabs1(num: f64) -> f64 { fn fake_nabs1(num: f64) -> f64 {
if num < 0.0 { if num < 0.0 { num } else { -num }
num
} else {
-num
}
} }
fn fake_nabs2(num: f64) -> f64 { fn fake_nabs2(num: f64) -> f64 {
if 0.0 >= num { if 0.0 >= num { num } else { -num }
num
} else {
-num
}
} }
fn fake_nabs3(a: A) -> A { fn fake_nabs3(a: A) -> A {
@ -70,43 +42,23 @@ fn fake_nabs3(a: A) -> A {
} }
fn not_fake_abs1(num: f64) -> f64 { fn not_fake_abs1(num: f64) -> f64 {
if num > 0.0 { if num > 0.0 { num } else { -num - 1f64 }
num
} else {
-num - 1f64
}
} }
fn not_fake_abs2(num: f64) -> f64 { fn not_fake_abs2(num: f64) -> f64 {
if num > 0.0 { if num > 0.0 { num + 1.0 } else { -(num + 1.0) }
num + 1.0
} else {
-(num + 1.0)
}
} }
fn not_fake_abs3(num1: f64, num2: f64) -> f64 { fn not_fake_abs3(num1: f64, num2: f64) -> f64 {
if num1 > 0.0 { if num1 > 0.0 { num2 } else { -num2 }
num2
} else {
-num2
}
} }
fn not_fake_abs4(a: A) -> f64 { fn not_fake_abs4(a: A) -> f64 {
if a.a > 0.0 { if a.a > 0.0 { a.b } else { -a.b }
a.b
} else {
-a.b
}
} }
fn not_fake_abs5(a: A) -> f64 { fn not_fake_abs5(a: A) -> f64 {
if a.a > 0.0 { if a.a > 0.0 { a.a } else { -a.b }
a.a
} else {
-a.b
}
} }
fn main() { fn main() {

View file

@ -1,77 +1,49 @@
error: manual implementation of `abs` method error: manual implementation of `abs` method
--> $DIR/floating_point_abs.rs:10:5 --> $DIR/floating_point_abs.rs:10:5
| |
LL | / if num >= 0.0 { LL | if num >= 0.0 { num } else { -num }
LL | | num | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()`
LL | | } else {
LL | | -num
LL | | }
| |_____^ help: try: `num.abs()`
| |
= note: `-D clippy::suboptimal-flops` implied by `-D warnings` = note: `-D clippy::suboptimal-flops` implied by `-D warnings`
error: manual implementation of `abs` method
--> $DIR/floating_point_abs.rs:14:5
|
LL | if 0.0 < num { num } else { -num }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()`
error: manual implementation of `abs` method error: manual implementation of `abs` method
--> $DIR/floating_point_abs.rs:18:5 --> $DIR/floating_point_abs.rs:18:5
| |
LL | / if 0.0 < num { LL | if a.a > 0.0 { a.a } else { -a.a }
LL | | num | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.a.abs()`
LL | | } else {
LL | | -num error: manual implementation of `abs` method
LL | | } --> $DIR/floating_point_abs.rs:22:5
| |_____^ help: try: `num.abs()` |
LL | if 0.0 >= num { -num } else { num }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()`
error: manual implementation of `abs` method error: manual implementation of `abs` method
--> $DIR/floating_point_abs.rs:26:5 --> $DIR/floating_point_abs.rs:26:5
| |
LL | / if a.a > 0.0 { LL | if a.a < 0.0 { -a.a } else { a.a }
LL | | a.a | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.a.abs()`
LL | | } else {
LL | | -a.a
LL | | }
| |_____^ help: try: `a.a.abs()`
error: manual implementation of `abs` method error: manual implementation of negation of `abs` method
--> $DIR/floating_point_abs.rs:30:5
|
LL | if num < 0.0 { num } else { -num }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-num.abs()`
error: manual implementation of negation of `abs` method
--> $DIR/floating_point_abs.rs:34:5 --> $DIR/floating_point_abs.rs:34:5
| |
LL | / if 0.0 >= num { LL | if 0.0 >= num { num } else { -num }
LL | | -num | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-num.abs()`
LL | | } else {
LL | | num
LL | | }
| |_____^ help: try: `num.abs()`
error: manual implementation of `abs` method
--> $DIR/floating_point_abs.rs:42:5
|
LL | / if a.a < 0.0 {
LL | | -a.a
LL | | } else {
LL | | a.a
LL | | }
| |_____^ help: try: `a.a.abs()`
error: manual implementation of negation of `abs` method error: manual implementation of negation of `abs` method
--> $DIR/floating_point_abs.rs:50:5 --> $DIR/floating_point_abs.rs:39:12
|
LL | / if num < 0.0 {
LL | | num
LL | | } else {
LL | | -num
LL | | }
| |_____^ help: try: `-num.abs()`
error: manual implementation of negation of `abs` method
--> $DIR/floating_point_abs.rs:58:5
|
LL | / if 0.0 >= num {
LL | | num
LL | | } else {
LL | | -num
LL | | }
| |_____^ help: try: `-num.abs()`
error: manual implementation of negation of `abs` method
--> $DIR/floating_point_abs.rs:67:12
| |
LL | a: if a.a >= 0.0 { -a.a } else { a.a }, LL | a: if a.a >= 0.0 { -a.a } else { a.a },
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-a.a.abs()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-a.a.abs()`

View file

@ -3,19 +3,11 @@
#![warn(clippy::if_let_some_result)] #![warn(clippy::if_let_some_result)]
fn str_to_int(x: &str) -> i32 { fn str_to_int(x: &str) -> i32 {
if let Ok(y) = x.parse() { if let Ok(y) = x.parse() { y } else { 0 }
y
} else {
0
}
} }
fn str_to_int_ok(x: &str) -> i32 { fn str_to_int_ok(x: &str) -> i32 {
if let Ok(y) = x.parse() { if let Ok(y) = x.parse() { y } else { 0 }
y
} else {
0
}
} }
#[rustfmt::skip] #[rustfmt::skip]

View file

@ -3,19 +3,11 @@
#![warn(clippy::if_let_some_result)] #![warn(clippy::if_let_some_result)]
fn str_to_int(x: &str) -> i32 { fn str_to_int(x: &str) -> i32 {
if let Some(y) = x.parse().ok() { if let Some(y) = x.parse().ok() { y } else { 0 }
y
} else {
0
}
} }
fn str_to_int_ok(x: &str) -> i32 { fn str_to_int_ok(x: &str) -> i32 {
if let Ok(y) = x.parse() { if let Ok(y) = x.parse() { y } else { 0 }
y
} else {
0
}
} }
#[rustfmt::skip] #[rustfmt::skip]

View file

@ -1,17 +1,17 @@
error: matching on `Some` with `ok()` is redundant error: matching on `Some` with `ok()` is redundant
--> $DIR/if_let_some_result.rs:6:5 --> $DIR/if_let_some_result.rs:6:5
| |
LL | if let Some(y) = x.parse().ok() { LL | if let Some(y) = x.parse().ok() { y } else { 0 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
= note: `-D clippy::if-let-some-result` implied by `-D warnings` = note: `-D clippy::if-let-some-result` implied by `-D warnings`
help: consider matching on `Ok(y)` and removing the call to `ok` instead help: consider matching on `Ok(y)` and removing the call to `ok` instead
| |
LL | if let Ok(y) = x.parse() { LL | if let Ok(y) = x.parse() { y } else { 0 }
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^
error: matching on `Some` with `ok()` is redundant error: matching on `Some` with `ok()` is redundant
--> $DIR/if_let_some_result.rs:24:9 --> $DIR/if_let_some_result.rs:16:9
| |
LL | if let Some(y) = x . parse() . ok () { LL | if let Some(y) = x . parse() . ok () {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -14,11 +14,7 @@ fn test_end_of_fn() -> bool {
#[allow(clippy::needless_bool)] #[allow(clippy::needless_bool)]
fn test_if_block() -> bool { fn test_if_block() -> bool {
if true { if true { return true } else { return false }
return true
} else {
return false
}
} }
#[rustfmt::skip] #[rustfmt::skip]

View file

@ -14,11 +14,7 @@ fn test_end_of_fn() -> bool {
#[allow(clippy::needless_bool)] #[allow(clippy::needless_bool)]
fn test_if_block() -> bool { fn test_if_block() -> bool {
if true { if true { true } else { false }
true
} else {
false
}
} }
#[rustfmt::skip] #[rustfmt::skip]

View file

@ -7,61 +7,61 @@ LL | true
= note: `-D clippy::implicit-return` implied by `-D warnings` = note: `-D clippy::implicit-return` implied by `-D warnings`
error: missing `return` statement error: missing `return` statement
--> $DIR/implicit_return.rs:18:9 --> $DIR/implicit_return.rs:17:15
| |
LL | true LL | if true { true } else { false }
| ^^^^ help: add `return` as shown: `return true` | ^^^^ help: add `return` as shown: `return true`
error: missing `return` statement error: missing `return` statement
--> $DIR/implicit_return.rs:20:9 --> $DIR/implicit_return.rs:17:29
| |
LL | false LL | if true { true } else { false }
| ^^^^^ help: add `return` as shown: `return false` | ^^^^^ help: add `return` as shown: `return false`
error: missing `return` statement error: missing `return` statement
--> $DIR/implicit_return.rs:27:17 --> $DIR/implicit_return.rs:23:17
| |
LL | true => false, LL | true => false,
| ^^^^^ help: add `return` as shown: `return false` | ^^^^^ help: add `return` as shown: `return false`
error: missing `return` statement error: missing `return` statement
--> $DIR/implicit_return.rs:28:20 --> $DIR/implicit_return.rs:24:20
| |
LL | false => { true }, LL | false => { true },
| ^^^^ help: add `return` as shown: `return true` | ^^^^ help: add `return` as shown: `return true`
error: missing `return` statement error: missing `return` statement
--> $DIR/implicit_return.rs:43:9 --> $DIR/implicit_return.rs:39:9
| |
LL | break true; LL | break true;
| ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true`
error: missing `return` statement error: missing `return` statement
--> $DIR/implicit_return.rs:51:13 --> $DIR/implicit_return.rs:47:13
| |
LL | break true; LL | break true;
| ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true`
error: missing `return` statement error: missing `return` statement
--> $DIR/implicit_return.rs:60:13 --> $DIR/implicit_return.rs:56:13
| |
LL | break true; LL | break true;
| ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true`
error: missing `return` statement error: missing `return` statement
--> $DIR/implicit_return.rs:78:18 --> $DIR/implicit_return.rs:74:18
| |
LL | let _ = || { true }; LL | let _ = || { true };
| ^^^^ help: add `return` as shown: `return true` | ^^^^ help: add `return` as shown: `return true`
error: missing `return` statement error: missing `return` statement
--> $DIR/implicit_return.rs:79:16 --> $DIR/implicit_return.rs:75:16
| |
LL | let _ = || true; LL | let _ = || true;
| ^^^^ help: add `return` as shown: `return true` | ^^^^ help: add `return` as shown: `return true`
error: missing `return` statement error: missing `return` statement
--> $DIR/implicit_return.rs:87:5 --> $DIR/implicit_return.rs:83:5
| |
LL | format!("test {}", "test") LL | format!("test {}", "test")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add `return` as shown: `return format!("test {}", "test")` | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add `return` as shown: `return format!("test {}", "test")`

View file

@ -105,11 +105,7 @@ fn fn_bound_3_cannot_elide() {
// No error; multiple input refs. // No error; multiple input refs.
fn fn_bound_4<'a, F: FnOnce() -> &'a ()>(cond: bool, x: &'a (), f: F) -> &'a () { fn fn_bound_4<'a, F: FnOnce() -> &'a ()>(cond: bool, x: &'a (), f: F) -> &'a () {
if cond { if cond { x } else { f() }
x
} else {
f()
}
} }
struct X { struct X {

View file

@ -43,109 +43,109 @@ LL | fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
--> $DIR/needless_lifetimes.rs:120:5 --> $DIR/needless_lifetimes.rs:116:5
| |
LL | fn self_and_out<'s>(&'s self) -> &'s u8 { LL | fn self_and_out<'s>(&'s self) -> &'s u8 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
--> $DIR/needless_lifetimes.rs:129:5 --> $DIR/needless_lifetimes.rs:125:5
| |
LL | fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) {} LL | fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
--> $DIR/needless_lifetimes.rs:148:1 --> $DIR/needless_lifetimes.rs:144:1
| |
LL | fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str { LL | fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
--> $DIR/needless_lifetimes.rs:178:1 --> $DIR/needless_lifetimes.rs:174:1
| |
LL | fn trait_obj_elided2<'a>(_arg: &'a dyn Drop) -> &'a str { LL | fn trait_obj_elided2<'a>(_arg: &'a dyn Drop) -> &'a str {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
--> $DIR/needless_lifetimes.rs:184:1 --> $DIR/needless_lifetimes.rs:180:1
| |
LL | fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str { LL | fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
--> $DIR/needless_lifetimes.rs:203:1 --> $DIR/needless_lifetimes.rs:199:1
| |
LL | fn named_input_elided_output<'a>(_arg: &'a str) -> &str { LL | fn named_input_elided_output<'a>(_arg: &'a str) -> &str {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
--> $DIR/needless_lifetimes.rs:211:1 --> $DIR/needless_lifetimes.rs:207:1
| |
LL | fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { LL | fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
--> $DIR/needless_lifetimes.rs:247:1 --> $DIR/needless_lifetimes.rs:243:1
| |
LL | fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> { LL | fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
--> $DIR/needless_lifetimes.rs:254:9 --> $DIR/needless_lifetimes.rs:250:9
| |
LL | fn needless_lt<'a>(x: &'a u8) {} LL | fn needless_lt<'a>(x: &'a u8) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
--> $DIR/needless_lifetimes.rs:258:9 --> $DIR/needless_lifetimes.rs:254:9
| |
LL | fn needless_lt<'a>(_x: &'a u8) {} LL | fn needless_lt<'a>(_x: &'a u8) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
--> $DIR/needless_lifetimes.rs:271:9 --> $DIR/needless_lifetimes.rs:267:9
| |
LL | fn baz<'a>(&'a self) -> impl Foo + 'a { LL | fn baz<'a>(&'a self) -> impl Foo + 'a {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
--> $DIR/needless_lifetimes.rs:300:5 --> $DIR/needless_lifetimes.rs:296:5
| |
LL | fn impl_trait_elidable_nested_named_lifetimes<'a>(i: &'a i32, f: impl for<'b> Fn(&'b i32) -> &'b i32) -> &'a i32 { LL | fn impl_trait_elidable_nested_named_lifetimes<'a>(i: &'a i32, f: impl for<'b> Fn(&'b i32) -> &'b i32) -> &'a i32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
--> $DIR/needless_lifetimes.rs:303:5 --> $DIR/needless_lifetimes.rs:299:5
| |
LL | fn impl_trait_elidable_nested_anonymous_lifetimes<'a>(i: &'a i32, f: impl Fn(&i32) -> &i32) -> &'a i32 { LL | fn impl_trait_elidable_nested_anonymous_lifetimes<'a>(i: &'a i32, f: impl Fn(&i32) -> &i32) -> &'a i32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
--> $DIR/needless_lifetimes.rs:312:5 --> $DIR/needless_lifetimes.rs:308:5
| |
LL | fn generics_elidable<'a, T: Fn(&i32) -> &i32>(i: &'a i32, f: T) -> &'a i32 { LL | fn generics_elidable<'a, T: Fn(&i32) -> &i32>(i: &'a i32, f: T) -> &'a i32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
--> $DIR/needless_lifetimes.rs:324:5 --> $DIR/needless_lifetimes.rs:320:5
| |
LL | fn where_clause_elidadable<'a, T>(i: &'a i32, f: T) -> &'a i32 LL | fn where_clause_elidadable<'a, T>(i: &'a i32, f: T) -> &'a i32
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
--> $DIR/needless_lifetimes.rs:339:5 --> $DIR/needless_lifetimes.rs:335:5
| |
LL | fn pointer_fn_elidable<'a>(i: &'a i32, f: fn(&i32) -> &i32) -> &'a i32 { LL | fn pointer_fn_elidable<'a>(i: &'a i32, f: fn(&i32) -> &i32) -> &'a i32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
--> $DIR/needless_lifetimes.rs:352:5 --> $DIR/needless_lifetimes.rs:348:5
| |
LL | fn nested_fn_pointer_3<'a>(_: &'a i32) -> fn(fn(&i32) -> &i32) -> i32 { LL | fn nested_fn_pointer_3<'a>(_: &'a i32) -> fn(fn(&i32) -> &i32) -> i32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
--> $DIR/needless_lifetimes.rs:355:5 --> $DIR/needless_lifetimes.rs:351:5
| |
LL | fn nested_fn_pointer_4<'a>(_: &'a i32) -> impl Fn(fn(&i32)) { LL | fn nested_fn_pointer_4<'a>(_: &'a i32) -> impl Fn(fn(&i32)) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -59,11 +59,7 @@ fn main() {
#[derive(Clone)] #[derive(Clone)]
struct Alpha; struct Alpha;
fn with_branch(a: Alpha, b: bool) -> (Alpha, Alpha) { fn with_branch(a: Alpha, b: bool) -> (Alpha, Alpha) {
if b { if b { (a.clone(), a) } else { (Alpha, a) }
(a.clone(), a)
} else {
(Alpha, a)
}
} }
fn cannot_double_move(a: Alpha) -> (Alpha, Alpha) { fn cannot_double_move(a: Alpha) -> (Alpha, Alpha) {

View file

@ -59,11 +59,7 @@ fn main() {
#[derive(Clone)] #[derive(Clone)]
struct Alpha; struct Alpha;
fn with_branch(a: Alpha, b: bool) -> (Alpha, Alpha) { fn with_branch(a: Alpha, b: bool) -> (Alpha, Alpha) {
if b { if b { (a.clone(), a.clone()) } else { (Alpha, a) }
(a.clone(), a.clone())
} else {
(Alpha, a)
}
} }
fn cannot_double_move(a: Alpha) -> (Alpha, Alpha) { fn cannot_double_move(a: Alpha) -> (Alpha, Alpha) {

View file

@ -108,61 +108,61 @@ LL | let _t = tup.0.clone();
| ^^^^^ | ^^^^^
error: redundant clone error: redundant clone
--> $DIR/redundant_clone.rs:63:22 --> $DIR/redundant_clone.rs:62:25
| |
LL | (a.clone(), a.clone()) LL | if b { (a.clone(), a.clone()) } else { (Alpha, a) }
| ^^^^^^^^ help: remove this | ^^^^^^^^ help: remove this
| |
note: this value is dropped without further use note: this value is dropped without further use
--> $DIR/redundant_clone.rs:63:21 --> $DIR/redundant_clone.rs:62:24
| |
LL | (a.clone(), a.clone()) LL | if b { (a.clone(), a.clone()) } else { (Alpha, a) }
| ^ | ^
error: redundant clone error: redundant clone
--> $DIR/redundant_clone.rs:123:15 --> $DIR/redundant_clone.rs:119:15
| |
LL | let _s = s.clone(); LL | let _s = s.clone();
| ^^^^^^^^ help: remove this | ^^^^^^^^ help: remove this
| |
note: this value is dropped without further use note: this value is dropped without further use
--> $DIR/redundant_clone.rs:123:14 --> $DIR/redundant_clone.rs:119:14
| |
LL | let _s = s.clone(); LL | let _s = s.clone();
| ^ | ^
error: redundant clone error: redundant clone
--> $DIR/redundant_clone.rs:124:15 --> $DIR/redundant_clone.rs:120:15
| |
LL | let _t = t.clone(); LL | let _t = t.clone();
| ^^^^^^^^ help: remove this | ^^^^^^^^ help: remove this
| |
note: this value is dropped without further use note: this value is dropped without further use
--> $DIR/redundant_clone.rs:124:14 --> $DIR/redundant_clone.rs:120:14
| |
LL | let _t = t.clone(); LL | let _t = t.clone();
| ^ | ^
error: redundant clone error: redundant clone
--> $DIR/redundant_clone.rs:134:19 --> $DIR/redundant_clone.rs:130:19
| |
LL | let _f = f.clone(); LL | let _f = f.clone();
| ^^^^^^^^ help: remove this | ^^^^^^^^ help: remove this
| |
note: this value is dropped without further use note: this value is dropped without further use
--> $DIR/redundant_clone.rs:134:18 --> $DIR/redundant_clone.rs:130:18
| |
LL | let _f = f.clone(); LL | let _f = f.clone();
| ^ | ^
error: redundant clone error: redundant clone
--> $DIR/redundant_clone.rs:146:14 --> $DIR/redundant_clone.rs:142:14
| |
LL | let y = x.clone().join("matthias"); LL | let y = x.clone().join("matthias");
| ^^^^^^^^ help: remove this | ^^^^^^^^ help: remove this
| |
note: cloned value is neither consumed nor mutated note: cloned value is neither consumed nor mutated
--> $DIR/redundant_clone.rs:146:13 --> $DIR/redundant_clone.rs:142:13
| |
LL | let y = x.clone().join("matthias"); LL | let y = x.clone().join("matthias");
| ^^^^^^^^^ | ^^^^^^^^^

View file

@ -22,29 +22,17 @@ fn func2(a: bool, b: bool) -> Option<i32> {
if a && b { if a && b {
return Some(10); return Some(10);
} }
if a { if a { Some(20) } else { Some(30) }
Some(20)
} else {
Some(30)
}
} }
// public fns should not be linted // public fns should not be linted
pub fn func3(a: bool) -> Option<i32> { pub fn func3(a: bool) -> Option<i32> {
if a { if a { Some(1) } else { Some(1) }
Some(1)
} else {
Some(1)
}
} }
// should not be linted // should not be linted
fn func4(a: bool) -> Option<i32> { fn func4(a: bool) -> Option<i32> {
if a { if a { Some(1) } else { None }
Some(1)
} else {
None
}
} }
// should be linted // should be linted
@ -64,11 +52,7 @@ fn func7() -> Result<i32, ()> {
// should not be linted // should not be linted
fn func8(a: bool) -> Result<i32, ()> { fn func8(a: bool) -> Result<i32, ()> {
if a { if a { Ok(1) } else { Err(()) }
Ok(1)
} else {
Err(())
}
} }
// should not be linted // should not be linted
@ -143,20 +127,12 @@ fn issue_6640_2(a: bool, b: bool) -> Result<(), i32> {
// should not be linted // should not be linted
fn issue_6640_3() -> Option<()> { fn issue_6640_3() -> Option<()> {
if true { if true { Some(()) } else { None }
Some(())
} else {
None
}
} }
// should not be linted // should not be linted
fn issue_6640_4() -> Result<(), ()> { fn issue_6640_4() -> Result<(), ()> {
if true { if true { Ok(()) } else { Err(()) }
Ok(())
} else {
Err(())
}
} }
fn main() { fn main() {

View file

@ -32,8 +32,7 @@ LL | / fn func2(a: bool, b: bool) -> Option<i32> {
LL | | if a && b { LL | | if a && b {
LL | | return Some(10); LL | | return Some(10);
LL | | } LL | | }
... | LL | | if a { Some(20) } else { Some(30) }
LL | | }
LL | | } LL | | }
| |_^ | |_^
| |
@ -45,14 +44,11 @@ help: ...and then change returning expressions
| |
LL | return 10; LL | return 10;
LL | } LL | }
LL | if a { LL | if a { 20 } else { 30 }
LL | 20
LL | } else {
LL | 30
| |
error: this function's return value is unnecessarily wrapped by `Option` error: this function's return value is unnecessarily wrapped by `Option`
--> $DIR/unnecessary_wraps.rs:51:1 --> $DIR/unnecessary_wraps.rs:39:1
| |
LL | / fn func5() -> Option<i32> { LL | / fn func5() -> Option<i32> {
LL | | Some(1) LL | | Some(1)
@ -69,7 +65,7 @@ LL | 1
| |
error: this function's return value is unnecessarily wrapped by `Result` error: this function's return value is unnecessarily wrapped by `Result`
--> $DIR/unnecessary_wraps.rs:61:1 --> $DIR/unnecessary_wraps.rs:49:1
| |
LL | / fn func7() -> Result<i32, ()> { LL | / fn func7() -> Result<i32, ()> {
LL | | Ok(1) LL | | Ok(1)
@ -86,7 +82,7 @@ LL | 1
| |
error: this function's return value is unnecessarily wrapped by `Option` error: this function's return value is unnecessarily wrapped by `Option`
--> $DIR/unnecessary_wraps.rs:93:5 --> $DIR/unnecessary_wraps.rs:77:5
| |
LL | / fn func12() -> Option<i32> { LL | / fn func12() -> Option<i32> {
LL | | Some(1) LL | | Some(1)
@ -103,7 +99,7 @@ LL | 1
| |
error: this function's return value is unnecessary error: this function's return value is unnecessary
--> $DIR/unnecessary_wraps.rs:120:1 --> $DIR/unnecessary_wraps.rs:104:1
| |
LL | / fn issue_6640_1(a: bool, b: bool) -> Option<()> { LL | / fn issue_6640_1(a: bool, b: bool) -> Option<()> {
LL | | if a && b { LL | | if a && b {
@ -129,7 +125,7 @@ LL | } else {
... ...
error: this function's return value is unnecessary error: this function's return value is unnecessary
--> $DIR/unnecessary_wraps.rs:133:1 --> $DIR/unnecessary_wraps.rs:117:1
| |
LL | / fn issue_6640_2(a: bool, b: bool) -> Result<(), i32> { LL | / fn issue_6640_2(a: bool, b: bool) -> Result<(), i32> {
LL | | if a && b { LL | | if a && b {

View file

@ -16,7 +16,8 @@ enum Flags {
FIN, FIN,
} }
struct GCCLLVMSomething; // linted with cfg option, beware that lint suggests `GccllvmSomething` instead of // linted with cfg option, beware that lint suggests `GccllvmSomething` instead of
// `GccLlvmSomething` // `GccLlvmSomething`
struct GCCLLVMSomething;
fn main() {} fn main() {}

View file

@ -329,11 +329,7 @@ mod issue4140 {
type To = Self; type To = Self;
fn from(value: bool) -> Self { fn from(value: bool) -> Self {
if value { if value { 100 } else { 0 }
100
} else {
0
}
} }
} }
} }

View file

@ -329,11 +329,7 @@ mod issue4140 {
type To = Self; type To = Self;
fn from(value: bool) -> Self { fn from(value: bool) -> Self {
if value { if value { 100 } else { 0 }
100
} else {
0
}
} }
} }
} }

View file

@ -169,7 +169,7 @@ LL | type To = T::To;
| ^^^^^ help: use the applicable keyword: `Self` | ^^^^^ help: use the applicable keyword: `Self`
error: unnecessary structure name repetition error: unnecessary structure name repetition
--> $DIR/use_self.rs:457:13 --> $DIR/use_self.rs:453:13
| |
LL | A::new::<submod::B>(submod::B {}) LL | A::new::<submod::B>(submod::B {})
| ^ help: use the applicable keyword: `Self` | ^ help: use the applicable keyword: `Self`