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
let s: &T = x moves x instead of binding a view (typed-let borrow over an ident) #1244
Spec §3.8 / D22: an annotation demands what it says, and &T is a borrow. The checker marks the initializer ident MOVED regardless of a reference annotation (SemaCheck.w let path: mark_moved_if_consumed(value) runs unless field_let_binds_as_view matches, which only covers field accesses), and MirLower lowers it as a plain use.
use std.fs
fn main:
let x = read_file("m.w").unwrap()
let s: &str = x
print(f"{s.len()} {x.len()}") // error: use of moved value
Same for let s: &Vec[str] = x. Over a global it is worse: let s: &str = g inside a function yields invalid MIR before codegen: use rvalue type is incompatible with assign destination, and the move mark on the global leaks into every later function body (#1242).
Expected: s is a view of x's place; x stays live; no move, no copy.
Found while fixing #1242; fix follows in its own ownership batch.
Activity
`let s: &T = place` borrows the place instead of moving it (#1244, §3…