1
1
use rustc_ast:: ast:: Attribute ;
2
2
use rustc_errors:: Applicability ;
3
- use rustc_hir:: def_id:: DefIdSet ;
3
+ use rustc_hir:: def_id:: { DefIdSet , LocalDefId } ;
4
4
use rustc_hir:: { self as hir, def:: Res , intravisit, QPath } ;
5
5
use rustc_lint:: { LateContext , LintContext } ;
6
6
use rustc_middle:: {
@@ -22,7 +22,7 @@ pub(super) fn check_item(cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
22
22
let attrs = cx. tcx . hir ( ) . attrs ( item. hir_id ( ) ) ;
23
23
let attr = must_use_attr ( attrs) ;
24
24
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 ) ;
26
26
let fn_header_span = item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ;
27
27
if let Some ( attr) = attr {
28
28
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<'_>) {
33
33
sig. decl ,
34
34
cx. tcx . hir ( ) . body ( * body_id) ,
35
35
item. span ,
36
- item. hir_id ( ) ,
36
+ item. def_id ,
37
37
item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ,
38
38
"this function could have a `#[must_use]` attribute" ,
39
39
) ;
@@ -43,7 +43,7 @@ pub(super) fn check_item(cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
43
43
44
44
pub ( super ) fn check_impl_item ( cx : & LateContext < ' tcx > , item : & ' tcx hir:: ImplItem < ' _ > ) {
45
45
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 ) ;
47
47
let fn_header_span = item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ;
48
48
let attrs = cx. tcx . hir ( ) . attrs ( item. hir_id ( ) ) ;
49
49
let attr = must_use_attr ( attrs) ;
@@ -55,7 +55,7 @@ pub(super) fn check_impl_item(cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<
55
55
sig. decl ,
56
56
cx. tcx . hir ( ) . body ( * body_id) ,
57
57
item. span ,
58
- item. hir_id ( ) ,
58
+ item. def_id ,
59
59
item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ,
60
60
"this method could have a `#[must_use]` attribute" ,
61
61
) ;
@@ -65,7 +65,7 @@ pub(super) fn check_impl_item(cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<
65
65
66
66
pub ( super ) fn check_trait_item ( cx : & LateContext < ' tcx > , item : & ' tcx hir:: TraitItem < ' _ > ) {
67
67
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 ) ;
69
69
let fn_header_span = item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ;
70
70
71
71
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
80
80
sig. decl ,
81
81
body,
82
82
item. span ,
83
- item. hir_id ( ) ,
83
+ item. def_id ,
84
84
item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ,
85
85
"this method could have a `#[must_use]` attribute" ,
86
86
) ;
@@ -132,7 +132,7 @@ fn check_must_use_candidate<'tcx>(
132
132
decl : & ' tcx hir:: FnDecl < ' _ > ,
133
133
body : & ' tcx hir:: Body < ' _ > ,
134
134
item_span : Span ,
135
- item_id : hir :: HirId ,
135
+ item_id : LocalDefId ,
136
136
fn_span : Span ,
137
137
msg : & str ,
138
138
) {
@@ -141,7 +141,7 @@ fn check_must_use_candidate<'tcx>(
141
141
|| in_external_macro ( cx. sess ( ) , item_span)
142
142
|| returns_unit ( decl)
143
143
|| !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) ) )
145
145
{
146
146
return ;
147
147
}
0 commit comments