Repository navigation
Conversation
I made the inner Vec on Name private. It was public before, so a caller could write Name(vec![]) and end up with a Name that breaks the "always at least one label" invariant that first_label() and friends rely on. You can't get an empty Name through FromStr anyway, so once the field is private that case just can't happen. While I was in there I switched first_label()'s last().expect() over to assert() to line up with how we handle these invariants elsewhere. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes
Name's innerVec<String>private.Why
The field was public, so a caller could construct
Name(vec![])and endup with a
Namethat violates the "always at least one label" invariantthat
first_label()and the other label accessors rely on.FromStrnever yields an empty
Name(split('.')always produces at least onelabel and empty labels are rejected), so making the field private rules
out the empty case across the whole crate — the invariant now holds by
construction.
Also switches
first_label()'slast().expect()toassert()to matchthe house assertion style.
Scope
No code outside
ident.rsconstructsName(...)as a tuple or reads.0, so the change is contained.🤖 Generated with Claude Code