E1145: field moved out of a zero_on_drop owner

View source

A struct marked meta zero_on_drop is overwritten with zeros as a whole when its owner ends (ADR-0102).

A struct marked meta zero_on_drop is overwritten with zeros as a whole when its owner ends (ADR-0102). Moving one field out with dat owner.field would leave a part of the secret outside the owner, where nothing zeroes it, so the compiler rejects the move. The message names the field and the owner.

Example

actus
meta repr(C)
meta zero_on_drop
struct Key {
    first: u64,
}

verb take(dat value: u64) {
}

verb main() {
    erg key = Key { first: 1u64, };
    take(value: dat key.first);
}

Fix

Lend the field with abs, so the owner keeps it.

actus
meta repr(C)
meta zero_on_drop
struct Key {
    first: u64,
}

verb take(abs value: u64) {
}

verb main() {
    erg key = Key { first: 1u64, };
    take(value: abs key.first);
}

Run actus explain E1145 in your terminal to read this entry offline. Browse Modules & rules or all error codes.