Skip to content

extra_unused_type_parameters should not warn external macros  #10318

Closed
@taiki-e

Description

@taiki-e

Summary

extra_unused_type_parameters currently warns of code generated by external macros, but it should not. (there is no way for the user to fix it.)

Mentioning @mkrasnitski who implemented this lint in #10028.

Lint Name

extra_unused_type_parameters

Reproducer

I tried this code:

# Cargo.toml
[package]
name = "repro"
version = "0.1.0"
edition = "2021"

[dependencies]
static_assertions = "=1.1.0"
// src/lib.rs
#![warn(clippy::extra_unused_type_parameters)]

#[allow(dead_code)]
struct S(());

static_assertions::assert_impl_all!(S: Send);

I saw this happen:

warning: type parameter goes unused in function definition
 --> src/lib.rs:6:1
  |
6 | static_assertions::assert_impl_all!(S: Send);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: consider removing the parameter
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_type_parameters
note: the lint level is defined here
 --> src/lib.rs:1:9
  |
1 | #![warn(clippy::extra_unused_type_parameters)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  = note: this warning originates in the macro `static_assertions::assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info)

I expected to see this happen: no warnings

Version

rustc 1.69.0-nightly (2773383a3 2023-02-10)
binary: rustc
commit-hash: 2773383a314a4b8f481ce2bed12c32de794ffbe9
commit-date: 2023-02-10
host: aarch64-apple-darwin
release: 1.69.0-nightly
LLVM version: 15.0.7

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions