Skip to content

Commit c95707a

Browse files
authored
Rollup merge of #107398 - scottmcm:its-their-funeral, r=dtolnay
Remove `ControlFlow::{BREAK, CONTINUE}` Libs-API decided to remove these in #102697. Follow-up to #107023, which removed them from `compiler/`, but a couple new ones showed up since that was merged. r? libs
2 parents 6bd09e0 + c4fa0d3 commit c95707a

File tree

15 files changed

+28
-74
lines changed

15 files changed

+28
-74
lines changed

compiler/rustc_trait_selection/src/solve/project_goals.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -93,24 +93,24 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
9393
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
9494
if t.needs_infer() {
9595
if ty::Term::from(t) == self.term {
96-
ControlFlow::BREAK
96+
ControlFlow::Break(())
9797
} else {
9898
t.super_visit_with(self)
9999
}
100100
} else {
101-
ControlFlow::CONTINUE
101+
ControlFlow::Continue(())
102102
}
103103
}
104104

105105
fn visit_const(&mut self, c: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
106106
if c.needs_infer() {
107107
if ty::Term::from(c) == self.term {
108-
ControlFlow::BREAK
108+
ControlFlow::Break(())
109109
} else {
110110
c.super_visit_with(self)
111111
}
112112
} else {
113-
ControlFlow::CONTINUE
113+
ControlFlow::Continue(())
114114
}
115115
}
116116
}

library/core/src/iter/adapters/filter_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ where
9999
) -> impl FnMut((), T) -> ControlFlow<B> + '_ {
100100
move |(), x| match f(x) {
101101
Some(x) => ControlFlow::Break(x),
102-
None => ControlFlow::CONTINUE,
102+
None => ControlFlow::Continue(()),
103103
}
104104
}
105105

library/core/src/iter/adapters/flatten.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ where
539539
#[rustc_inherit_overflow_checks]
540540
fn advance<U: Iterator>(n: usize, iter: &mut U) -> ControlFlow<(), usize> {
541541
match iter.advance_by(n) {
542-
Ok(()) => ControlFlow::BREAK,
542+
Ok(()) => ControlFlow::Break(()),
543543
Err(advanced) => ControlFlow::Continue(n - advanced),
544544
}
545545
}
@@ -629,7 +629,7 @@ where
629629
#[rustc_inherit_overflow_checks]
630630
fn advance<U: DoubleEndedIterator>(n: usize, iter: &mut U) -> ControlFlow<(), usize> {
631631
match iter.advance_back_by(n) {
632-
Ok(()) => ControlFlow::BREAK,
632+
Ok(()) => ControlFlow::Break(()),
633633
Err(advanced) => ControlFlow::Continue(n - advanced),
634634
}
635635
}

