//# print-bytecode // Borrowing a local produces a reference type. main() { let x: u64; let ref_x: &u64; label b0: x = 3; ref_x = &x; _ = move(ref_x); return; } //# print-bytecode // Borrowing a local reference produces a reference type. main() { let x: u64; let ref_x: &u64; let ref_ref_x: &u64; label b0: x = 3; ref_x = &x; ref_ref_x = &ref_x; return; } //# print-bytecode --input=module module 0x1d4.M { struct T { u: u64 } // An immutable borrow, of a field on an immutable reference to a struct, // produces an immutable reference type. f(t: &Self.T) { let r: &u64; label b0: r = &move(t).T::u; _ = move(r); return; } // An immutable borrow, of a field on a mutable reference to a struct, // produces an immutable reference type. g(t: &mut Self.T) { let r: &u64; label b0: r = &move(t).T::u; _ = move(r); return; } // A mutable borrow, of a field on a mutable reference to a struct, // produces an mutable reference type. public h(t: &mut Self.T) { let r: &mut u64; label b0: r = &mut move(t).T::u; _ = move(r); return; } } //# print-bytecode --input=module module 0x2d4.M { struct T { u: U } f(t: &Self.T) { let r: &u64; label b0: r = &move(t).T::u; _ = move(r); return; } g(t: &mut Self.T) { let r: &u128; label b0: r = &move(t).T::u; _ = move(r); return; } } //# publish module 0x3d4.M { struct T has key { b: bool } public new(): Self.T { label b0: return T { b: true }; } } //# print-bytecode --input=module // Attempting an immutable borrow of the field of a struct type defined in a // separate module is invalid. module 0x3d4.N { import 0x1.signer; import 0x3d4.M; f(account: signer) { let t: M.T; let r: &bool; label b0: t = M.new(); _ = &(&mut t).T::b; return; } } //# print-bytecode import 0x3d4.M; main(account: signer) { let t: M.T; let r: &bool; label b0: t = M.new(); _ = &(&mut t).T::b; return; } //# print-bytecode --input=module // Attempting a mutable borrow of the field of a struct type defined in a // separate module is invalid. module 0x3d4.O { import 0x1.signer; import 0x3d4.M; f(account: signer) { let t: M.T; let r: &bool; label b0: t = M.new(); _ = &mut (&mut t).T::b; return; } } //# print-bytecode main(account: signer) { let t: M.T; let r: &bool; label b0: t = M.new(); _ = &mut (&mut t).T::b; return; }