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 {
7070 . iter ( )
7171 . any ( |s| cx. tcx . is_diagnostic_item ( * s, i. def_id ( ) ) )
7272 {
73- let span = expr. span ;
73+ let expr_span = expr. span ;
7474
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 ( )
7880 } ) ;
7981 }
8082 }
Original file line number Diff line number Diff line change @@ -21,25 +21,25 @@ impl<T> Deref for DerefExample<T> {
2121
2222fn main ( ) {
2323 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]
2525
2626 let bar = & Bar ( 1u32 ) ;
2727 let bar_clone: Bar < u32 > = bar. clone ( ) ;
2828
2929 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]
3131
3232 let deref = & DerefExample ( 12u32 ) ;
3333 let derefed: & u32 = deref. deref ( ) ;
3434
3535 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]
3737}
3838
3939fn generic < T > ( foo : & Foo < T > ) {
4040 foo. clone ( ) ;
4141}
4242
4343fn 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]
4545}
Original file line number Diff line number Diff line change 1- warning: call to noop method
1+ warning: call to method that does nothing
22 --> $DIR/noop-method-call.rs:24:32
33 |
44LL | let foo_clone: &Foo<u32> = foo.clone();
5- | ^^^^^^^^^^^
5+ | ^^^^^^^^^^^ unnecessary method call
66 |
77 = note: `#[warn(noop_method_call)]` on by default
88
9- warning: call to noop method
9+ warning: call to method that does nothing
1010 --> $DIR/noop-method-call.rs:30:39
1111 |
1212LL | let derefed: &DerefExample<u32> = deref.deref();
13- | ^^^^^^^^^^^^^
13+ | ^^^^^^^^^^^^^ unnecessary method call
1414
15- warning: call to noop method
15+ warning: call to method that does nothing
1616 --> $DIR/noop-method-call.rs:36:31
1717 |
1818LL | let borrowed: &Foo<u32> = a.borrow();
19- | ^^^^^^^^^^
19+ | ^^^^^^^^^^ unnecessary method call
2020
21- warning: call to noop method
21+ warning: call to method that does nothing
2222 --> $DIR/noop-method-call.rs:44:5
2323 |
2424LL | foo.clone();
25- | ^^^^^^^^^^^
25+ | ^^^^^^^^^^^ unnecessary method call
2626
2727warning: 4 warnings emitted
2828
You can’t perform that action at this time.
0 commit comments