Open JosephCottam opened 9 months ago
Discussion with @rdfriese , the idea of only suggesting if the locked structure is passed to another context. However, there might be difficulty around alias detection...
async fn do_stuff(table: LocalLockArray) {
let values = table.read_local_data().await;
let v = values[0];
let table2 = table;
do_other_stuff(table2);
}
Not sure when the linter runs, but if the de-aliasing isn't run yet this case would be harder to catch.
A potentail lamellar-lint: Try to detect when a temporary holds a lock but that temporary is never used again.
If
do_other_stuff
wants to write to table, it will be blocked because the read_lock is held untildo_stuff
finishes. It would be nice to have a lint that (1) knows what functions grab locks and (2) indicates when those locks probably aren't needed after a certain point (and suggests the temporary be explicitly dropped).