Running rustfmt on test

This commit is contained in:
Joe Frikker 2019-06-30 18:28:12 -04:00
parent 8880677b4f
commit c96bb2c303
3 changed files with 28 additions and 18 deletions

View file

@ -6,7 +6,8 @@
// Should flag `Err(err)?`
pub fn basic_test() -> Result<i32, i32> {
let err: i32 = 1;
if true { // To avoid warnings during rustfix
// To avoid warnings during rustfix
if true {
return Err(err);
}
Ok(0)
@ -15,7 +16,8 @@ pub fn basic_test() -> Result<i32, i32> {
// Tests that `.into()` is added when appropriate
pub fn into_test() -> Result<i32, i32> {
let err: u8 = 1;
if true { // To avoid warnings during rustfix
// To avoid warnings during rustfix
if true {
return Err(err.into());
}
Ok(0)
@ -26,15 +28,16 @@ pub fn negative_test() -> Result<i32, i32> {
Ok(nested_error()? + 1)
}
// Tests that `.into()` isn't added when the error type
// matches the surrounding closure's return type, even
// when it doesn't match the surrounding function's.
pub fn closure_matches_test() -> Result<i32, i32> {
let res: Result<i32, i8> = Some(1).into_iter()
let res: Result<i32, i8> = Some(1)
.into_iter()
.map(|i| {
let err: i8 = 1;
if true { // To avoid warnings during rustfix
// To avoid warnings during rustfix
if true {
return Err(err);
}
Ok(i)
@ -48,10 +51,12 @@ pub fn closure_matches_test() -> Result<i32, i32> {
// Tests that `.into()` isn't added when the error type
// doesn't match the surrounding closure's return type.
pub fn closure_into_test() -> Result<i32, i32> {
let res: Result<i32, i16> = Some(1).into_iter()
let res: Result<i32, i16> = Some(1)
.into_iter()
.map(|i| {
let err: i8 = 1;
if true { // To avoid warnings during rustfix
// To avoid warnings during rustfix
if true {
return Err(err.into());
}
Ok(i)

View file

@ -6,7 +6,8 @@
// Should flag `Err(err)?`
pub fn basic_test() -> Result<i32, i32> {
let err: i32 = 1;
if true { // To avoid warnings during rustfix
// To avoid warnings during rustfix
if true {
Err(err)?;
}
Ok(0)
@ -15,7 +16,8 @@ pub fn basic_test() -> Result<i32, i32> {
// Tests that `.into()` is added when appropriate
pub fn into_test() -> Result<i32, i32> {
let err: u8 = 1;
if true { // To avoid warnings during rustfix
// To avoid warnings during rustfix
if true {
Err(err)?;
}
Ok(0)
@ -26,15 +28,16 @@ pub fn negative_test() -> Result<i32, i32> {
Ok(nested_error()? + 1)
}
// Tests that `.into()` isn't added when the error type
// matches the surrounding closure's return type, even
// when it doesn't match the surrounding function's.
pub fn closure_matches_test() -> Result<i32, i32> {
let res: Result<i32, i8> = Some(1).into_iter()
let res: Result<i32, i8> = Some(1)
.into_iter()
.map(|i| {
let err: i8 = 1;
if true { // To avoid warnings during rustfix
// To avoid warnings during rustfix
if true {
Err(err)?;
}
Ok(i)
@ -48,10 +51,12 @@ pub fn closure_matches_test() -> Result<i32, i32> {
// Tests that `.into()` isn't added when the error type
// doesn't match the surrounding closure's return type.
pub fn closure_into_test() -> Result<i32, i32> {
let res: Result<i32, i16> = Some(1).into_iter()
let res: Result<i32, i16> = Some(1)
.into_iter()
.map(|i| {
let err: i8 = 1;
if true { // To avoid warnings during rustfix
// To avoid warnings during rustfix
if true {
Err(err)?;
}
Ok(i)

View file

@ -1,5 +1,5 @@
error: returning an `Err(_)` with the `?` operator
--> $DIR/try_err.rs:10:9
--> $DIR/try_err.rs:11:9
|
LL | Err(err)?;
| ^^^^^^^^^ help: try this: `return Err(err)`
@ -11,19 +11,19 @@ LL | #![deny(clippy::try_err)]
| ^^^^^^^^^^^^^^^
error: returning an `Err(_)` with the `?` operator
--> $DIR/try_err.rs:19:9
--> $DIR/try_err.rs:21:9
|
LL | Err(err)?;
| ^^^^^^^^^ help: try this: `return Err(err.into())`
error: returning an `Err(_)` with the `?` operator
--> $DIR/try_err.rs:38:17
--> $DIR/try_err.rs:41:17
|
LL | Err(err)?;
| ^^^^^^^^^ help: try this: `return Err(err)`
error: returning an `Err(_)` with the `?` operator
--> $DIR/try_err.rs:55:17
--> $DIR/try_err.rs:60:17
|
LL | Err(err)?;
| ^^^^^^^^^ help: try this: `return Err(err.into())`