Summary
Rust Lang has an attribute #[must_use]
#[must_use]
fn use_me1() -> u8 { 0 }
#[must_use = "explanation of why it should be used"]
fn use_me2() -> u8 { 0 }
#[must_use]
fn f() {}
f(); // ERROR: Unused return value that must be used.
https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute
Scope
The scope of this ticket is to crawl over all public APIs of the bc-rust library and tag any where ignoring a return value could lead to bugs or vulnerabilities. This is probably particularly relevant on functions of the form -> Result<(), Error>, or -> Result<usize, Error>; it might not be necessary to handle the () or usize, but we should use #[must_use] to force the caller to check for an error.
We should come up with a guideline for when a function should be tagged, and document this in QUALITY_AND_STYLE.md.
Acceptance Criteria
Summary
Rust Lang has an attribute
#[must_use]https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute
Scope
The scope of this ticket is to crawl over all public APIs of the bc-rust library and tag any where ignoring a return value could lead to bugs or vulnerabilities. This is probably particularly relevant on functions of the form
-> Result<(), Error>, or-> Result<usize, Error>; it might not be necessary to handle the()orusize, but we should use#[must_use]to force the caller to check for an error.We should come up with a guideline for when a function should be tagged, and document this in QUALITY_AND_STYLE.md.
Acceptance Criteria
#[must_use]has been written in QUALITY_AND_STYLE.md.