mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
Avoid linting on procedural macros
This commit is contained in:
parent
1b4c423f30
commit
f0eb40c981
4 changed files with 34 additions and 8 deletions
|
@ -1,4 +1,5 @@
|
|||
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_then};
|
||||
use clippy_utils::is_from_proc_macro;
|
||||
use clippy_utils::trait_ref_of_method;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_errors::Applicability;
|
||||
|
@ -265,6 +266,7 @@ impl<'tcx> LateLintPass<'tcx> for ExtraUnusedTypeParameters {
|
|||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
|
||||
if let ItemKind::Fn(_, generics, body_id) = item.kind
|
||||
&& !self.is_empty_exported_or_macro(cx, item.span, item.owner_id.def_id, body_id)
|
||||
&& !is_from_proc_macro(cx, item)
|
||||
{
|
||||
let mut walker = TypeWalker::new(cx, generics);
|
||||
walk_item(&mut walker, item);
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
//@run-rustfix
|
||||
//@aux-build:proc_macros.rs
|
||||
|
||||
#![allow(unused, clippy::needless_lifetimes)]
|
||||
#![warn(clippy::extra_unused_type_parameters)]
|
||||
|
||||
extern crate proc_macros;
|
||||
use proc_macros::with_span;
|
||||
|
||||
fn unused_ty(x: u8) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
@ -102,4 +106,12 @@ mod issue10319 {
|
|||
}
|
||||
}
|
||||
|
||||
with_span!(
|
||||
span
|
||||
|
||||
fn should_not_lint<T>(x: u8) {
|
||||
unimplemented!()
|
||||
}
|
||||
);
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
//@run-rustfix
|
||||
//@aux-build:proc_macros.rs
|
||||
|
||||
#![allow(unused, clippy::needless_lifetimes)]
|
||||
#![warn(clippy::extra_unused_type_parameters)]
|
||||
|
||||
extern crate proc_macros;
|
||||
use proc_macros::with_span;
|
||||
|
||||
fn unused_ty<T>(x: u8) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
@ -102,4 +106,12 @@ mod issue10319 {
|
|||
}
|
||||
}
|
||||
|
||||
with_span!(
|
||||
span
|
||||
|
||||
fn should_not_lint<T>(x: u8) {
|
||||
unimplemented!()
|
||||
}
|
||||
);
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: type parameter `T` goes unused in function definition
|
||||
--> $DIR/extra_unused_type_parameters.rs:6:13
|
||||
--> $DIR/extra_unused_type_parameters.rs:10:13
|
||||
|
|
||||
LL | fn unused_ty<T>(x: u8) {
|
||||
| ^^^ help: consider removing the parameter
|
||||
|
@ -7,19 +7,19 @@ LL | fn unused_ty<T>(x: u8) {
|
|||
= note: `-D clippy::extra-unused-type-parameters` implied by `-D warnings`
|
||||
|
||||
error: type parameters go unused in function definition: T, U
|
||||
--> $DIR/extra_unused_type_parameters.rs:10:16
|
||||
--> $DIR/extra_unused_type_parameters.rs:14:16
|
||||
|
|
||||
LL | fn unused_multi<T, U>(x: u8) {
|
||||
| ^^^^^^ help: consider removing the parameters
|
||||
|
||||
error: type parameter `T` goes unused in function definition
|
||||
--> $DIR/extra_unused_type_parameters.rs:14:21
|
||||
--> $DIR/extra_unused_type_parameters.rs:18:21
|
||||
|
|
||||
LL | fn unused_with_lt<'a, T>(x: &'a u8) {
|
||||
| ^^^ help: consider removing the parameter
|
||||
|
||||
error: type parameters go unused in function definition: T, V
|
||||
--> $DIR/extra_unused_type_parameters.rs:26:19
|
||||
--> $DIR/extra_unused_type_parameters.rs:30:19
|
||||
|
|
||||
LL | fn unused_bounded<T: Default, U, V: Default>(x: U) {
|
||||
| ^^^^^^^^^^^^ ^^^^^^^^^^^^
|
||||
|
@ -31,7 +31,7 @@ LL + fn unused_bounded<U>(x: U) {
|
|||
|
|
||||
|
||||
error: type parameters go unused in function definition: A, D, E
|
||||
--> $DIR/extra_unused_type_parameters.rs:30:16
|
||||
--> $DIR/extra_unused_type_parameters.rs:34:16
|
||||
|
|
||||
LL | fn some_unused<A, B, C, D: Iterator<Item = (B, C)>, E>(b: B, c: C) {
|
||||
| ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -43,19 +43,19 @@ LL + fn some_unused<B, C>(b: B, c: C) {
|
|||
|
|
||||
|
||||
error: type parameter `T` goes unused in function definition
|
||||
--> $DIR/extra_unused_type_parameters.rs:55:22
|
||||
--> $DIR/extra_unused_type_parameters.rs:59:22
|
||||
|
|
||||
LL | fn unused_ty_impl<T>(&self) {
|
||||
| ^^^ help: consider removing the parameter
|
||||
|
||||
error: type parameters go unused in function definition: A, B
|
||||
--> $DIR/extra_unused_type_parameters.rs:77:17
|
||||
--> $DIR/extra_unused_type_parameters.rs:81:17
|
||||
|
|
||||
LL | fn unused_opaque<A, B>(dummy: impl Default) {
|
||||
| ^^^^^^ help: consider removing the parameters
|
||||
|
||||
error: type parameter `U` goes unused in function definition
|
||||
--> $DIR/extra_unused_type_parameters.rs:90:56
|
||||
--> $DIR/extra_unused_type_parameters.rs:94:56
|
||||
|
|
||||
LL | fn unused_with_priv_trait_bound<T: private::Private, U>() {
|
||||
| ^^^ help: consider removing the parameter
|
||||
|
|
Loading…
Reference in a new issue