E0309: Opaque bounded address
| Code | Category | Stability |
|---|---|---|
E0309 | Semantic | Permanent |
Explanation
A bounded comptime type parameter supplies no source-visible layout inside its own function body. Taking a raw pointer to such a value, or offsetting and dereferencing one, would recover the size and field placement the parameter does not expose, so those intrinsics are unavailable.
Likely cause
The body applies @raw, @raw_mut, @field_ptr, @ptr_offset, @ptr_read, or @ptr_write to a value of its bounded parameter. Move, borrow, and drop the value, or call a requirement of its bound, instead of addressing it.
Examples
Raw pointer to an opaque bounded value
Requires --preview interfaces.
interface Show { fn show(borrow self) -> i64; }
fn addr(comptime T: Show, x: T) -> ptr const T { checked { @raw(x) } }
fn main() {}
Use the value without addressing it
Requires --preview interfaces.
interface Show { fn show(borrow self) -> i64; }
fn read(comptime T: Show, borrow x: T) -> i64 { x.show() }
fn main() {}