Repository navigation
FixedString's methods are declared in the library; as_view is a view of its value (part of #3483) - #3611
Merged
Conversation
…of its value (part of #3483)
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.
Part of #3483; the issue stays open.
Moved. Ten of
FixedString's methods are library declarations inlib/std/fixed_string.with(impl[Storage] FixedString[Storage]):len,len_i32,len_i64,capacity,is_empty,clear,push_byte,push_str,as_view,equals.newstays built in: it needs a zeroed value of a generic type, which the library cannot spell yet.Deleted with them: their
MirIntrinsicmembers, about 190 lines of hand-built IR inCodegenDispatch, the threeBuiltinSigsrows, and inSemaCheckthe name-based receiver modes, arity checks, return types and theFixedString__Nsignature fallback. The MIR shows the calls going to the library bodies (FixedString.len,.capacity, …).Two soundness holes close with the move. The built-in
as_viewreturned astrthat aliased the buffer, and nothing tied it to the value:The library declaration is
as_view() -> &str from self. A binding of it is its own copy (D111), text returned asstris a copy, and returning the view itself is refused ("returned view may outlive its origin 's'").This changes a signature and what safe code may do, by closing the holes:
as_viewis&str, notstr. Every existing use in the tree compiles unchanged. Flagged for your veto.Tests:
behav_fixed_stringpasses unchanged; newbehav_fixed_string_view_is_a_viewanderr_fixed_string_view_outlives_buffer, both failing on main.Evidence at 8cb6621: both compilers check the source; release build;
:unit-return-review,:ceremony-census,:self-audit,:native-compile-error-tests,:behavior-tests,:d-acceptance-corpusgreen; battery green;:release-checkssurvey: all targets green (the emit-C lanes among them).