Repository navigation
#3026 (D111): an unannotated let of a str place takes the str; a str global reads as a value - #3028
Conversation
|
Second commit (8639268): the Sema-only change left MIR aliasing any field let on syntax ( |
…a str global reads as a value
A str is a value (D111): the binding of a str field, of a local
record's str field, or of a global is a count increment, never a view
of the place. `field_let_binds_as_view` answered true for a str field
(only plain bits took the value), so MIR alias-bound the binding, a
later write of the owner was refused ("cannot mutate `self` while
`old` is a live view into it"), a consume of the record was refused
("view may outlive its origin"), and the diagnostic's own help was the
`: str` annotation the census counts as ceremony. A str global read in
value position was refused as a move ("cannot move out of global …
clone it"). Now the str field let takes the str (the annotated form's
copy path, `copy _1.name` in MIR) and `reject_move_out_of_global` and
the tail-read rule exempt str.
Found by the #2942 sweep, whose seven kept `.clone()` are these shapes.
Fixture: behav_3026_str_place_let_takes_the_str (a rename through
self, a global read as a value, a record consumed after its field was
read); debug-alloc clean.
…w pins keep a non-str field Sema decides whether a field let is a view of its place or takes the value (view_bound_let_nodes); MirLower.lower_let_binding aliased any field access on syntax alone (D65), so `let p = x.inner.s; x.inner = …; print(p)` printed the replacement after Sema had made the binding a value. A field access is now aliased only when Sema recorded the let as view-bound. Seven refusal fixtures pinned the live-view rule on a str field, whose binding now takes the str: three become behavior fixtures printing the saved value (behav_3026_assign_str_field_under_saved_value, behav_3026_concat_str_field_after_saved_value, behav_3026_assign_parent_after_saved_str_field); four keep their rule on a List[i32] field (err_loop_write_under_view_used_after_loop, err_loop_write_under_view_used_next_iteration, err_move_field_under_live_view, err_move_whole_under_live_field_view), and err_3026_list_field_let_stays_a_view pins the List case beside the str case.
8639268 to
8c3153c
Compare
|
Battery green on ffa08ba (seed-driven gate, uat, battery-checks; |
Closes #3026.
A str is a value (D111), so the binding of a str place is a count increment, never a view of the place. Three refusals said otherwise:
let old = self.namethenself.name = to: "cannot mutateselfwhileoldis a live view into it", with the help text being the: strannotation the census counts as ceremony (str-view-copy-annotation, D179).field_let_binds_as_viewanswered true for a str field (only plain bits took the value), and MIR alias-bound the binding.let name = record.namethen a consume ofrecord: "viewnamemay outlive its origin".fn label() -> str: g_label: "cannot move out of globalg_label… clone it".Now the str field let takes the str (the annotated form's copy path:
copy _1.namein MIR, as before forlet old: str = self.name), andreject_move_out_of_globaland the tail-read rule exempt str. Sema only; MIR and codegen unchanged.Found by the #2942 sweep (#3027), whose seven kept
.clone()are exactly these shapes; they are re-swept once this lands.Fixture
behav_3026_str_place_let_takes_the_str(a rename through self, a global read as a value, a record consumed after its field was read): fails on the installed compiler with both old errors, passes on the stage1,--debug-allocleak count 0. Str/view-origin regression set and gate reported below. Draft until the battery is green.