add some adjustment regarding review suggestion

This commit is contained in:
J-ZhengLi 2023-02-15 11:26:30 +08:00
parent 8e96adedd5
commit 8b93eb8a9b
4 changed files with 61 additions and 35 deletions

View file

@ -297,8 +297,14 @@ fn issue10051() -> Result<String, String> {
}
}
fn issue10049(b1: bool, b2: bool, b3: bool) -> u32 {
(if b1 { 0 } else { 1 } | if b2 { 2 } else { 3 } | if b3 { 4 } else { 5 })
mod issue10049 {
fn single() -> u32 {
if true { 1 } else { 2 }
}
fn multiple(b1: bool, b2: bool, b3: bool) -> u32 {
(if b1 { 0 } else { 1 } | if b2 { 2 } else { 3 } | if b3 { 4 } else { 5 })
}
}
fn main() {}

View file

@ -307,8 +307,14 @@ fn issue10051() -> Result<String, String> {
}
}
fn issue10049(b1: bool, b2: bool, b3: bool) -> u32 {
return if b1 { 0 } else { 1 } | if b2 { 2 } else { 3 } | if b3 { 4 } else { 5 };
mod issue10049 {
fn single() -> u32 {
return if true { 1 } else { 2 };
}
fn multiple(b1: bool, b2: bool, b3: bool) -> u32 {
return if b1 { 0 } else { 1 } | if b2 { 2 } else { 3 } | if b3 { 4 } else { 5 };
}
}
fn main() {}

View file

@ -419,12 +419,20 @@ LL | return Err(format!("err!"));
= help: remove `return`
error: unneeded `return` statement
--> $DIR/needless_return.rs:311:5
--> $DIR/needless_return.rs:312:9
|
LL | return if b1 { 0 } else { 1 } | if b2 { 2 } else { 3 } | if b3 { 4 } else { 5 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | return if true { 1 } else { 2 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: remove `return`
error: unneeded `return` statement
--> $DIR/needless_return.rs:316:9
|
LL | return if b1 { 0 } else { 1 } | if b2 { 2 } else { 3 } | if b3 { 4 } else { 5 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: remove `return` and wrap the sequence with parentheses
error: aborting due to 51 previous errors
error: aborting due to 52 previous errors