11use rustc_ast:: ast:: Attribute ;
22use rustc_errors:: Applicability ;
3- use rustc_hir:: def_id:: { DefIdSet , LocalDefId } ;
3+ use rustc_hir:: def_id:: DefIdSet ;
44use rustc_hir:: { self as hir, def:: Res , QPath } ;
55use rustc_lint:: { LateContext , LintContext } ;
66use rustc_middle:: {
@@ -27,14 +27,14 @@ pub(super) fn check_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>
2727 let is_public = cx. effective_visibilities . is_exported ( item. owner_id . def_id ) ;
2828 let fn_header_span = item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ;
2929 if let Some ( attr) = attr {
30- check_needless_must_use ( cx, sig. decl , item. hir_id ( ) , item. span , fn_header_span, attr) ;
30+ check_needless_must_use ( cx, sig. decl , item. owner_id , item. span , fn_header_span, attr) ;
3131 } else if is_public && !is_proc_macro ( cx. sess ( ) , attrs) && !attrs. iter ( ) . any ( |a| a. has_name ( sym:: no_mangle) ) {
3232 check_must_use_candidate (
3333 cx,
3434 sig. decl ,
3535 cx. tcx . hir ( ) . body ( * body_id) ,
3636 item. span ,
37- item. owner_id . def_id ,
37+ item. owner_id ,
3838 item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ,
3939 "this function could have a `#[must_use]` attribute" ,
4040 ) ;
@@ -49,7 +49,7 @@ pub(super) fn check_impl_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Imp
4949 let attrs = cx. tcx . hir ( ) . attrs ( item. hir_id ( ) ) ;
5050 let attr = cx. tcx . get_attr ( item. owner_id . to_def_id ( ) , sym:: must_use) ;
5151 if let Some ( attr) = attr {
52- check_needless_must_use ( cx, sig. decl , item. hir_id ( ) , item. span , fn_header_span, attr) ;
52+ check_needless_must_use ( cx, sig. decl , item. owner_id , item. span , fn_header_span, attr) ;
5353 } else if is_public
5454 && !is_proc_macro ( cx. sess ( ) , attrs)
5555 && trait_ref_of_method ( cx, item. owner_id . def_id ) . is_none ( )
@@ -59,7 +59,7 @@ pub(super) fn check_impl_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Imp
5959 sig. decl ,
6060 cx. tcx . hir ( ) . body ( * body_id) ,
6161 item. span ,
62- item. owner_id . def_id ,
62+ item. owner_id ,
6363 item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ,
6464 "this method could have a `#[must_use]` attribute" ,
6565 ) ;
@@ -75,7 +75,7 @@ pub(super) fn check_trait_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Tr
7575 let attrs = cx. tcx . hir ( ) . attrs ( item. hir_id ( ) ) ;
7676 let attr = cx. tcx . get_attr ( item. owner_id . to_def_id ( ) , sym:: must_use) ;
7777 if let Some ( attr) = attr {
78- check_needless_must_use ( cx, sig. decl , item. hir_id ( ) , item. span , fn_header_span, attr) ;
78+ check_needless_must_use ( cx, sig. decl , item. owner_id , item. span , fn_header_span, attr) ;
7979 } else if let hir:: TraitFn :: Provided ( eid) = * eid {
8080 let body = cx. tcx . hir ( ) . body ( eid) ;
8181 if attr. is_none ( ) && is_public && !is_proc_macro ( cx. sess ( ) , attrs) {
@@ -84,7 +84,7 @@ pub(super) fn check_trait_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Tr
8484 sig. decl ,
8585 body,
8686 item. span ,
87- item. owner_id . def_id ,
87+ item. owner_id ,
8888 item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ,
8989 "this method could have a `#[must_use]` attribute" ,
9090 ) ;
@@ -96,7 +96,7 @@ pub(super) fn check_trait_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Tr
9696fn check_needless_must_use (
9797 cx : & LateContext < ' _ > ,
9898 decl : & hir:: FnDecl < ' _ > ,
99- item_id : hir:: HirId ,
99+ item_id : hir:: OwnerId ,
100100 item_span : Span ,
101101 fn_header_span : Span ,
102102 attr : & Attribute ,
@@ -131,16 +131,16 @@ fn check_must_use_candidate<'tcx>(
131131 decl : & ' tcx hir:: FnDecl < ' _ > ,
132132 body : & ' tcx hir:: Body < ' _ > ,
133133 item_span : Span ,
134- item_id : LocalDefId ,
134+ item_id : hir :: OwnerId ,
135135 fn_span : Span ,
136136 msg : & str ,
137137) {
138138 if has_mutable_arg ( cx, body)
139139 || mutates_static ( cx, body)
140140 || in_external_macro ( cx. sess ( ) , item_span)
141141 || returns_unit ( decl)
142- || !cx. effective_visibilities . is_exported ( item_id)
143- || is_must_use_ty ( cx, return_ty ( cx, cx . tcx . hir ( ) . local_def_id_to_hir_id ( item_id) ) )
142+ || !cx. effective_visibilities . is_exported ( item_id. def_id )
143+ || is_must_use_ty ( cx, return_ty ( cx, item_id) )
144144 {
145145 return ;
146146 }
0 commit comments