mirror of
https://github.com/salsa-rs/salsa.git
synced 2024-11-25 04:27:52 +00:00
avoid warnings in generated code
This commit is contained in:
parent
1363d78fe5
commit
b14d12ada9
4 changed files with 35 additions and 2 deletions
|
@ -310,14 +310,15 @@ impl<A: AllowedOptions> SalsaStruct<A> {
|
|||
|
||||
impl<Everything, Db: ?Sized, T: ::core::fmt::Debug> Fallback<T, Db> for Everything {}
|
||||
|
||||
&Test::<#field_ty, #db_type>::salsa_debug(&self.#field_getter(db), db)
|
||||
#[allow(clippy::needless_borrow)]
|
||||
&Test::<#field_ty, #db_type>::salsa_debug(&self.#field_getter(_db), _db)
|
||||
})
|
||||
}
|
||||
}).collect::<Vec<TokenStream>>();
|
||||
|
||||
parse_quote_spanned! {ident.span()=>
|
||||
impl ::salsa::DebugWithDb<#db_type> for #ident {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>, db: &#db_type) -> ::std::fmt::Result {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>, _db: &#db_type) -> ::std::fmt::Result {
|
||||
f.debug_struct(#ident_string)
|
||||
.field("[salsa id]", &self.0.as_u32())
|
||||
#(#fields)*
|
||||
|
|
6
salsa-2022-tests/tests/warnings/main.rs
Normal file
6
salsa-2022-tests/tests/warnings/main.rs
Normal file
|
@ -0,0 +1,6 @@
|
|||
//! Test that macros don't generate code with warnings
|
||||
|
||||
#![deny(warnings)]
|
||||
|
||||
mod needless_borrow;
|
||||
mod unused_variable_db;
|
19
salsa-2022-tests/tests/warnings/needless_borrow.rs
Normal file
19
salsa-2022-tests/tests/warnings/needless_borrow.rs
Normal file
|
@ -0,0 +1,19 @@
|
|||
trait Db: salsa::DbWithJar<Jar> {}
|
||||
|
||||
#[salsa::jar(db = Db)]
|
||||
struct Jar(TokenTree);
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||
enum Token {}
|
||||
|
||||
impl salsa::DebugWithDb<dyn Db + '_> for Token {
|
||||
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>, _db: &dyn Db) -> std::fmt::Result {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
#[salsa::tracked(jar = Jar)]
|
||||
struct TokenTree {
|
||||
#[return_ref]
|
||||
tokens: Vec<Token>,
|
||||
}
|
7
salsa-2022-tests/tests/warnings/unused_variable_db.rs
Normal file
7
salsa-2022-tests/tests/warnings/unused_variable_db.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
trait Db: salsa::DbWithJar<Jar> {}
|
||||
|
||||
#[salsa::jar(db = Db)]
|
||||
struct Jar(Keywords);
|
||||
|
||||
#[salsa::interned(jar = Jar)]
|
||||
struct Keywords {}
|
Loading…
Reference in a new issue