11use rustc_ast:: ast:: Attribute ;
22use rustc_errors:: Applicability ;
3- use rustc_hir:: def_id:: DefIdSet ;
3+ use rustc_hir:: def_id:: { DefIdSet , LocalDefId } ;
44use rustc_hir:: { self as hir, def:: Res , intravisit, QPath } ;
55use rustc_lint:: { LateContext , LintContext } ;
66use rustc_middle:: {
@@ -22,7 +22,7 @@ pub(super) fn check_item(cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
2222 let attrs = cx. tcx . hir ( ) . attrs ( item. hir_id ( ) ) ;
2323 let attr = must_use_attr ( attrs) ;
2424 if let hir:: ItemKind :: Fn ( ref sig, ref _generics, ref body_id) = item. kind {
25- let is_public = cx. access_levels . is_exported ( item. hir_id ( ) ) ;
25+ let is_public = cx. access_levels . is_exported ( item. def_id ) ;
2626 let fn_header_span = item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ;
2727 if let Some ( attr) = attr {
2828 check_needless_must_use ( cx, sig. decl , item. hir_id ( ) , item. span , fn_header_span, attr) ;
@@ -33,7 +33,7 @@ pub(super) fn check_item(cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
3333 sig. decl ,
3434 cx. tcx . hir ( ) . body ( * body_id) ,
3535 item. span ,
36- item. hir_id ( ) ,
36+ item. def_id ,
3737 item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ,
3838 "this function could have a `#[must_use]` attribute" ,
3939 ) ;
@@ -43,7 +43,7 @@ pub(super) fn check_item(cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
4343
4444pub ( super ) fn check_impl_item ( cx : & LateContext < ' tcx > , item : & ' tcx hir:: ImplItem < ' _ > ) {
4545 if let hir:: ImplItemKind :: Fn ( ref sig, ref body_id) = item. kind {
46- let is_public = cx. access_levels . is_exported ( item. hir_id ( ) ) ;
46+ let is_public = cx. access_levels . is_exported ( item. def_id ) ;
4747 let fn_header_span = item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ;
4848 let attrs = cx. tcx . hir ( ) . attrs ( item. hir_id ( ) ) ;
4949 let attr = must_use_attr ( attrs) ;
@@ -55,7 +55,7 @@ pub(super) fn check_impl_item(cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<
5555 sig. decl ,
5656 cx. tcx . hir ( ) . body ( * body_id) ,
5757 item. span ,
58- item. hir_id ( ) ,
58+ item. def_id ,
5959 item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ,
6060 "this method could have a `#[must_use]` attribute" ,
6161 ) ;
@@ -65,7 +65,7 @@ pub(super) fn check_impl_item(cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<
6565
6666pub ( super ) fn check_trait_item ( cx : & LateContext < ' tcx > , item : & ' tcx hir:: TraitItem < ' _ > ) {
6767 if let hir:: TraitItemKind :: Fn ( ref sig, ref eid) = item. kind {
68- let is_public = cx. access_levels . is_exported ( item. hir_id ( ) ) ;
68+ let is_public = cx. access_levels . is_exported ( item. def_id ) ;
6969 let fn_header_span = item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ;
7070
7171 let attrs = cx. tcx . hir ( ) . attrs ( item. hir_id ( ) ) ;
@@ -80,7 +80,7 @@ pub(super) fn check_trait_item(cx: &LateContext<'tcx>, item: &'tcx hir::TraitIte
8080 sig. decl ,
8181 body,
8282 item. span ,
83- item. hir_id ( ) ,
83+ item. def_id ,
8484 item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ,
8585 "this method could have a `#[must_use]` attribute" ,
8686 ) ;
@@ -132,7 +132,7 @@ fn check_must_use_candidate<'tcx>(
132132 decl : & ' tcx hir:: FnDecl < ' _ > ,
133133 body : & ' tcx hir:: Body < ' _ > ,
134134 item_span : Span ,
135- item_id : hir :: HirId ,
135+ item_id : LocalDefId ,
136136 fn_span : Span ,
137137 msg : & str ,
138138) {
@@ -141,7 +141,7 @@ fn check_must_use_candidate<'tcx>(
141141 || in_external_macro ( cx. sess ( ) , item_span)
142142 || returns_unit ( decl)
143143 || !cx. access_levels . is_exported ( item_id)
144- || is_must_use_ty ( cx, return_ty ( cx, item_id) )
144+ || is_must_use_ty ( cx, return_ty ( cx, cx . tcx . hir ( ) . local_def_id_to_hir_id ( item_id) ) )
145145 {
146146 return ;
147147 }
0 commit comments