E0016 — Generic trait bound not satisfied
A type argument doesn’t implement a bound required by the generic function or struct it’s substituted into.
What triggers it
A generic function or struct declares a trait bound on one of its
type parameters (e.g. fn max<T: Ord>(...)). Instantiating it with
a concrete type that has no matching impl fails this check.
Minimal example
trait Ord { fn cmp(self, Self other) -> int; }
fn max<T: Ord>(T a, T b) -> T { return a; }
struct Point { int x; int y; }
fn main() {
max(Point { x: 1, y: 2 }, Point { x: 3, y: 4 });
}
Output:
scratch.rz:5:5: error[E0016]: `Point` does not implement `Ord`
max(Point { x: 1, y: 2 }, Point { x: 3, y: 4 });
^^^
Fix
Provide an impl Ord for Point { ... }, or call the generic
function with a type that already satisfies the bound.
Source
Emitted from the typechecker’s generic-instantiation check in
resilient/src/typechecker.rs.