Skip to content

Commit 6aa06b7

Browse files
committed
Remove #[allow]s. Apply conversations from @Jarcho
1 parent 8a2245d commit 6aa06b7

17 files changed

+68
-95
lines changed

clippy_lints/src/functions/impl_trait_in_params.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,20 @@ pub(super) fn check_fn<'tcx>(cx: &LateContext<'_>, kind: &'tcx FnKind<'_>, body:
1111
{
1212
if let FnKind::ItemFn(ident, generics, _) = kind {
1313
for param in generics.params {
14-
if param.is_impl_trait()
15-
&& !param.name.ident().as_str().contains('<')
16-
&& !param.name.ident().as_str().contains('(')
17-
{
14+
if param.is_impl_trait() {
1815
// No generics with nested generics, and no generics like FnMut(x)
1916
span_lint_and_then(
2017
cx,
2118
IMPL_TRAIT_IN_PARAMS,
2219
param.span,
23-
&format!("'{}' in the function's parameters", param.name.ident().as_str()),
20+
"'`impl Trait` used as a function parameter'",
2421
|diag| {
2522
let next_letter = next_valid_letter(generics);
2623
if let Some(gen_span) = generics.span_for_param_suggestion() {
2724
diag.span_suggestion_with_style(
2825
gen_span,
29-
format!(
30-
"create a generic type here and replace that `{}` with `{}`",
31-
param.name.ident().as_str(),
32-
next_letter
33-
),
34-
", T: Trait",
26+
"add a type paremeter, `{}`: `{}`",
27+
format!(", {next_letter}: {}", &param.name.ident().as_str()[5..]),
3528
rustc_errors::Applicability::MaybeIncorrect,
3629
rustc_errors::SuggestionStyle::ShowAlways,
3730
);
@@ -46,12 +39,8 @@ pub(super) fn check_fn<'tcx>(cx: &LateContext<'_>, kind: &'tcx FnKind<'_>, body:
4639
ident.span.ctxt(),
4740
ident.span.parent(),
4841
),
49-
format!(
50-
"create a generic type here and replace that '{}' with `{}`",
51-
param.name.ident().as_str(),
52-
next_letter
53-
),
54-
"<T: Trait>",
42+
"add a type paremeter",
43+
format!("<{next_letter}: {}>", &param.name.ident().as_str()[5..]),
5544
rustc_errors::Applicability::MaybeIncorrect,
5645
rustc_errors::SuggestionStyle::ShowAlways,
5746
);

clippy_utils/src/ast_utils.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22
//!
33
//! - The `eq_foobar` functions test for semantic equality but ignores `NodeId`s and `Span`s.
44
5-
#![allow(
6-
clippy::similar_names,
7-
clippy::wildcard_imports,
8-
clippy::enum_glob_use,
9-
clippy::impl_trait_in_params
10-
)]
5+
#![allow(clippy::similar_names, clippy::wildcard_imports, clippy::enum_glob_use)]
116

127
use crate::{both, over};
138
use rustc_ast::ptr::P;

clippy_utils/src/check_proc_macro.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(clippy::impl_trait_in_params)]
21
//! This module handles checking if the span given is from a proc-macro or not.
32
//!
43
//! Proc-macros are capable of setting the span of every token they output to a few possible spans.

clippy_utils/src/hir_utils.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(clippy::impl_trait_in_params)]
21
use crate::consts::constant_simple;
32
use crate::macros::macro_backtrace;
43
use crate::source::snippet_opt;

clippy_utils/src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(clippy::similar_names, clippy::impl_trait_in_params)] // `expr` and `expn`
1+
#![allow(clippy::similar_names)] // `expr` and `expn`
22

33
use crate::source::snippet_opt;
44
use crate::visitors::{for_each_expr, Descend};

clippy_utils/src/source.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Utils for extracting, inspecting or transforming source code
22
3-
#![allow(clippy::module_name_repetitions, clippy::impl_trait_in_params)]
3+
#![allow(clippy::module_name_repetitions)]
44

55
use rustc_errors::Applicability;
66
use rustc_hir::{Expr, ExprKind};

tests/ui/borrow_box.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#![deny(clippy::borrowed_box)]
22
#![allow(dead_code, unused_variables)]
3-
#![allow(
4-
clippy::uninlined_format_args,
5-
clippy::disallowed_names,
6-
clippy::impl_trait_in_params
7-
)]
3+
#![allow(clippy::uninlined_format_args, clippy::disallowed_names)]
84

95
use std::fmt::Display;
106

tests/ui/borrow_box.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
2-
--> $DIR/borrow_box.rs:24:14
2+
--> $DIR/borrow_box.rs:20:14
33
|
44
LL | let foo: &Box<bool>;
55
| ^^^^^^^^^^ help: try: `&bool`
@@ -11,55 +11,55 @@ LL | #![deny(clippy::borrowed_box)]
1111
| ^^^^^^^^^^^^^^^^^^^^
1212

1313
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
14-
--> $DIR/borrow_box.rs:28:10
14+
--> $DIR/borrow_box.rs:24:10
1515
|
1616
LL | foo: &'a Box<bool>,
1717
| ^^^^^^^^^^^^^ help: try: `&'a bool`
1818

1919
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
20-
--> $DIR/borrow_box.rs:32:17
20+
--> $DIR/borrow_box.rs:28:17
2121
|
2222
LL | fn test4(a: &Box<bool>);
2323
| ^^^^^^^^^^ help: try: `&bool`
2424

2525
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
26-
--> $DIR/borrow_box.rs:98:25
26+
--> $DIR/borrow_box.rs:94:25
2727
|
2828
LL | pub fn test14(_display: &Box<dyn Display>) {}
2929
| ^^^^^^^^^^^^^^^^^ help: try: `&dyn Display`
3030

3131
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
32-
--> $DIR/borrow_box.rs:99:25
32+
--> $DIR/borrow_box.rs:95:25
3333
|
3434
LL | pub fn test15(_display: &Box<dyn Display + Send>) {}
3535
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)`
3636

3737
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
38-
--> $DIR/borrow_box.rs:100:29
38+
--> $DIR/borrow_box.rs:96:29
3939
|
4040
LL | pub fn test16<'a>(_display: &'a Box<dyn Display + 'a>) {}
4141
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (dyn Display + 'a)`
4242

4343
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
44-
--> $DIR/borrow_box.rs:102:25
44+
--> $DIR/borrow_box.rs:98:25
4545
|
4646
LL | pub fn test17(_display: &Box<impl Display>) {}
4747
| ^^^^^^^^^^^^^^^^^^ help: try: `&impl Display`
4848

4949
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
50-
--> $DIR/borrow_box.rs:103:25
50+
--> $DIR/borrow_box.rs:99:25
5151
|
5252
LL | pub fn test18(_display: &Box<impl Display + Send>) {}
5353
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(impl Display + Send)`
5454

5555
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
56-
--> $DIR/borrow_box.rs:104:29
56+
--> $DIR/borrow_box.rs:100:29
5757
|
5858
LL | pub fn test19<'a>(_display: &'a Box<impl Display + 'a>) {}
5959
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (impl Display + 'a)`
6060

6161
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
62-
--> $DIR/borrow_box.rs:109:25
62+
--> $DIR/borrow_box.rs:105:25
6363
|
6464
LL | pub fn test20(_display: &Box<(dyn Display + Send)>) {}
6565
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)`

tests/ui/eta.fixed

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
clippy::no_effect,
88
clippy::option_map_unit_fn,
99
clippy::redundant_closure_call,
10-
clippy::uninlined_format_args,
11-
clippy::impl_trait_in_params
10+
clippy::uninlined_format_args
1211
)]
1312

1413
use std::path::{Path, PathBuf};

tests/ui/eta.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
clippy::no_effect,
88
clippy::option_map_unit_fn,
99
clippy::redundant_closure_call,
10-
clippy::uninlined_format_args,
11-
clippy::impl_trait_in_params
10+
clippy::uninlined_format_args
1211
)]
1312

1413
use std::path::{Path, PathBuf};

0 commit comments

Comments
 (0)