Skip to content

clippy::type_repetition_in_bounds clippy warning inside #[query_group] #203

Closed
@Wodann

Description

@Wodann

When using the #[salsa::invoke(...)] attribute inside a #[query_group], clippy complains about type repetition inside the function's bounds.

This is the code in question:

#[salsa::query_group(IrDatabaseStorage)]
pub trait IrDatabase: hir::HirDatabase {
    /// Get the LLVM context that should be used for all generation steps.
    #[salsa::input]
    fn context(&self) -> Arc<Context>;

    /// Gets the optimization level for generation.
    #[salsa::input]
    fn optimization_lvl(&self) -> OptimizationLevel;

    /// Returns the target for code generation.
    #[salsa::input]
    fn target(&self) -> Target;

    /// Given a type, return the corresponding IR type.
    #[salsa::invoke(crate::ir::ty::ir_query)]
    fn type_ir(&self, ty: hir::Ty) -> AnyTypeEnum;

    /// Given a `hir::FileId` generate code for the module.
    #[salsa::invoke(crate::ir::module::ir_query)]
    fn module_ir(&self, file: hir::FileId) -> Arc<ModuleIR>;

    /// Given a type, return the runtime `TypeInfo` that can be used to reflect the type.
    #[salsa::invoke(crate::code_gen::symbols::type_info_query)]
    fn type_info(&self, ty: hir::Ty) -> TypeInfo;
}

and these are the consequent warnings in clippy:

warning: this type has already been used as a bound predicate
  --> crates\mun_codegen\src\db.rs:26:8
   |
26 |     fn type_ir(&self, ty: hir::Ty) -> AnyTypeEnum;
   |        ^^^^^^^
   |
   = note: `#[warn(clippy::type_repetition_in_bounds)]` on by default
   = help: consider combining the bounds: `type_ir: IrDatabase + salsa::plumbing::HasQueryGroup<IrDatabaseStorage>`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

warning: this type has already been used as a bound predicate
  --> crates\mun_codegen\src\db.rs:26:8
   |
26 |     fn type_ir(&self, ty: hir::Ty) -> AnyTypeEnum;
   |        ^^^^^^^
   |
   = help: consider combining the bounds: `type_ir: salsa::plumbing::HasQueryGroup<IrDatabaseStorage> + salsa::Database`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

warning: this type has already been used as a bound predicate
  --> crates\mun_codegen\src\db.rs:30:8
   |
30 |     fn module_ir(&self, file: hir::FileId) -> Arc<ModuleIR>;
   |        ^^^^^^^^^
   |
   = help: consider combining the bounds: `module_ir: IrDatabase + salsa::plumbing::HasQueryGroup<IrDatabaseStorage>`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

warning: this type has already been used as a bound predicate
  --> crates\mun_codegen\src\db.rs:30:8
   |
30 |     fn module_ir(&self, file: hir::FileId) -> Arc<ModuleIR>;
   |        ^^^^^^^^^
   |
   = help: consider combining the bounds: `module_ir: salsa::plumbing::HasQueryGroup<IrDatabaseStorage> + salsa::Database`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

warning: this type has already been used as a bound predicate
  --> crates\mun_codegen\src\db.rs:34:8
   |
34 |     fn type_info(&self, ty: hir::Ty) -> TypeInfo;
   |        ^^^^^^^^^
   |
   = help: consider combining the bounds: `type_info: IrDatabase + salsa::plumbing::HasQueryGroup<IrDatabaseStorage>`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

warning: this type has already been used as a bound predicate
  --> crates\mun_codegen\src\db.rs:34:8
   |
34 |     fn type_info(&self, ty: hir::Ty) -> TypeInfo;
   |        ^^^^^^^^^
   |
   = help: consider combining the bounds: `type_info: salsa::plumbing::HasQueryGroup<IrDatabaseStorage> + salsa::Database`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

Used version:

salsa="0.12"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions