@@ -5,18 +5,10 @@ use rustc_hir as hir;
5
5
use rustc_hir:: intravisit:: FnKind ;
6
6
use rustc_hir:: { Body , GenericParam , Generics , HirId , ImplItem , ImplItemKind , TraitItem , TraitItemKind } ;
7
7
use rustc_lint:: LateContext ;
8
- use rustc_span:: symbol:: Ident ;
9
- use rustc_span:: { BytePos , Span } ;
10
8
11
9
use super :: IMPL_TRAIT_IN_PARAMS ;
12
10
13
- fn report (
14
- cx : & LateContext < ' _ > ,
15
- param : & GenericParam < ' _ > ,
16
- ident : & Ident ,
17
- generics : & Generics < ' _ > ,
18
- first_param_span : Span ,
19
- ) {
11
+ fn report ( cx : & LateContext < ' _ > , param : & GenericParam < ' _ > , generics : & Generics < ' _ > ) {
20
12
// No generics with nested generics, and no generics like FnMut(x)
21
13
span_lint_and_then (
22
14
cx,
@@ -35,12 +27,7 @@ fn report(
35
27
) ;
36
28
} else {
37
29
diag. span_suggestion_with_style (
38
- Span :: new (
39
- first_param_span. lo ( ) - rustc_span:: BytePos ( 1 ) ,
40
- ident. span . hi ( ) ,
41
- ident. span . ctxt ( ) ,
42
- ident. span . parent ( ) ,
43
- ) ,
30
+ generics. span ,
44
31
"add a type parameter" ,
45
32
format ! ( "<{{ /* Generic name */ }}: {}>" , & param. name. ident( ) . as_str( ) [ 5 ..] ) ,
46
33
rustc_errors:: Applicability :: HasPlaceholders ,
@@ -52,13 +39,13 @@ fn report(
52
39
}
53
40
54
41
pub ( super ) fn check_fn < ' tcx > ( cx : & LateContext < ' _ > , kind : & ' tcx FnKind < ' _ > , body : & ' tcx Body < ' _ > , hir_id : HirId ) {
55
- if let FnKind :: ItemFn ( ident , generics, _) = kind
42
+ if let FnKind :: ItemFn ( _ , generics, _) = kind
56
43
&& cx. tcx . visibility ( cx. tcx . hir ( ) . body_owner_def_id ( body. id ( ) ) ) . is_public ( )
57
44
&& !is_in_test_function ( cx. tcx , hir_id)
58
45
{
59
46
for param in generics. params {
60
47
if param. is_impl_trait ( ) {
61
- report ( cx, param, ident , generics, body . params [ 0 ] . span ) ;
48
+ report ( cx, param, generics) ;
62
49
} ;
63
50
}
64
51
}
@@ -76,7 +63,7 @@ pub(super) fn check_impl_item(cx: &LateContext<'_>, impl_item: &ImplItem<'_>) {
76
63
{
77
64
for param in impl_item. generics . params {
78
65
if param. is_impl_trait ( ) {
79
- report ( cx, param, & impl_item. ident , impl_item . generics , body . params [ 0 ] . span ) ;
66
+ report ( cx, param, impl_item. generics ) ;
80
67
}
81
68
}
82
69
}
@@ -92,8 +79,7 @@ pub(super) fn check_trait_item(cx: &LateContext<'_>, trait_item: &TraitItem<'_>,
92
79
{
93
80
for param in trait_item. generics . params {
94
81
if param. is_impl_trait ( ) {
95
- let sp = trait_item. ident . span . with_hi ( trait_item. ident . span . hi ( ) + BytePos ( 1 ) ) ;
96
- report ( cx, param, & trait_item. ident , trait_item. generics , sp. shrink_to_hi ( ) ) ;
82
+ report ( cx, param, trait_item. generics ) ;
97
83
}
98
84
}
99
85
}
0 commit comments