Skip to content

simplify the TaggedLen / set_len / capacity ... model #451

Closed
2 of 2 issues completed
Closed

Description

@alejandro-vaz

the current length/capacity model is becoming hard to maintain and understand leading to strange miri provenance bugs #406

what we need conceptually is:

TaggedLen: Copy -> [onheap:1][length:63]
- default() -> Self
- new(bool, usize) -> Self
- length(self) -> usize
- onheap(self) -> bool
- get(self) -> (bool, usize)
- resize(&mut self, usize) -> ()
- relocate(&mut self, bool) -> ()
- update(&mut self, bool, usize) -> ()

and no additional methods like set_len on SmallVec

currently set_len depends on capacity its downstream methods, so this is not a simple refactor

the sketch above is just a concept

Activity

  1. added this to the v2-alpha milestone on Aug 26, 2026
  2. removed theissue type on Aug 26, 2026
  3. fereidani commented on Sep 3, 2026

    @fereidani
    Contributor

    set_len is a unsafe public API and which enables users to implement their own specialized optimized code, are we sure we are going to remove it?

  4. alejandro-vaz commented on Sep 3, 2026

    @alejandro-vaz
    CollaboratorAuthor

    not removing it fully since it is on vec, but certainly not using it everywhere internally and instead operate with self.len

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedNo clear candidate to implement itr-refactorrelated to refactoring

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions