Skip to content

Commit 9e7b895

Browse files
committed
fix clippy tests
1 parent cb71243 commit 9e7b895

2 files changed

Lines changed: 15 additions & 12 deletions

File tree

src/tools/clippy/tests/ui/manual_try_fold.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#![feature(try_trait_v2)]
55
#![feature(try_trait_v2_residual)]
66
//@no-rustfix
7-
use std::ops::{ControlFlow, FromResidual, Residual, Try};
7+
use std::ops::{ControlFlow, FromResidual, Residual, Try, FromOutput, Branch};
88

99
#[macro_use]
1010
extern crate proc_macros;
@@ -24,19 +24,20 @@ impl Residual<()> for NotOptionResidual {
2424
type TryType = NotOption;
2525
}
2626

27-
impl Try for NotOption {
27+
impl Branch for NotOption {
2828
type Output = ();
2929
type Residual = NotOptionResidual;
3030

31-
fn from_output(_: Self::Output) -> Self {
31+
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
3232
todo!()
3333
}
34+
}
3435

35-
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
36+
impl FromOutput for NotOption {
37+
fn from_output(_: Self::Output) -> Self {
3638
todo!()
3739
}
3840
}
39-
4041
// Test custom `Try` with only 1 argument
4142
#[derive(Default)]
4243
struct NotOptionButWorse(i32);
@@ -53,15 +54,17 @@ impl Residual<()> for NotOptionButWorseResidual {
5354
type TryType = NotOptionButWorse;
5455
}
5556

56-
impl Try for NotOptionButWorse {
57+
impl Branch for NotOptionButWorse {
5758
type Output = ();
5859
type Residual = NotOptionButWorseResidual;
5960

60-
fn from_output(_: Self::Output) -> Self {
61+
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
6162
todo!()
6263
}
64+
}
6365

64-
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
66+
impl FromOutput for NotOptionButWorse {
67+
fn from_output(_: Self::Output) -> Self {
6568
todo!()
6669
}
6770
}

src/tools/clippy/tests/ui/manual_try_fold.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: usage of `Iterator::fold` on a type that implements `Try`
2-
--> tests/ui/manual_try_fold.rs:72:10
2+
--> tests/ui/manual_try_fold.rs:75:10
33
|
44
LL | .fold(Some(0i32), |sum, i| sum?.checked_add(*i))
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i| ...)`
@@ -8,19 +8,19 @@ LL | .fold(Some(0i32), |sum, i| sum?.checked_add(*i))
88
= help: to override `-D warnings` add `#[allow(clippy::manual_try_fold)]`
99

1010
error: usage of `Iterator::fold` on a type that implements `Try`
11-
--> tests/ui/manual_try_fold.rs:77:10
11+
--> tests/ui/manual_try_fold.rs:80:10
1212
|
1313
LL | .fold(NotOption(0i32, 0i32), |sum, i| NotOption(0i32, 0i32));
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(..., |sum, i| ...)`
1515

1616
error: usage of `Iterator::fold` on a type that implements `Try`
17-
--> tests/ui/manual_try_fold.rs:81:10
17+
--> tests/ui/manual_try_fold.rs:84:10
1818
|
1919
LL | .fold(NotOptionButWorse(0i32), |sum, i| NotOptionButWorse(0i32));
2020
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i| ...)`
2121

2222
error: usage of `Iterator::fold` on a type that implements `Try`
23-
--> tests/ui/manual_try_fold.rs:112:10
23+
--> tests/ui/manual_try_fold.rs:115:10
2424
|
2525
LL | .fold(Some(0i32), |sum, i| sum?.checked_add(*i))
2626
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i| ...)`

0 commit comments

Comments
 (0)