@@ -13,7 +13,6 @@ use rustc_hir::def_id::DefId;
13
13
use rustc_hir:: {
14
14
BodyId , Expr , ExprKind , HirId , Impl , ImplItem , ImplItemKind , Item , ItemKind , Node , TraitItem , TraitItemKind , UnOp ,
15
15
} ;
16
- use rustc_hir_analysis:: hir_ty_to_ty;
17
16
use rustc_lint:: { LateContext , LateLintPass , Lint } ;
18
17
use rustc_middle:: mir:: interpret:: { ErrorHandled , EvalToValTreeResult , GlobalId } ;
19
18
use rustc_middle:: ty:: adjustment:: Adjust ;
@@ -297,17 +296,17 @@ declare_lint_pass!(NonCopyConst => [DECLARE_INTERIOR_MUTABLE_CONST, BORROW_INTER
297
296
298
297
impl < ' tcx > LateLintPass < ' tcx > for NonCopyConst {
299
298
fn check_item ( & mut self , cx : & LateContext < ' tcx > , it : & ' tcx Item < ' _ > ) {
300
- if let ItemKind :: Const ( hir_ty , _generics , body_id) = it. kind {
301
- let ty = hir_ty_to_ty ( cx. tcx , hir_ty ) ;
299
+ if let ItemKind :: Const ( .. , body_id) = it. kind {
300
+ let ty = cx. tcx . type_of ( it . owner_id ) . instantiate_identity ( ) ;
302
301
if !ignored_macro ( cx, it) && is_unfrozen ( cx, ty) && is_value_unfrozen_poly ( cx, body_id, ty) {
303
302
lint ( cx, Source :: Item { item : it. span } ) ;
304
303
}
305
304
}
306
305
}
307
306
308
307
fn check_trait_item ( & mut self , cx : & LateContext < ' tcx > , trait_item : & ' tcx TraitItem < ' _ > ) {
309
- if let TraitItemKind :: Const ( hir_ty , body_id_opt) = & trait_item. kind {
310
- let ty = hir_ty_to_ty ( cx. tcx , hir_ty ) ;
308
+ if let TraitItemKind :: Const ( _ , body_id_opt) = & trait_item. kind {
309
+ let ty = cx. tcx . type_of ( trait_item . owner_id ) . instantiate_identity ( ) ;
311
310
312
311
// Normalize assoc types because ones originated from generic params
313
312
// bounded other traits could have their bound.
@@ -333,7 +332,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst {
333
332
}
334
333
335
334
fn check_impl_item ( & mut self , cx : & LateContext < ' tcx > , impl_item : & ' tcx ImplItem < ' _ > ) {
336
- if let ImplItemKind :: Const ( hir_ty , body_id) = & impl_item. kind {
335
+ if let ImplItemKind :: Const ( _ , body_id) = & impl_item. kind {
337
336
let item_def_id = cx. tcx . hir ( ) . get_parent_item ( impl_item. hir_id ( ) ) . def_id ;
338
337
let item = cx. tcx . hir ( ) . expect_item ( item_def_id) ;
339
338
@@ -366,7 +365,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst {
366
365
// we should use here as a frozen variant is a potential to be frozen
367
366
// similar to unknown layouts.
368
367
// e.g. `layout_of(...).is_err() || has_frozen_variant(...);`
369
- let ty = hir_ty_to_ty ( cx. tcx, hir_ty ) ;
368
+ let ty = cx. tcx. type_of ( impl_item . owner_id ) . instantiate_identity ( ) ;
370
369
let normalized = cx. tcx. normalize_erasing_regions( cx. param_env, ty) ;
371
370
if is_unfrozen( cx, normalized) ;
372
371
if is_value_unfrozen_poly( cx, * body_id, normalized) ;
@@ -381,7 +380,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst {
381
380
}
382
381
} ,
383
382
ItemKind :: Impl ( Impl { of_trait : None , .. } ) => {
384
- let ty = hir_ty_to_ty ( cx. tcx , hir_ty ) ;
383
+ let ty = cx. tcx . type_of ( impl_item . owner_id ) . instantiate_identity ( ) ;
385
384
// Normalize assoc types originated from generic params.
386
385
let normalized = cx. tcx . normalize_erasing_regions ( cx. param_env , ty) ;
387
386
0 commit comments