Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Wodann opened this issue Oct 22, 2019 · 3 comments
Closed

Comments

@Wodann
Copy link

Wodann commented Oct 22, 2019

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"
@jonas-schievink
Copy link
Contributor

This is a bug in Clippy. It needs to check if the code originates from a macro expansion.

@rail-rain
Copy link

Aparrently, it's already reported, fixed and will be shipped with 1.47.

@matklad
Copy link
Member

matklad commented Sep 24, 2020

Thanks for those links @rail-rain! I think we should then close this!

@matklad matklad closed this as completed Sep 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants