1
1
#![ allow( rustc:: default_hash_types) ]
2
2
3
+ mod box_vec;
4
+
3
5
use std:: borrow:: Cow ;
4
6
use std:: cmp:: Ordering ;
5
7
use std:: collections:: BTreeMap ;
@@ -346,6 +348,7 @@ impl Types {
346
348
let hir_id = hir_ty. hir_id ;
347
349
let res = cx. qpath_res ( qpath, hir_id) ;
348
350
if let Some ( def_id) = res. opt_def_id ( ) {
351
+ box_vec:: check ( cx, hir_ty, qpath, def_id) ;
349
352
if Some ( def_id) == cx. tcx . lang_items ( ) . owned_box ( ) {
350
353
if let Some ( span) = match_borrows_parameter ( cx, qpath) {
351
354
let mut applicability = Applicability :: MachineApplicable ;
@@ -360,17 +363,6 @@ impl Types {
360
363
) ;
361
364
return ; // don't recurse into the type
362
365
}
363
- if is_ty_param_diagnostic_item ( cx, qpath, sym:: vec_type) . is_some ( ) {
364
- span_lint_and_help (
365
- cx,
366
- BOX_VEC ,
367
- hir_ty. span ,
368
- "you seem to be trying to use `Box<Vec<T>>`. Consider using just `Vec<T>`" ,
369
- None ,
370
- "`Vec<T>` is already on the heap, `Box<Vec<T>>` makes an extra allocation" ,
371
- ) ;
372
- return ; // don't recurse into the type
373
- }
374
366
} else if cx. tcx . is_diagnostic_item ( sym:: Rc , def_id) {
375
367
if let Some ( ty) = is_ty_param_diagnostic_item ( cx, qpath, sym:: Rc ) {
376
368
let mut applicability = Applicability :: MachineApplicable ;
0 commit comments