File tree Expand file tree Collapse file tree 3 files changed +18
-16
lines changed Expand file tree Collapse file tree 3 files changed +18
-16
lines changed Original file line number Diff line number Diff line change @@ -70,11 +70,13 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
70
70
. iter ( )
71
71
. any ( |s| cx. tcx . is_diagnostic_item ( * s, i. def_id ( ) ) )
72
72
{
73
- let span = expr. span ;
73
+ let expr_span = expr. span ;
74
74
75
- cx. struct_span_lint ( NOOP_METHOD_CALL , span, |lint| {
76
- let message = "call to noop method" ;
77
- lint. build ( & message) . emit ( )
75
+ cx. struct_span_lint ( NOOP_METHOD_CALL , expr_span, |lint| {
76
+ let message = "call to method that does nothing" ;
77
+ lint. build ( & message)
78
+ . span_label ( expr_span, "unnecessary method call" )
79
+ . emit ( )
78
80
} ) ;
79
81
}
80
82
}
Original file line number Diff line number Diff line change @@ -21,25 +21,25 @@ impl<T> Deref for DerefExample<T> {
21
21
22
22
fn main ( ) {
23
23
let foo = & Foo ( 1u32 ) ;
24
- let foo_clone: & Foo < u32 > = foo. clone ( ) ; //~ WARNING call to noop method
24
+ let foo_clone: & Foo < u32 > = foo. clone ( ) ; //~ WARNING call to method that does nothing [noop_method_call]
25
25
26
26
let bar = & Bar ( 1u32 ) ;
27
27
let bar_clone: Bar < u32 > = bar. clone ( ) ;
28
28
29
29
let deref = & & DerefExample ( 12u32 ) ;
30
- let derefed: & DerefExample < u32 > = deref. deref ( ) ; //~ WARNING call to noop method
30
+ let derefed: & DerefExample < u32 > = deref. deref ( ) ; //~ WARNING call to method that does nothing [noop_method_call]
31
31
32
32
let deref = & DerefExample ( 12u32 ) ;
33
33
let derefed: & u32 = deref. deref ( ) ;
34
34
35
35
let a = & & Foo ( 1u32 ) ;
36
- let borrowed: & Foo < u32 > = a. borrow ( ) ; //~ WARNING call to noop method
36
+ let borrowed: & Foo < u32 > = a. borrow ( ) ; //~ WARNING call to method that does nothing [noop_method_call]
37
37
}
38
38
39
39
fn generic < T > ( foo : & Foo < T > ) {
40
40
foo. clone ( ) ;
41
41
}
42
42
43
43
fn non_generic ( foo : & Foo < u32 > ) {
44
- foo. clone ( ) ; //~ WARNING call to noop method
44
+ foo. clone ( ) ; //~ WARNING call to method that does nothing [noop_method_call]
45
45
}
Original file line number Diff line number Diff line change 1
- warning: call to noop method
1
+ warning: call to method that does nothing
2
2
--> $DIR/noop-method-call.rs:24:32
3
3
|
4
4
LL | let foo_clone: &Foo<u32> = foo.clone();
5
- | ^^^^^^^^^^^
5
+ | ^^^^^^^^^^^ unnecessary method call
6
6
|
7
7
= note: `#[warn(noop_method_call)]` on by default
8
8
9
- warning: call to noop method
9
+ warning: call to method that does nothing
10
10
--> $DIR/noop-method-call.rs:30:39
11
11
|
12
12
LL | let derefed: &DerefExample<u32> = deref.deref();
13
- | ^^^^^^^^^^^^^
13
+ | ^^^^^^^^^^^^^ unnecessary method call
14
14
15
- warning: call to noop method
15
+ warning: call to method that does nothing
16
16
--> $DIR/noop-method-call.rs:36:31
17
17
|
18
18
LL | let borrowed: &Foo<u32> = a.borrow();
19
- | ^^^^^^^^^^
19
+ | ^^^^^^^^^^ unnecessary method call
20
20
21
- warning: call to noop method
21
+ warning: call to method that does nothing
22
22
--> $DIR/noop-method-call.rs:44:5
23
23
|
24
24
LL | foo.clone();
25
- | ^^^^^^^^^^^
25
+ | ^^^^^^^^^^^ unnecessary method call
26
26
27
27
warning: 4 warnings emitted
28
28
You can’t perform that action at this time.
0 commit comments