File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ impl LateLintPass<'_> for BoxDefault {
4646 && !in_external_macro ( cx. sess ( ) , expr. span )
4747 && ( expr. span . eq_ctxt ( arg. span ) || is_vec_expn ( cx, arg) )
4848 && seg. ident . name == sym:: new
49- && path_def_id ( cx, ty) == cx. tcx . lang_items ( ) . owned_box ( )
49+ && path_def_id ( cx, ty) . map_or ( false , |id| Some ( id ) == cx. tcx . lang_items ( ) . owned_box ( ) )
5050 && is_default_equivalent ( cx, arg)
5151 {
5252 let arg_ty = cx. typeck_results ( ) . expr_ty ( arg) ;
Original file line number Diff line number Diff line change 1+ #![ feature( lang_items, start, libc) ]
2+ #![ warn( clippy:: box_default) ]
3+ #![ no_std]
4+
5+ pub struct NotBox < T > {
6+ _value : T ,
7+ }
8+
9+ impl < T > NotBox < T > {
10+ pub fn new ( value : T ) -> Self {
11+ Self { _value : value }
12+ }
13+ }
14+
15+ impl < T : Default > Default for NotBox < T > {
16+ fn default ( ) -> Self {
17+ Self :: new ( T :: default ( ) )
18+ }
19+ }
20+
21+ #[ start]
22+ fn main ( _argc : isize , _argv : * const * const u8 ) -> isize {
23+ let _p = NotBox :: new ( isize:: default ( ) ) ;
24+ 0
25+ }
26+
27+ #[ panic_handler]
28+ fn panic ( _info : & core:: panic:: PanicInfo ) -> ! {
29+ loop { }
30+ }
31+
32+ #[ lang = "eh_personality" ]
33+ extern "C" fn eh_personality ( ) { }
You can’t perform that action at this time.
0 commit comments