Skip to content

Commit 8bc1aa3

Browse files
committed
Auto merge of #155380 - jhpratt:rollup-j1e7DVL, r=jhpratt
Rollup of 18 pull requests Successful merges: - #154451 (Require that a `<_ as Try>::Residual` implement the `Residual` trait) - #154595 (Emit fatal on invalid const args with nested defs) - #154599 (report the `varargs_without_pattern` lint in deps) - #154699 (`core::unicode`: Replace `Cased` table with `Lt`) - #155353 (resolve: Remove `inaccessible_ctor_reexport` resolver field) - #155357 (Add `--remap-path-scope` as unstable in rustdoc) - #150649 (clippy fix: non_canonical_clone_impl) - #154604 (abort in core) - #154616 (Add `--quiet` flag to x.py and bootstrap to suppress output) - #155215 (Clean up `AttributeLintKind` and refactor diagnostic attribute linting) - #155228 (Check diagnostic output in incremental `cpass` and `rpass` revisions) - #155266 (Adjust release notes for post-merge feedback) - #155326 (Disallow ZST allocations with `TypedArena`.) - #155334 (docs: Use `0b1` instead of `NonZero::MIN` in `NonZero::bit_width` doctests) - #155340 (Handle nonnull pattern types in size skeleton) - #155347 (Add push_mut and new Layout methods to release notes) - #155356 (remove calls to AliasTyKind::def_id) - #155364 (Reduce diagnostic type visibilities.)
2 parents 23d7346 + 9b5a48b commit 8bc1aa3

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

tests/ui/manual_try_fold.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,31 @@
22
#![allow(clippy::unnecessary_fold, unused)]
33
#![warn(clippy::manual_try_fold)]
44
#![feature(try_trait_v2)]
5+
#![feature(try_trait_v2_residual)]
56
//@no-rustfix
6-
use std::ops::{ControlFlow, FromResidual, Try};
7+
use std::ops::{ControlFlow, FromResidual, Residual, Try};
78

89
#[macro_use]
910
extern crate proc_macros;
1011

1112
// Test custom `Try` with more than 1 argument
1213
struct NotOption(i32, i32);
1314

15+
struct NotOptionResidual;
16+
1417
impl<R> FromResidual<R> for NotOption {
1518
fn from_residual(_: R) -> Self {
1619
todo!()
1720
}
1821
}
1922

23+
impl Residual<()> for NotOptionResidual {
24+
type TryType = NotOption;
25+
}
26+
2027
impl Try for NotOption {
2128
type Output = ();
22-
type Residual = ();
29+
type Residual = NotOptionResidual;
2330

2431
fn from_output(_: Self::Output) -> Self {
2532
todo!()
@@ -34,15 +41,21 @@ impl Try for NotOption {
3441
#[derive(Default)]
3542
struct NotOptionButWorse(i32);
3643

44+
struct NotOptionButWorseResidual;
45+
3746
impl<R> FromResidual<R> for NotOptionButWorse {
3847
fn from_residual(_: R) -> Self {
3948
todo!()
4049
}
4150
}
4251

52+
impl Residual<()> for NotOptionButWorseResidual {
53+
type TryType = NotOptionButWorse;
54+
}
55+
4356
impl Try for NotOptionButWorse {
4457
type Output = ();
45-
type Residual = ();
58+
type Residual = NotOptionButWorseResidual;
4659

4760
fn from_output(_: Self::Output) -> Self {
4861
todo!()

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:59:10
2+
--> tests/ui/manual_try_fold.rs:72: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:64:10
11+
--> tests/ui/manual_try_fold.rs:77: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:68:10
17+
--> tests/ui/manual_try_fold.rs:81: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:99:10
23+
--> tests/ui/manual_try_fold.rs:112: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)