Skip to content

vec::IntoIter is now invariant #35721

Closed
Closed
@asajeffrey

Description

@asajeffrey

#35447 replaced a *const T by a *mut T in IntoIter<T>, which changed IntoIter from being covariant to being invariant. This breaks crates like vec_map which relied on IntoIter being invariant, e.g. https://travis-ci.org/asajeffrey/presort/jobs/152720189#L208 has error:

error[E0308]: mismatched types
   --> /home/ajeffrey/.cargo/registry/src/github.com-1ecc6299db9ec823/vec_map-0.6.0/src/lib.rs:952:84
    |
952 |     fn into_iter_covariant<'a, T>(iter: IntoIter<&'static T>) -> IntoIter<&'a T> { iter }
    |                                                                                    ^^^^ lifetime mismatch
    |
    = note: expected type `IntoIter<&'a T>`
    = note:    found type `IntoIter<&'static T>`
note: the lifetime 'a as defined on the block at 952:81...
   --> /home/ajeffrey/.cargo/registry/src/github.com-1ecc6299db9ec823/vec_map-0.6.0/src/lib.rs:952:82
    |
952 |     fn into_iter_covariant<'a, T>(iter: IntoIter<&'static T>) -> IntoIter<&'a T> { iter }
    |                                                                                  ^^^^^^^^
    = note: ...does not necessarily outlive the static lifetime

   Compiling rustc-serialize v0.3.19
error: aborting due to previous error

cc @alexcrichton @frewsxcv @apasel422

Metadata

Metadata

Assignees

Labels

T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions