mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-06 08:36:52 -04:00
Revert const hack and use const closure
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user