1
1
use rustc_ast:: ast:: Attribute ;
2
2
use rustc_errors:: Applicability ;
3
- use rustc_hir:: def_id:: { DefIdSet , LocalDefId } ;
3
+ use rustc_hir:: def_id:: DefIdSet ;
4
4
use rustc_hir:: { self as hir, def:: Res , QPath } ;
5
5
use rustc_lint:: { LateContext , LintContext } ;
6
6
use rustc_middle:: {
@@ -27,14 +27,14 @@ pub(super) fn check_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>
27
27
let is_public = cx. effective_visibilities . is_exported ( item. owner_id . def_id ) ;
28
28
let fn_header_span = item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ;
29
29
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) ;
31
31
} else if is_public && !is_proc_macro ( cx. sess ( ) , attrs) && !attrs. iter ( ) . any ( |a| a. has_name ( sym:: no_mangle) ) {
32
32
check_must_use_candidate (
33
33
cx,
34
34
sig. decl ,
35
35
cx. tcx . hir ( ) . body ( * body_id) ,
36
36
item. span ,
37
- item. owner_id . def_id ,
37
+ item. owner_id ,
38
38
item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ,
39
39
"this function could have a `#[must_use]` attribute" ,
40
40
) ;
@@ -49,7 +49,7 @@ pub(super) fn check_impl_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Imp
49
49
let attrs = cx. tcx . hir ( ) . attrs ( item. hir_id ( ) ) ;
50
50
let attr = cx. tcx . get_attr ( item. owner_id . to_def_id ( ) , sym:: must_use) ;
51
51
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) ;
53
53
} else if is_public
54
54
&& !is_proc_macro ( cx. sess ( ) , attrs)
55
55
&& 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
59
59
sig. decl ,
60
60
cx. tcx . hir ( ) . body ( * body_id) ,
61
61
item. span ,
62
- item. owner_id . def_id ,
62
+ item. owner_id ,
63
63
item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ,
64
64
"this method could have a `#[must_use]` attribute" ,
65
65
) ;
@@ -75,7 +75,7 @@ pub(super) fn check_trait_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Tr
75
75
let attrs = cx. tcx . hir ( ) . attrs ( item. hir_id ( ) ) ;
76
76
let attr = cx. tcx . get_attr ( item. owner_id . to_def_id ( ) , sym:: must_use) ;
77
77
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) ;
79
79
} else if let hir:: TraitFn :: Provided ( eid) = * eid {
80
80
let body = cx. tcx . hir ( ) . body ( eid) ;
81
81
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
84
84
sig. decl ,
85
85
body,
86
86
item. span ,
87
- item. owner_id . def_id ,
87
+ item. owner_id ,
88
88
item. span . with_hi ( sig. decl . output . span ( ) . hi ( ) ) ,
89
89
"this method could have a `#[must_use]` attribute" ,
90
90
) ;
@@ -96,7 +96,7 @@ pub(super) fn check_trait_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Tr
96
96
fn check_needless_must_use (
97
97
cx : & LateContext < ' _ > ,
98
98
decl : & hir:: FnDecl < ' _ > ,
99
- item_id : hir:: HirId ,
99
+ item_id : hir:: OwnerId ,
100
100
item_span : Span ,
101
101
fn_header_span : Span ,
102
102
attr : & Attribute ,
@@ -131,16 +131,16 @@ fn check_must_use_candidate<'tcx>(
131
131
decl : & ' tcx hir:: FnDecl < ' _ > ,
132
132
body : & ' tcx hir:: Body < ' _ > ,
133
133
item_span : Span ,
134
- item_id : LocalDefId ,
134
+ item_id : hir :: OwnerId ,
135
135
fn_span : Span ,
136
136
msg : & str ,
137
137
) {
138
138
if has_mutable_arg ( cx, body)
139
139
|| mutates_static ( cx, body)
140
140
|| in_external_macro ( cx. sess ( ) , item_span)
141
141
|| 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) )
144
144
{
145
145
return ;
146
146
}
0 commit comments