library/core/src/iter/traits/double_ended.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ pub trait DoubleEndedIterator: Iterator {
352352
#[inline]
353353
fn check<T>(mut predicate: impl FnMut(&T) -> bool) -> impl FnMut((), T) -> ControlFlow<T> {
354354
move |(), x| {
355-
if predicate(&x) { ControlFlow::Break(x) } else { ControlFlow::CONTINUE }
355+
if predicate(&x) { ControlFlow::Break(x) } else { ControlFlow::Continue(()) }
356356
}
357357
}
358358

library/core/src/iter/traits/iterator.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -2601,10 +2601,10 @@ pub trait Iterator {
26012601
#[inline]
26022602
fn check<T>(mut f: impl FnMut(T) -> bool) -> impl FnMut((), T) -> ControlFlow<()> {
26032603
move |(), x| {
2604-
if f(x) { ControlFlow::CONTINUE } else { ControlFlow::BREAK }
2604+
if f(x) { ControlFlow::Continue(()) } else { ControlFlow::Break(()) }
26052605
}
26062606
}
2607-
self.try_fold((), check(f)) == ControlFlow::CONTINUE
2607+
self.try_fold((), check(f)) == ControlFlow::Continue(())
26082608
}
26092609

26102610
/// Tests if any element of the iterator matches a predicate.
@@ -2654,11 +2654,11 @@ pub trait Iterator {
26542654
#[inline]
26552655
fn check<T>(mut f: impl FnMut(T) -> bool) -> impl FnMut((), T) -> ControlFlow<()> {
26562656
move |(), x| {
2657-
if f(x) { ControlFlow::BREAK } else { ControlFlow::CONTINUE }
2657+
if f(x) { ControlFlow::Break(()) } else { ControlFlow::Continue(()) }
26582658
}
26592659
}
26602660

2661-
self.try_fold((), check(f)) == ControlFlow::BREAK
2661+
self.try_fold((), check(f)) == ControlFlow::Break(())
26622662
}
26632663

26642664
/// Searches for an element of an iterator that satisfies a predicate.
@@ -2717,7 +2717,7 @@ pub trait Iterator {
27172717
#[inline]
27182718
fn check<T>(mut predicate: impl FnMut(&T) -> bool) -> impl FnMut((), T) -> ControlFlow<T> {
27192719
move |(), x| {
2720-
if predicate(&x) { ControlFlow::Break(x) } else { ControlFlow::CONTINUE }
2720+
if predicate(&x) { ControlFlow::Break(x) } else { ControlFlow::Continue(()) }
27212721
}
27222722
}
27232723

@@ -2749,7 +2749,7 @@ pub trait Iterator {
27492749
fn check<T, B>(mut f: impl FnMut(T) -> Option<B>) -> impl FnMut((), T) -> ControlFlow<B> {
27502750
move |(), x| match f(x) {
27512751
Some(x) => ControlFlow::Break(x),
2752-
None => ControlFlow::CONTINUE,
2752+
None => ControlFlow::Continue(()),
27532753
}
27542754
}
27552755

@@ -2812,7 +2812,7 @@ pub trait Iterator {
28122812
R: Residual<Option<I>>,
28132813
{
28142814
move |(), x| match f(&x).branch() {
2815-
ControlFlow::Continue(false) => ControlFlow::CONTINUE,
2815+
ControlFlow::Continue(false) => ControlFlow::Continue(()),
28162816
ControlFlow::Continue(true) => ControlFlow::Break(Try::from_output(Some(x))),
28172817
ControlFlow::Break(r) => ControlFlow::Break(FromResidual::from_residual(r)),
28182818
}
@@ -3491,7 +3491,7 @@ pub trait Iterator {
34913491
F: FnMut(X, Y) -> Ordering,
34923492
{
34933493
move |x, y| match cmp(x, y) {
3494-
Ordering::Equal => ControlFlow::CONTINUE,
3494+
Ordering::Equal => ControlFlow::Continue(()),
34953495
non_eq => ControlFlow::Break(non_eq),
34963496
}
34973497
}
@@ -3567,7 +3567,7 @@ pub trait Iterator {
35673567
F: FnMut(X, Y) -> Option<Ordering>,
35683568
{
35693569
move |x, y| match partial_cmp(x, y) {
3570-
Some(Ordering::Equal) => ControlFlow::CONTINUE,
3570+
Some(Ordering::Equal) => ControlFlow::Continue(()),
35713571
non_eq => ControlFlow::Break(non_eq),
35723572
}
35733573
}
@@ -3625,7 +3625,7 @@ pub trait Iterator {
36253625
F: FnMut(X, Y) -> bool,
36263626
{
36273627
move |x, y| {
3628-
if eq(x, y) { ControlFlow::CONTINUE } else { ControlFlow::BREAK }
3628+
if eq(x, y) { ControlFlow::Continue(()) } else { ControlFlow::Break(()) }
36293629
}
36303630
}
36313631

@@ -3859,7 +3859,7 @@ pub trait Iterator {
38593859

38603860
/// Compares two iterators element-wise using the given function.
38613861
///
3862-
/// If `ControlFlow::CONTINUE` is returned from the function, the comparison moves on to the next
3862+
/// If `ControlFlow::Continue(())` is returned from the function, the comparison moves on to the next
38633863
/// elements of both iterators. Returning `ControlFlow::Break(x)` short-circuits the iteration and
38643864
/// returns `ControlFlow::Break(x)`. If one of the iterators runs out of elements,
38653865
/// `ControlFlow::Continue(ord)` is returned where `ord` is the result of comparing the lengths of

library/core/src/ops/control_flow.rs

-43
Original file line numberDiff line numberDiff line change
@@ -259,46 +259,3 @@ impl<R: ops::Try> ControlFlow<R, R::Output> {
259259
}
260260
}
261261
}
262-
263-
impl<B> ControlFlow<B, ()> {
264-
/// It's frequently the case that there's no value needed with `Continue`,
265-
/// so this provides a way to avoid typing `(())`, if you prefer it.
266-
///
267-
/// # Examples
268-
///
269-
/// ```
270-
/// #![feature(control_flow_enum)]
271-
/// use std::ops::ControlFlow;
272-
///
273-
/// let mut partial_sum = 0;
274-
/// let last_used = (1..10).chain(20..25).try_for_each(|x| {
275-
/// partial_sum += x;
276-
/// if partial_sum > 100 { ControlFlow::Break(x) }
277-
/// else { ControlFlow::CONTINUE }
278-
/// });
279-
/// assert_eq!(last_used.break_value(), Some(22));
280-
/// ```
281-
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
282-
pub const CONTINUE: Self = ControlFlow::Continue(());
283-
}
284-
285-
impl<C> ControlFlow<(), C> {
286-
/// APIs like `try_for_each` don't need values with `Break`,
287-
/// so this provides a way to avoid typing `(())`, if you prefer it.
288-
///
289-
/// # Examples
290-
///
291-
/// ```
292-
/// #![feature(control_flow_enum)]
293-
/// use std::ops::ControlFlow;
294-
///
295-
/// let mut partial_sum = 0;
296-
/// (1..10).chain(20..25).try_for_each(|x| {
297-
/// if partial_sum > 100 { ControlFlow::BREAK }
298-
/// else { partial_sum += x; ControlFlow::CONTINUE }
299-
/// });
300-
/// assert_eq!(partial_sum, 108);
301-
/// ```
302-
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
303-
pub const BREAK: Self = ControlFlow::Break(());
304-
}

src/librustdoc/html/length_limit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ impl HtmlWithLimit {
6161
/// and returns [`ControlFlow::Break`].
6262
pub(super) fn push(&mut self, text: &str) -> ControlFlow<(), ()> {
6363
if self.len + text.len() > self.limit {
64-
return ControlFlow::BREAK;
64+
return ControlFlow::Break(());
6565
}
6666

6767
self.flush_queue();
6868
write!(self.buf, "{}", Escape(text)).unwrap();
6969
self.len += text.len();
7070

71-
ControlFlow::CONTINUE
71+
ControlFlow::Continue(())
7272
}
7373

7474
/// Open an HTML tag.

src/librustdoc/html/length_limit/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ fn past_the_limit() {
8383
buf.push("word#")?;
8484
buf.push(&n.to_string())?;
8585
buf.close_tag();
86-
ControlFlow::CONTINUE
86+
ControlFlow::Continue(())
8787
});
8888
buf.close_tag();
8989
assert_eq!(

src/librustdoc/html/markdown.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1188,18 +1188,18 @@ fn markdown_summary_with_limit(
11881188
Event::Start(tag) => match tag {
11891189
Tag::Emphasis => buf.open_tag("em"),
11901190
Tag::Strong => buf.open_tag("strong"),
1191-
Tag::CodeBlock(..) => return ControlFlow::BREAK,
1191+
Tag::CodeBlock(..) => return ControlFlow::Break(()),
11921192
_ => {}
11931193
},
11941194
Event::End(tag) => match tag {
11951195
Tag::Emphasis | Tag::Strong => buf.close_tag(),
1196-
Tag::Paragraph | Tag::Heading(..) => return ControlFlow::BREAK,
1196+
Tag::Paragraph | Tag::Heading(..) => return ControlFlow::Break(()),
11971197
_ => {}
11981198
},
11991199
Event::HardBreak | Event::SoftBreak => buf.push(" ")?,
12001200
_ => {}
12011201
};
1202-
ControlFlow::CONTINUE
1202+
ControlFlow::Continue(())
12031203
});
12041204

12051205
(buf.finish(), stopped_early)

src/librustdoc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#![feature(array_methods)]
77
#![feature(assert_matches)]
88
#![feature(box_patterns)]
9-
#![feature(control_flow_enum)]
109
#![feature(drain_filter)]
1110
#![feature(is_terminal)]
1211
#![feature(let_chains)]

src/tools/clippy/clippy_lints/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#![feature(array_windows)]
22
#![feature(binary_heap_into_iter_sorted)]
33
#![feature(box_patterns)]
4-
#![feature(control_flow_enum)]
54
#![feature(drain_filter)]
65
#![feature(iter_intersperse)]
76
#![feature(let_chains)]

src/tools/clippy/clippy_lints/src/methods/collapsible_str_replace.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn collect_replace_calls<'tcx>(
5454
from_args.push_front(from);
5555
ControlFlow::Continue(())
5656
} else {
57-
ControlFlow::BREAK
57+
ControlFlow::Break(())
5858
}
5959
} else {
6060
ControlFlow::Continue(())

src/tools/clippy/clippy_utils/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![feature(array_chunks)]
22
#![feature(box_patterns)]
3-
#![feature(control_flow_enum)]
43
#![feature(let_chains)]
54
#![feature(lint_reasons)]
65
#![feature(never_type)]

src/tools/clippy/clippy_utils/src/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ fn is_assert_arg(cx: &LateContext<'_>, expr: &Expr<'_>, assert_expn: ExpnId) ->
327327
} else {
328328
match cx.tcx.item_name(macro_call.def_id) {
329329
// `cfg!(debug_assertions)` in `debug_assert!`
330-
sym::cfg => ControlFlow::CONTINUE,
330+
sym::cfg => ControlFlow::Continue(()),
331331
// assert!(other_macro!(..))
332332
_ => ControlFlow::Break(true),
333333
}

src/tools/clippy/clippy_utils/src/mir/possible_borrower.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl TypeVisitor<'_> for ContainsRegion {
140140
type BreakTy = ();
141141

142142
fn visit_region(&mut self, _: ty::Region<'_>) -> ControlFlow<Self::BreakTy> {
143-
ControlFlow::BREAK
143+
ControlFlow::Break(())
144144
}
145145
}
146146

0 commit comments

Comments
 (0)