Revert const hack and use const closure

This commit is contained in:
Oli Scherer
2026-04-28 10:14:24 +02:00
parent 664177fdf1
commit a015eb119a
2 changed files with 6 additions and 8 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ fn inherit_const_stability(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
match def_kind {
DefKind::AssocFn | DefKind::AssocTy | DefKind::AssocConst { .. } => {
match tcx.def_kind(tcx.local_parent(def_id)) {
DefKind::Impl { .. } => true,
DefKind::Trait | DefKind::Impl { .. } => true,
_ => false,
}
}
+5 -7
View File
@@ -226,13 +226,11 @@ pub const trait Iterator {
Self: Sized + [const] Destruct,
Self::Item: [const] Destruct,
{
// FIXME(const-hack): revert this to a const closure
#[rustc_const_unstable(feature = "const_iter", issue = "92476")]
#[rustc_inherit_overflow_checks]
const fn plus_one<T: [const] Destruct>(accum: usize, _elem: T) -> usize {
accum + 1
}
self.fold(0, plus_one)
self.fold(
0,
#[rustc_inherit_overflow_checks]
const |accum, _elem| accum + 1,
)
}
/// Consumes the iterator, returning the last element.