mirror of
https://github.com/salsa-rs/salsa.git
synced 2024-11-25 04:27:52 +00:00
Allow clippy::needless_lifetimes on tracked method getters
Previously, this would necessitate having to manually add an allow for this clippy lint, since an extra `'db` lifetime was added to the signature.
This commit is contained in:
parent
ef7c0f12c8
commit
7c8647e572
3 changed files with 34 additions and 0 deletions
|
@ -234,6 +234,12 @@ fn tracked_method(
|
|||
|
||||
let (config_ty, fn_struct) = crate::tracked_fn::fn_struct(&args, &item_fn)?;
|
||||
|
||||
// we generate a `'db` lifetime that clippy
|
||||
// sometimes doesn't like
|
||||
item_method
|
||||
.attrs
|
||||
.push(syn::parse_quote! {#[allow(clippy::needless_lifetimes)]});
|
||||
|
||||
item_method.block = getter_fn(
|
||||
&args,
|
||||
&mut item_method.sig,
|
||||
|
|
|
@ -3,4 +3,5 @@
|
|||
#![deny(warnings)]
|
||||
|
||||
mod needless_borrow;
|
||||
mod needless_lifetimes;
|
||||
mod unused_variable_db;
|
||||
|
|
27
salsa-2022-tests/tests/warnings/needless_lifetimes.rs
Normal file
27
salsa-2022-tests/tests/warnings/needless_lifetimes.rs
Normal file
|
@ -0,0 +1,27 @@
|
|||
pub trait Db: salsa::DbWithJar<Jar> {}
|
||||
|
||||
#[salsa::jar(db = Db)]
|
||||
pub struct Jar(SourceTree, SourceTree_all_items, use_tree);
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
pub struct Item {}
|
||||
|
||||
#[salsa::tracked(jar = Jar)]
|
||||
pub struct SourceTree {}
|
||||
|
||||
#[salsa::tracked(jar = Jar)]
|
||||
impl SourceTree {
|
||||
#[salsa::tracked(return_ref)]
|
||||
pub fn all_items(self, _db: &dyn Db) -> Vec<Item> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
#[salsa::tracked(jar = Jar, return_ref)]
|
||||
fn use_tree(_db: &dyn Db, _tree: SourceTree) {}
|
||||
|
||||
#[allow(unused)]
|
||||
fn use_it(db: &dyn Db, tree: SourceTree) {
|
||||
tree.all_items(db);
|
||||
use_tree(db, tree);
|
||||
}
|
Loading…
Reference in a new issue