E0305: Interface bound not satisfied
| Code | Category | Stability |
|---|---|---|
E0305 | Semantic | Permanent |
Explanation
A comptime type argument does not have an asserted conformance satisfying an interface bound. Having matching inherent members alone does not establish declared conformance.
Likely cause
The concrete type needs a conformance assertion, or an enclosing generic parameter needs the required interface in its own bound. Follow the diagnostic's suggested assertion or bound addition.
Examples
Matching member without an assertion
Requires --preview interfaces.
interface Show { fn show(borrow self) -> i64; }
struct Value { fn show(borrow self) -> i64 { 42 } }
fn read(comptime T: Show, borrow x: T) -> i64 { x.show() }
fn main() -> i32 { @intCast(read(Value, borrow Value {})) }
Assert conformance
Requires --preview interfaces.
interface Show { fn show(borrow self) -> i64; }
struct Value is Show { fn show(borrow self) -> i64 { 42 } }
fn read(comptime T: Show, borrow x: T) -> i64 { x.show() }
fn main() -> i32 { @intCast(read(Value, borrow Value {})) }