You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
&str points at a string header, so a str range view (D71 §4.8a) cannot be returned: make &str its own {ptr, len} #1810
D71 / §4.8a: a range of a str or &str is a &str view "with the origin and ephemerality of any view (§5, §21.1)". So fn tail(s: &str) -> &str: s[1..] is valid: the view's origin is the parameter s (§21.1 Rule 6).
A &str is a pointer to a str header {ptr, len}. A range view has no header of its own, so lower_slice_expr builds {ptr+a, b-a} into a hidden str local of the frame and the view is a reference to it. Inside the function every use works (print, methods, compare, owned demand, invalidation). Returning it would hand out a pointer into the dead frame, so Sema gives the view a frame-local sentinel origin (syms.str_range_view) and refuses the return by name:
error: a string slice cannot be returned yet (#1587): ...
(test/compile_errors/err_1587_str_range_returned*.w pin it; they flip to behavior tests when this lands.)
What the ruling needs
&str represented as {ptr, len} by value (a fat view, like []u8), so a range view is a value and carries only its base's origins. Touches every &str producer and consumer: FnAbi/PassMode for &str params and returns, build_str_ref_from_value and the with_*_str_ref runtime seams, c_import marshalling (#1589's D47 path), element views of Vec[str] (#925), pattern bindings, str_data in rt_core. Then drop the sentinel origin and the hidden header.
Question
Land #1587's interim refusal now (loud, one rule) and do the representation change as its own campaign? Recommended: yes — the refusal is not a silent fallback, every non-returning use already matches the ruling, and the representation change is ABI work that must be alone in its battery.
Activity
Sema: a call writes every global its callee writes, so a view of that…
Build/Link: a stage links and embeds only runtime objects its own com…
rt/std/compiler: read a `&str`'s bytes through `s as *const str`, whi…
PROPOSED (needs Eric's blessing): with-abi v7 — a shared `&str` is a …
FnAbi/TypeLayout/Codegen/CCodegen: a shared `&str` is its own `{ptr, …
Sema: a str range view carries only its base's origins, so `fn tail(s…
Globals: a call, dyn dispatch, stored callable or drop that writes a …
Sema/Codegen/migrator: unsuffixed literal arithmetic takes its contex…
A reference's place pointer is the local's category from its owners, …
A reference's place pointer is the local's category from its owners, …
emit-C: multi-field enum payloads, collection literals, declared Resu…
#1647 phases 2–4 completion: owner facts in codegen, per-instance Sem…
D44 map transfers, D97 TotalF64, deep-debugging tools, and the fixes …