mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 23:08:14 +00:00
fix(core/rust): fix "unnecessary unsafe" warning
[no changelog]
This commit is contained in:
parent
31de21718f
commit
795ed2d339
@ -38,12 +38,10 @@ pub extern "C" fn protobuf_encode(buf: Obj, obj: Obj) -> Obj {
|
|||||||
util::try_or_raise(|| {
|
util::try_or_raise(|| {
|
||||||
let obj = Gc::<MsgObj>::try_from(obj)?;
|
let obj = Gc::<MsgObj>::try_from(obj)?;
|
||||||
|
|
||||||
|
// We assume there are no other refs into `buf` at this point. This specifically
|
||||||
|
// means that no fields of `obj` should reference `buf` memory.
|
||||||
let buf = &mut BufferMut::try_from(buf)?;
|
let buf = &mut BufferMut::try_from(buf)?;
|
||||||
let stream = &mut BufferStream::new(unsafe {
|
let stream = &mut BufferStream::new(buf.as_mut());
|
||||||
// SAFETY: We assume there are no other refs into `buf` at this point. This
|
|
||||||
// specifically means that no fields of `obj` should reference `buf` memory.
|
|
||||||
buf.as_mut()
|
|
||||||
});
|
|
||||||
|
|
||||||
Encoder.encode_message(stream, &obj.def(), &obj)?;
|
Encoder.encode_message(stream, &obj.def(), &obj)?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user