Skip to content

array::IntoIter does not get optimized as well as vec::IntoIter #87949

@vandenheuvel

Description

@vandenheuvel

I found a situation where creation, conversion into an iterator and consuming the iterator gets optimized for a Vec, but not for an array.

Compiler explorer

The snipped on the left works well; the abstracted function compiles down to the same code as the goal function. The snipped on the right has the Vec usage replaced by an array. The assembler for the abstracted function is now more complicated than goal function.

Note that if one removes the Enum::Single variant, it does work.

I attempted to make the above example minimal. A more elaborate example is here.

Should this be mentioned in #84513?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-arrayArea: `[T; N]`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions