E0303: Interface signature mismatch
| Code | Category | Stability |
|---|---|---|
E0303 | Semantic | Permanent |
Explanation
A required inherent member exists, but its signature differs from the interface requirement after substituting Self and associated types. Receiver modes, parameter modes and types, and the result must match.
Likely cause
The method uses a different access mode or type. Compare the expected and found signatures in the diagnostic and align the inherent declaration with the requirement.
Examples
Different return type
Requires --preview interfaces.
interface Show { fn show(borrow self) -> i64; }
struct Value is Show { fn show(borrow self) -> bool { true } }
fn read(comptime T: Show, borrow x: T) -> i64 { x.show() }
fn main() -> i32 { @intCast(read(Value, borrow Value {})) }
Matching return type
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 {})) }