@@ -13,7 +13,6 @@ use rustc_hir::def_id::DefId;
1313use rustc_hir:: {
1414 BodyId , Expr , ExprKind , HirId , Impl , ImplItem , ImplItemKind , Item , ItemKind , Node , TraitItem , TraitItemKind , UnOp ,
1515} ;
16- use rustc_hir_analysis:: hir_ty_to_ty;
1716use rustc_lint:: { LateContext , LateLintPass , Lint } ;
1817use rustc_middle:: mir:: interpret:: { ErrorHandled , EvalToValTreeResult , GlobalId } ;
1918use rustc_middle:: ty:: adjustment:: Adjust ;
@@ -297,17 +296,17 @@ declare_lint_pass!(NonCopyConst => [DECLARE_INTERIOR_MUTABLE_CONST, BORROW_INTER
297296
298297impl < ' tcx > LateLintPass < ' tcx > for NonCopyConst {
299298 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 ( ) ;
302301 if !ignored_macro ( cx, it) && is_unfrozen ( cx, ty) && is_value_unfrozen_poly ( cx, body_id, ty) {
303302 lint ( cx, Source :: Item { item : it. span } ) ;
304303 }
305304 }
306305 }
307306
308307 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 ( ) ;
311310
312311 // Normalize assoc types because ones originated from generic params
313312 // bounded other traits could have their bound.
@@ -333,7 +332,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst {
333332 }
334333
335334 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 {
337336 let item_def_id = cx. tcx . hir ( ) . get_parent_item ( impl_item. hir_id ( ) ) . def_id ;
338337 let item = cx. tcx . hir ( ) . expect_item ( item_def_id) ;
339338
@@ -366,7 +365,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst {
366365 // we should use here as a frozen variant is a potential to be frozen
367366 // similar to unknown layouts.
368367 // 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 ( ) ;
370369 let normalized = cx. tcx. normalize_erasing_regions( cx. param_env, ty) ;
371370 if is_unfrozen( cx, normalized) ;
372371 if is_value_unfrozen_poly( cx, * body_id, normalized) ;
@@ -381,7 +380,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst {
381380 }
382381 } ,
383382 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 ( ) ;
385384 // Normalize assoc types originated from generic params.
386385 let normalized = cx. tcx . normalize_erasing_regions ( cx. param_env , ty) ;
387386
0 commit comments