Skip to content

Commit 989bf84

Browse files
author
Bartłomiej Kuras
committed
Added ExactSizeIterator bound to return types
This reverts commit d97379a.
1 parent d97379a commit 989bf84

File tree

19 files changed

+31
-53
lines changed

19 files changed

+31
-53
lines changed

src/bootstrap/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1274,7 +1274,7 @@ impl Build {
12741274
t!(fs::remove_dir_all(dir))
12751275
}
12761276

1277-
fn read_dir(&self, dir: &Path) -> impl Iterator<Item=fs::DirEntry> + ExactSizeIterator {
1277+
fn read_dir(&self, dir: &Path) -> impl Iterator<Item=fs::DirEntry> {
12781278
let iter = match fs::read_dir(dir) {
12791279
Ok(v) => v,
12801280
Err(_) if self.config.dry_run => return vec![].into_iter(),

src/librustc/infer/canonical/query_response.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
574574
param_env: ty::ParamEnv<'tcx>,
575575
unsubstituted_region_constraints: &'a [QueryOutlivesConstraint<'tcx>],
576576
result_subst: &'a CanonicalVarValues<'tcx>,
577-
) -> impl Iterator<Item = PredicateObligation<'tcx>> + ExactSizeIterator + 'a + Captures<'tcx> {
577+
) -> impl Iterator<Item = PredicateObligation<'tcx>> + 'a + Captures<'tcx> {
578578
unsubstituted_region_constraints
579579
.iter()
580580
.map(move |constraint| {

src/librustc/infer/outlives/free_region_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub struct FreeRegionMap<'tcx> {
1111
}
1212

1313
impl<'tcx> FreeRegionMap<'tcx> {
14-
pub fn elements(&self) -> impl Iterator<Item=&Region<'tcx>> + ExactSizeIterator {
14+
pub fn elements(&self) -> impl Iterator<Item=&Region<'tcx>> {
1515
self.relation.elements()
1616
}
1717

src/librustc/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ impl<'tcx> Body<'tcx> {
284284
#[inline]
285285
pub fn args_iter(&self) -> impl Iterator<Item = Local> + ExactSizeIterator {
286286
let arg_count = self.arg_count;
287-
(1..arg_count+1).map(Local::new)
287+
(1..arg_count + 1).map(Local::new)
288288
}
289289

290290
/// Returns an iterator over all user-defined variables and compiler-generated temporaries (all

src/librustc/traits/specialize/specialization_graph.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,7 @@ impl<'tcx> Node {
414414
}
415415

416416
/// Iterate over the items defined directly by the given (impl or trait) node.
417-
pub fn items(&self, tcx: TyCtxt<'tcx>)
418-
-> impl Iterator<Item = ty::AssocItem> + ExactSizeIterator + Clone + 'tcx
419-
{
417+
pub fn items(&self, tcx: TyCtxt<'tcx>) -> ty::AssocItemsIterator<'tcx> {
420418
tcx.associated_items(self.def_id())
421419
}
422420

src/librustc/ty/mod.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,7 +2376,7 @@ impl<'tcx> AdtDef {
23762376
pub fn discriminants(
23772377
&'tcx self,
23782378
tcx: TyCtxt<'tcx>,
2379-
) -> impl Iterator<Item = (VariantIdx, Discr<'tcx>)> + ExactSizeIterator + Captures<'tcx> {
2379+
) -> impl Iterator<Item = (VariantIdx, Discr<'tcx>)> + Captures<'tcx> {
23802380
let repr_type = self.repr.discr_type();
23812381
let initial = repr_type.initial_discriminant(tcx);
23822382
let mut prev_discr = None::<Discr<'tcx>>;
@@ -2740,9 +2740,7 @@ impl<'tcx> TyCtxt<'tcx> {
27402740
/// Returns an iterator of the `DefId`s for all body-owners in this
27412741
/// crate. If you would prefer to iterate over the bodies
27422742
/// themselves, you can do `self.hir().krate().body_ids.iter()`.
2743-
pub fn body_owners(self)
2744-
-> impl Iterator<Item = DefId> + ExactSizeIterator + Captures<'tcx> + 'tcx
2745-
{
2743+
pub fn body_owners(self) -> impl Iterator<Item = DefId> + Captures<'tcx> + 'tcx {
27462744
self.hir().krate()
27472745
.body_ids
27482746
.iter()
@@ -3118,12 +3116,6 @@ impl Iterator for AssocItemsIterator<'_> {
31183116
}
31193117
}
31203118

3121-
impl ExactSizeIterator for AssocItemsIterator<'_> {
3122-
fn len(&self) -> usize {
3123-
self.def_ids.len() - self.next_index
3124-
}
3125-
}
3126-
31273119
fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> AssocItem {
31283120
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
31293121
let parent_id = tcx.hir().get_parent_item(id);

src/librustc/ty/sty.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ impl<'tcx> ClosureSubsts<'tcx> {
345345
self,
346346
def_id: DefId,
347347
tcx: TyCtxt<'_>,
348-
) -> impl Iterator<Item = Ty<'tcx>> + ExactSizeIterator + 'tcx {
348+
) -> impl Iterator<Item = Ty<'tcx>> + 'tcx {
349349
let SplitClosureSubsts { upvar_kinds, .. } = self.split(def_id, tcx);
350350
upvar_kinds.iter().map(|t| {
351351
if let GenericArgKind::Type(ty) = t.unpack() {
@@ -433,7 +433,7 @@ impl<'tcx> GeneratorSubsts<'tcx> {
433433
self,
434434
def_id: DefId,
435435
tcx: TyCtxt<'_>,
436-
) -> impl Iterator<Item = Ty<'tcx>> + ExactSizeIterator + 'tcx {
436+
) -> impl Iterator<Item = Ty<'tcx>> + 'tcx {
437437
let SplitGeneratorSubsts { upvar_kinds, .. } = self.split(def_id, tcx);
438438
upvar_kinds.iter().map(|t| {
439439
if let GenericArgKind::Type(ty) = t.unpack() {
@@ -551,7 +551,7 @@ impl<'tcx> GeneratorSubsts<'tcx> {
551551
self,
552552
def_id: DefId,
553553
tcx: TyCtxt<'tcx>,
554-
) -> impl Iterator<Item = impl Iterator<Item = Ty<'tcx>> + ExactSizeIterator + Captures<'tcx>> {
554+
) -> impl Iterator<Item = impl Iterator<Item = Ty<'tcx>> + Captures<'tcx>> {
555555
let layout = tcx.generator_layout(def_id);
556556
layout.variant_fields.iter().map(move |variant| {
557557
variant.iter().map(move |field| {
@@ -563,9 +563,7 @@ impl<'tcx> GeneratorSubsts<'tcx> {
563563
/// This is the types of the fields of a generator which are not stored in a
564564
/// variant.
565565
#[inline]
566-
pub fn prefix_tys(self, def_id: DefId, tcx: TyCtxt<'tcx>)
567-
-> impl Iterator<Item = Ty<'tcx>> + ExactSizeIterator
568-
{
566+
pub fn prefix_tys(self, def_id: DefId, tcx: TyCtxt<'tcx>) -> impl Iterator<Item = Ty<'tcx>> {
569567
self.upvar_tys(def_id, tcx)
570568
}
571569
}
@@ -582,7 +580,7 @@ impl<'tcx> UpvarSubsts<'tcx> {
582580
self,
583581
def_id: DefId,
584582
tcx: TyCtxt<'tcx>,
585-
) -> impl Iterator<Item = Ty<'tcx>> + ExactSizeIterator + 'tcx {
583+
) -> impl Iterator<Item = Ty<'tcx>> + 'tcx {
586584
let upvar_kinds = match self {
587585
UpvarSubsts::Closure(substs) => substs.as_closure().split(def_id, tcx).upvar_kinds,
588586
UpvarSubsts::Generator(substs) => substs.as_generator().split(def_id, tcx).upvar_kinds,

src/librustc_data_structures/graph/implementation/mod.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,18 +186,14 @@ impl<N: Debug, E: Debug> Graph<N, E> {
186186

187187
// # Iterating over nodes, edges
188188

189-
pub fn enumerated_nodes(&self)
190-
-> impl Iterator<Item = (NodeIndex, &Node<N>)> + ExactSizeIterator
191-
{
189+
pub fn enumerated_nodes(&self) -> impl Iterator<Item = (NodeIndex, &Node<N>)> {
192190
self.nodes
193191
.iter()
194192
.enumerate()
195193
.map(|(idx, n)| (NodeIndex(idx), n))
196194
}
197195

198-
pub fn enumerated_edges(&self)
199-
-> impl Iterator<Item = (EdgeIndex, &Edge<E>)> + ExactSizeIterator
200-
{
196+
pub fn enumerated_edges(&self) -> impl Iterator<Item = (EdgeIndex, &Edge<E>)> {
201197
self.edges
202198
.iter()
203199
.enumerate()

src/librustc_data_structures/transitive_relation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl<T: Clone + Debug + Eq + Hash> TransitiveRelation<T> {
6060
self.edges.is_empty()
6161
}
6262

63-
pub fn elements(&self) -> impl Iterator<Item=&T> + ExactSizeIterator {
63+
pub fn elements(&self) -> impl Iterator<Item=&T> {
6464
self.elements.iter()
6565
}
6666

src/librustc_incremental/persist/dirty_clean.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ impl DirtyCleanVisitor<'tcx> {
449449
&self,
450450
labels: &'l Labels,
451451
def_id: DefId
452-
) -> impl Iterator<Item = DepNode> + ExactSizeIterator + 'l {
452+
) -> impl Iterator<Item = DepNode> + 'l {
453453
let def_path_hash = self.tcx.def_path_hash(def_id);
454454
labels
455455
.iter()

0 commit comments

Comments
 (0)