File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -1140,7 +1140,8 @@ fn detect_same_item_push<'tcx>(
11401140 walk_expr ( & mut same_item_push_visitor, body) ;
11411141 if same_item_push_visitor. should_lint {
11421142 if let Some ( ( vec, pushed_item) ) = same_item_push_visitor. vec_push {
1143- let ty = cx. typeck_results ( ) . expr_ty ( pushed_item) ;
1143+ let vec_ty = cx. typeck_results ( ) . expr_ty ( vec) ;
1144+ let ty = vec_ty. walk ( ) . nth ( 1 ) . unwrap ( ) . expect_ty ( ) ;
11441145 if cx
11451146 . tcx
11461147 . lang_items ( )
Original file line number Diff line number Diff line change @@ -100,4 +100,15 @@ fn main() {
100100 for _ in 0 ..10 {
101101 vec14. push ( std:: fs:: File :: open ( "foobar" ) . unwrap ( ) ) ;
102102 }
103+ // Fix #5979
104+ #[ derive( Clone ) ]
105+ struct S { }
106+
107+ trait T { }
108+ impl T for S { }
109+
110+ let mut vec15: Vec < Box < dyn T > > = Vec :: new ( ) ;
111+ for _ in 0 ..10 {
112+ vec15. push ( Box :: new ( S { } ) ) ;
113+ }
103114}
You can’t perform that action at this time.
0 commit comments