Skip to content

Add track_caller to iterator methods #102024

Open
@xxchan

Description

@xxchan

I'm trying to add track_caller to Itertools::zip_eq, but:

zip_eq(&a, &b).count();

reports Iterator::fold

thread 'zip_eq_panic1' panicked at 'itertools: .zip_eq() reached end of one iterator before the other', /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/iter/traits/iterator.rs:2170:34
stack backtrace:
   0: std::panicking::begin_panic
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:525:12
   1: <itertools::zip_eq_impl::ZipEq<I,J> as core::iter::traits::iterator::Iterator>::next
             at ./src/zip_eq_impl.rs:51:13
   2: core::iter::traits::iterator::Iterator::fold
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/iter/traits/iterator.rs:2170:29
   3: core::iter::traits::iterator::Iterator::count
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/iter/traits/iterator.rs:201:9
   4: zip::zip_eq_panic1
             at ./tests/zip.rs:66:5
   5: zip::zip_eq_panic1::{{closure}}
             at ./tests/zip.rs:61:1
   6: core::ops::function::FnOnce::call_once
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/ops/function.rs:227:5
   7: core::ops::function::FnOnce::call_once
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/ops/function.rs:227:5
zip_eq(&a, &b).collect_vec();

reports alloc::vec::...

thread 'zip_eq_panic1' panicked at 'itertools: .zip_eq() reached end of one iterator before the other', /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/alloc/src/vec/mod.rs:2638:44
stack backtrace:
   0: std::panicking::begin_panic
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:525:12
   1: <itertools::zip_eq_impl::ZipEq<I,J> as core::iter::traits::iterator::Iterator>::next
             at ./src/zip_eq_impl.rs:51:13
   2: alloc::vec::Vec<T,A>::extend_desugared
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/alloc/src/vec/mod.rs:2638:35
   3: <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/alloc/src/vec/spec_extend.rs:18:9
   4: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/alloc/src/vec/spec_from_iter_nested.rs:37:9
   5: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/alloc/src/vec/spec_from_iter.rs:33:9
   6: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/alloc/src/vec/mod.rs:2541:9
   7: core::iter::traits::iterator::Iterator::collect
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/iter/traits/iterator.rs:1745:9
   8: itertools::Itertools::collect_vec
             at ./src/lib.rs:1985:9
   9: zip::zip_eq_panic1
             at ./tests/zip.rs:66:5

Is it possible to improve it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-error-handlingArea: Error handlingA-iteratorsArea: IteratorsC-discussionCategory: Discussion or questions that doesn't represent real issues.T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions