annotation-mismatch
Default severity: error · Identifier: weavec::annotation-mismatch
What it means
Section titled “What it means”A definition contradicts its own annotation: '<p>' is annotated WEAVEC_BORROWED but is freed here (also WEAVEC_MUT; also moved, written through; also ... but '<p>->f' is freed here for a path under the parameter), function returns a borrow but its return type is annotated WEAVEC_OWNED, function returns a fresh allocation but its return type is annotated WEAVEC_BORROWED (or WEAVEC_MUT). Notes: '<p>' is annotated here / annotated here; '<q>' is a copy of '<p>' when through an alias. Callers keep trusting the annotation. A store into a WEAVEC_SIZED_BY(g) field of an object smaller than g says (RFC 0012): 'b->data' is declared WEAVEC_SIZED_BY(cap) but is given 4 bytes where 'b->cap' says 8 (at the store, or at the write to the count when that comes second; says at least 8 under a lower bound, says 'n' elements of 4 bytes for a non-byte element), note 'b->data' is declared here. An object of unknown size, a larger one, or null is not reported.
How to resolve it
Section titled “How to resolve it”Compare the annotation with the function body and its callers. Correct the implementation or the declared contract so they describe the same ownership, extent, and effects. Do not strengthen an annotation simply to silence a diagnostic.