File tree Expand file tree Collapse file tree 2 files changed +34
-6
lines changed Expand file tree Collapse file tree 2 files changed +34
-6
lines changed Original file line number Diff line number Diff line change 11#![ warn( clippy:: unused_box) ]
22
3- fn foo ( ) -> Box < usize > {
3+ struct Foo { }
4+
5+ // lint
6+ fn boxed_usize ( ) -> Box < usize > {
47 Box :: new ( 5 )
58}
69
10+ // lint
11+ fn boxed_string ( ) -> Box < Foo > {
12+ Box :: new ( Foo { } )
13+ }
14+
15+ // don't lint: str is unsized
16+ fn boxed_str ( ) -> Box < str > {
17+ "Hello, world!" . to_string ( ) . into_boxed_str ( )
18+ }
19+
20+ // don't lint: this has an unspecified return type
21+ fn default ( ) { }
22+
23+ // don't lint: this doesn't return a Box
24+ fn string ( ) -> String {
25+ String :: from ( "Hello, world" )
26+ }
27+
728fn main ( ) {
8- // test code goes here
29+ // don't lint: this is a closure
30+ let a = || -> Box < usize > { Box :: new ( 5 ) } ;
931}
Original file line number Diff line number Diff line change 11error: function returns `Box<usize>` when `usize` implements `Sized`
2- --> $DIR/unused_box.rs:3:13
2+ --> $DIR/unused_box.rs:6:21
33 |
4- LL | fn foo () -> Box<usize> {
5- | ^^^^^^^^^^ help: change the return type to: `usize`
4+ LL | fn boxed_usize () -> Box<usize> {
5+ | ^^^^^^^^^^ help: change the return type to: `usize`
66 |
77 = note: `-D clippy::unused-box` implied by `-D warnings`
88
9- error: aborting due to previous error
9+ error: function returns `Box<Foo>` when `Foo` implements `Sized`
10+ --> $DIR/unused_box.rs:11:22
11+ |
12+ LL | fn boxed_string() -> Box<Foo> {
13+ | ^^^^^^^^ help: change the return type to: `Foo`
14+
15+ error: aborting due to 2 previous errors
1016
You can’t perform that action at this time.
0 commit comments