Skip to content

Commit 650b7d9

Browse files
committed
Move methods from Map to TyCtxt, part 4.
Continuing the work from rust-lang#137350. Removes the unused methods: `expect_variant`, `expect_field`, `expect_foreign_item`. Every method gains a `hir_` prefix.
1 parent cb044d4 commit 650b7d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+67
-78
lines changed

clippy_lints/src/attrs/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ impl Attributes {
465465

466466
impl<'tcx> LateLintPass<'tcx> for Attributes {
467467
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
468-
let attrs = cx.tcx.hir().attrs(item.hir_id());
468+
let attrs = cx.tcx.hir_attrs(item.hir_id());
469469
if is_relevant_item(cx, item) {
470470
inline_always::check(cx, item.span, item.ident.name, attrs);
471471
}
@@ -474,13 +474,13 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
474474

475475
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
476476
if is_relevant_impl(cx, item) {
477-
inline_always::check(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id()));
477+
inline_always::check(cx, item.span, item.ident.name, cx.tcx.hir_attrs(item.hir_id()));
478478
}
479479
}
480480

481481
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'_>) {
482482
if is_relevant_trait(cx, item) {
483-
inline_always::check(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id()));
483+
inline_always::check(cx, item.span, item.ident.name, cx.tcx.hir_attrs(item.hir_id()));
484484
}
485485
}
486486
}

clippy_lints/src/default_union_representation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ fn is_zst<'tcx>(cx: &LateContext<'tcx>, field: &FieldDef, args: ty::GenericArgsR
9797
}
9898

9999
fn has_c_repr_attr(cx: &LateContext<'_>, hir_id: HirId) -> bool {
100-
let attrs = cx.tcx.hir().attrs(hir_id);
100+
let attrs = cx.tcx.hir_attrs(hir_id);
101101

102102
find_attr!(attrs, AttributeKind::Repr(r) if r.iter().any(|(x, _)| *x == ReprAttr::ReprC))
103103
}

clippy_lints/src/derivable_impls.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
197197
&& let ImplItemKind::Fn(_, b) = &impl_item.kind
198198
&& let Body { value: func_expr, .. } = cx.tcx.hir_body(*b)
199199
&& let &ty::Adt(adt_def, args) = cx.tcx.type_of(item.owner_id).instantiate_identity().kind()
200-
&& let attrs = cx.tcx.hir().attrs(item.hir_id())
200+
&& let attrs = cx.tcx.hir_attrs(item.hir_id())
201201
&& !attrs.iter().any(|attr| attr.doc_str().is_some())
202-
&& cx.tcx.hir().attrs(impl_item_hir).is_empty()
202+
&& cx.tcx.hir_attrs(impl_item_hir).is_empty()
203203
{
204204
if adt_def.is_struct() {
205205
check_struct(cx, item, self_ty, func_expr, adt_def, args, cx.tcx.typeck_body(*b));

clippy_lints/src/derive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ fn check_unsafe_derive_deserialize<'tcx>(
384384
.tcx
385385
.inherent_impls(def.did())
386386
.iter()
387-
.map(|imp_did| cx.tcx.hir().expect_item(imp_did.expect_local()))
387+
.map(|imp_did| cx.tcx.hir_expect_item(imp_did.expect_local()))
388388
.any(|imp| has_unsafe(cx, imp))
389389
{
390390
span_lint_hir_and_then(

clippy_lints/src/doc/missing_headers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub fn check(
2525
&& cx
2626
.tcx
2727
.hir_parent_iter(owner_id.into())
28-
.any(|(id, _node)| is_doc_hidden(cx.tcx.hir().attrs(id)))
28+
.any(|(id, _node)| is_doc_hidden(cx.tcx.hir_attrs(id)))
2929
{
3030
return;
3131
}

clippy_lints/src/escape.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ impl<'tcx> Delegate<'tcx> for EscapeDelegate<'_, 'tcx> {
163163

164164
fn mutate(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId) {
165165
if cmt.place.projections.is_empty() {
166-
let map = &self.cx.tcx.hir();
167166
if is_argument(self.cx.tcx, cmt.hir_id) {
168167
// Skip closure arguments
169168
let parent_id = self.cx.tcx.parent_hir_id(cmt.hir_id);
@@ -174,7 +173,7 @@ impl<'tcx> Delegate<'tcx> for EscapeDelegate<'_, 'tcx> {
174173
// skip if there is a `self` parameter binding to a type
175174
// that contains `Self` (i.e.: `self: Box<Self>`), see #4804
176175
if let Some(trait_self_ty) = self.trait_self_ty {
177-
if map.name(cmt.hir_id) == kw::SelfLower && cmt.place.ty().contains(trait_self_ty) {
176+
if self.cx.tcx.hir_name(cmt.hir_id) == kw::SelfLower && cmt.place.ty().contains(trait_self_ty) {
178177
return;
179178
}
180179
}

clippy_lints/src/exhaustive_items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl LateLintPass<'_> for ExhaustiveItems {
8484
_ => return,
8585
};
8686
if cx.effective_visibilities.is_exported(item.owner_id.def_id)
87-
&& let attrs = cx.tcx.hir().attrs(item.hir_id())
87+
&& let attrs = cx.tcx.hir_attrs(item.hir_id())
8888
&& !attrs.iter().any(|a| a.has_name(sym::non_exhaustive))
8989
&& fields.iter().all(|f| cx.tcx.visibility(f.def_id).is_public())
9090
{

clippy_lints/src/format_impl.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,8 @@ impl FormatImplExpr<'_, '_> {
209209
// Handle dereference of &self -> self that is equivalent (i.e. via *self in fmt() impl)
210210
// Since the argument to fmt is itself a reference: &self
211211
let reference = peel_ref_operators(self.cx, arg);
212-
let map = self.cx.tcx.hir();
213212
// Is the reference self?
214-
if path_to_local(reference).map(|x| map.name(x)) == Some(kw::SelfLower) {
213+
if path_to_local(reference).map(|x| self.cx.tcx.hir_name(x)) == Some(kw::SelfLower) {
215214
let FormatTraitNames { name, .. } = self.format_trait_impl;
216215
span_lint(
217216
self.cx,

clippy_lints/src/four_forward_slashes.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ impl<'tcx> LateLintPass<'tcx> for FourForwardSlashes {
4343
let sm = cx.sess().source_map();
4444
let mut span = cx
4545
.tcx
46-
.hir()
47-
.attrs(item.hir_id())
46+
.hir_attrs(item.hir_id())
4847
.iter()
4948
.filter(|i| i.is_doc_comment())
5049
.fold(item.span.shrink_to_lo(), |span, attr| span.to(attr.span()));

clippy_lints/src/functions/must_use.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use core::ops::ControlFlow;
2121
use super::{DOUBLE_MUST_USE, MUST_USE_CANDIDATE, MUST_USE_UNIT};
2222

2323
pub(super) fn check_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
24-
let attrs = cx.tcx.hir().attrs(item.hir_id());
24+
let attrs = cx.tcx.hir_attrs(item.hir_id());
2525
let attr = cx.tcx.get_attr(item.owner_id, sym::must_use);
2626
if let hir::ItemKind::Fn {
2727
ref sig,
@@ -51,7 +51,7 @@ pub(super) fn check_impl_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Imp
5151
if let hir::ImplItemKind::Fn(ref sig, ref body_id) = item.kind {
5252
let is_public = cx.effective_visibilities.is_exported(item.owner_id.def_id);
5353
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
54-
let attrs = cx.tcx.hir().attrs(item.hir_id());
54+
let attrs = cx.tcx.hir_attrs(item.hir_id());
5555
let attr = cx.tcx.get_attr(item.owner_id, sym::must_use);
5656
if let Some(attr) = attr {
5757
check_needless_must_use(cx, sig.decl, item.owner_id, item.span, fn_header_span, attr, attrs, sig);
@@ -74,7 +74,7 @@ pub(super) fn check_trait_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Tr
7474
let is_public = cx.effective_visibilities.is_exported(item.owner_id.def_id);
7575
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
7676

77-
let attrs = cx.tcx.hir().attrs(item.hir_id());
77+
let attrs = cx.tcx.hir_attrs(item.hir_id());
7878
let attr = cx.tcx.get_attr(item.owner_id, sym::must_use);
7979
if let Some(attr) = attr {
8080
check_needless_must_use(cx, sig.decl, item.owner_id, item.span, fn_header_span, attr, attrs, sig);

clippy_lints/src/inconsistent_struct_constructor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ fn suggestion<'tcx>(
182182
}
183183

184184
fn field_with_attrs_span(tcx: TyCtxt<'_>, field: &hir::ExprField<'_>) -> Span {
185-
if let Some(attr) = tcx.hir().attrs(field.hir_id).first() {
185+
if let Some(attr) = tcx.hir_attrs(field.hir_id).first() {
186186
field.span.with_lo(attr.span().lo())
187187
} else {
188188
field.span

clippy_lints/src/inline_fn_without_body.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ impl<'tcx> LateLintPass<'tcx> for InlineFnWithoutBody {
3434
if let TraitItemKind::Fn(_, TraitFn::Required(_)) = item.kind
3535
&& let Some(attr) = cx
3636
.tcx
37-
.hir()
38-
.attrs(item.hir_id())
37+
.hir_attrs(item.hir_id())
3938
.iter()
4039
.find(|a| a.has_name(sym::inline))
4140
{

clippy_lints/src/macro_use.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl LateLintPass<'_> for MacroUseImports {
9898
if cx.sess().opts.edition >= Edition::Edition2018
9999
&& let hir::ItemKind::Use(path, _kind) = &item.kind
100100
&& let hir_id = item.hir_id()
101-
&& let attrs = cx.tcx.hir().attrs(hir_id)
101+
&& let attrs = cx.tcx.hir_attrs(hir_id)
102102
&& let Some(mac_attr) = attrs.iter().find(|attr| attr.has_name(sym::macro_use))
103103
&& let Some(id) = path.res.iter().find_map(|res| match res {
104104
Res::Def(DefKind::Mod, id) => Some(id),

clippy_lints/src/manual_non_exhaustive.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustive {
8989
match item.kind {
9090
ItemKind::Enum(def, _) if def.variants.len() > 1 => {
9191
let iter = def.variants.iter().filter_map(|v| {
92-
(matches!(v.data, VariantData::Unit(_, _)) && is_doc_hidden(cx.tcx.hir().attrs(v.hir_id)))
92+
(matches!(v.data, VariantData::Unit(_, _)) && is_doc_hidden(cx.tcx.hir_attrs(v.hir_id)))
9393
.then_some((v.def_id, v.span))
9494
});
9595
if let Ok((id, span)) = iter.exactly_one()
96-
&& !attr::contains_name(cx.tcx.hir().attrs(item.hir_id()), sym::non_exhaustive)
96+
&& !attr::contains_name(cx.tcx.hir_attrs(item.hir_id()), sym::non_exhaustive)
9797
{
9898
self.potential_enums.push((item.owner_id.def_id, id, item.span, span));
9999
}
@@ -114,7 +114,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustive {
114114
"this seems like a manual implementation of the non-exhaustive pattern",
115115
|diag| {
116116
if let Some(non_exhaustive) =
117-
attr::find_by_name(cx.tcx.hir().attrs(item.hir_id()), sym::non_exhaustive)
117+
attr::find_by_name(cx.tcx.hir_attrs(item.hir_id()), sym::non_exhaustive)
118118
{
119119
diag.span_note(non_exhaustive.span(), "the struct is already non-exhaustive");
120120
} else {

clippy_lints/src/matches/match_like_matches.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub(super) fn check_match<'tcx>(
4242
cx,
4343
scrutinee,
4444
arms.iter()
45-
.map(|arm| (cx.tcx.hir().attrs(arm.hir_id), Some(arm.pat), arm.body, arm.guard)),
45+
.map(|arm| (cx.tcx.hir_attrs(arm.hir_id), Some(arm.pat), arm.body, arm.guard)),
4646
e,
4747
false,
4848
)

clippy_lints/src/matches/match_same_arms.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, arms: &'tcx [Arm<'_>]) {
7575
HirIdMapEntry::Occupied(entry) => return *entry.get() == b_id,
7676
}
7777
// the names technically don't have to match; this makes the lint more conservative
78-
&& cx.tcx.hir().name(a_id) == cx.tcx.hir().name(b_id)
78+
&& cx.tcx.hir_name(a_id) == cx.tcx.hir_name(b_id)
7979
&& cx.typeck_results().expr_ty(a) == cx.typeck_results().expr_ty(b)
8080
&& pat_contains_local(lhs.pat, a_id)
8181
&& pat_contains_local(rhs.pat, b_id)

clippy_lints/src/methods/is_empty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &'_ Expr<'_>, receiver: &Expr<'_
4141
fn is_under_cfg(cx: &LateContext<'_>, id: HirId) -> bool {
4242
cx.tcx
4343
.hir_parent_id_iter(id)
44-
.any(|id| cx.tcx.hir().attrs(id).iter().any(|attr| attr.has_name(sym::cfg)))
44+
.any(|id| cx.tcx.hir_attrs(id).iter().any(|attr| attr.has_name(sym::cfg)))
4545
}
4646

4747
/// Similar to [`clippy_utils::expr_or_init`], but does not go up the chain if the initialization

clippy_lints/src/methods/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4731,7 +4731,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
47314731
}
47324732
let name = impl_item.ident.name.as_str();
47334733
let parent = cx.tcx.hir_get_parent_item(impl_item.hir_id()).def_id;
4734-
let item = cx.tcx.hir().expect_item(parent);
4734+
let item = cx.tcx.hir_expect_item(parent);
47354735
let self_ty = cx.tcx.type_of(item.owner_id).instantiate_identity();
47364736

47374737
let implements_trait = matches!(item.kind, hir::ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }));

clippy_lints/src/missing_doc.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
182182
}
183183

184184
fn check_crate(&mut self, cx: &LateContext<'tcx>) {
185-
let attrs = cx.tcx.hir().attrs(hir::CRATE_HIR_ID);
185+
let attrs = cx.tcx.hir_attrs(hir::CRATE_HIR_ID);
186186
self.check_missing_docs_attrs(cx, CRATE_DEF_ID, attrs, cx.tcx.def_span(CRATE_DEF_ID), "the", "crate");
187187
}
188188

@@ -224,7 +224,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
224224

225225
let (article, desc) = cx.tcx.article_and_description(it.owner_id.to_def_id());
226226

227-
let attrs = cx.tcx.hir().attrs(it.hir_id());
227+
let attrs = cx.tcx.hir_attrs(it.hir_id());
228228
if !is_from_proc_macro(cx, it) {
229229
self.check_missing_docs_attrs(cx, it.owner_id.def_id, attrs, it.span, article, desc);
230230
}
@@ -234,7 +234,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
234234
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, trait_item: &'tcx hir::TraitItem<'_>) {
235235
let (article, desc) = cx.tcx.article_and_description(trait_item.owner_id.to_def_id());
236236

237-
let attrs = cx.tcx.hir().attrs(trait_item.hir_id());
237+
let attrs = cx.tcx.hir_attrs(trait_item.hir_id());
238238
if !is_from_proc_macro(cx, trait_item) {
239239
self.check_missing_docs_attrs(cx, trait_item.owner_id.def_id, attrs, trait_item.span, article, desc);
240240
}
@@ -252,7 +252,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
252252
}
253253

254254
let (article, desc) = cx.tcx.article_and_description(impl_item.owner_id.to_def_id());
255-
let attrs = cx.tcx.hir().attrs(impl_item.hir_id());
255+
let attrs = cx.tcx.hir_attrs(impl_item.hir_id());
256256
if !is_from_proc_macro(cx, impl_item) {
257257
self.check_missing_docs_attrs(cx, impl_item.owner_id.def_id, attrs, impl_item.span, article, desc);
258258
}
@@ -261,7 +261,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
261261

262262
fn check_field_def(&mut self, cx: &LateContext<'tcx>, sf: &'tcx hir::FieldDef<'_>) {
263263
if !sf.is_positional() {
264-
let attrs = cx.tcx.hir().attrs(sf.hir_id);
264+
let attrs = cx.tcx.hir_attrs(sf.hir_id);
265265
if !is_from_proc_macro(cx, sf) {
266266
self.check_missing_docs_attrs(cx, sf.def_id, attrs, sf.span, "a", "struct field");
267267
}
@@ -270,7 +270,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
270270
}
271271

272272
fn check_variant(&mut self, cx: &LateContext<'tcx>, v: &'tcx hir::Variant<'_>) {
273-
let attrs = cx.tcx.hir().attrs(v.hir_id);
273+
let attrs = cx.tcx.hir_attrs(v.hir_id);
274274
if !is_from_proc_macro(cx, v) {
275275
self.check_missing_docs_attrs(cx, v.def_id, attrs, v.span, "a", "variant");
276276
}

clippy_lints/src/missing_inline.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
9898
match it.kind {
9999
hir::ItemKind::Fn { .. } => {
100100
let desc = "a function";
101-
let attrs = cx.tcx.hir().attrs(it.hir_id());
101+
let attrs = cx.tcx.hir_attrs(it.hir_id());
102102
check_missing_inline_attrs(cx, attrs, it.span, desc);
103103
},
104104
hir::ItemKind::Trait(ref _is_auto, ref _unsafe, _generics, _bounds, trait_items) => {
@@ -114,7 +114,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
114114
// an impl is not provided
115115
let desc = "a default trait method";
116116
let item = cx.tcx.hir_trait_item(tit.id);
117-
let attrs = cx.tcx.hir().attrs(item.hir_id());
117+
let attrs = cx.tcx.hir_attrs(item.hir_id());
118118
check_missing_inline_attrs(cx, attrs, item.span, desc);
119119
}
120120
},
@@ -168,7 +168,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
168168
}
169169
}
170170

171-
let attrs = cx.tcx.hir().attrs(impl_item.hir_id());
171+
let attrs = cx.tcx.hir_attrs(impl_item.hir_id());
172172
check_missing_inline_attrs(cx, attrs, impl_item.span, desc);
173173
}
174174
}

clippy_lints/src/mixed_read_write_in_expression.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ impl<'tcx> Visitor<'tcx> for ReadVisitor<'_, 'tcx> {
334334
self.cx,
335335
MIXED_READ_WRITE_IN_EXPRESSION,
336336
expr.span,
337-
format!("unsequenced read of `{}`", self.cx.tcx.hir().name(self.var)),
337+
format!("unsequenced read of `{}`", self.cx.tcx.hir_name(self.var)),
338338
|diag| {
339339
diag.span_note(
340340
self.write_expr.span,

clippy_lints/src/needless_if.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl LateLintPass<'_> for NeedlessIf {
6565
stmt.span,
6666
"this `if` branch is empty",
6767
"you can remove it",
68-
if cond.can_have_side_effects() || !cx.tcx.hir().attrs(stmt.hir_id).is_empty() {
68+
if cond.can_have_side_effects() || !cx.tcx.hir_attrs(stmt.hir_id).is_empty() {
6969
// `{ foo }` or `{ foo } && bar` placed into a statement position would be
7070
// interpreted as a block statement, force it to be an expression
7171
if cond_snippet.starts_with('{') {

clippy_lints/src/needless_late_init.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ fn check<'tcx>(
261261
binding_id: HirId,
262262
) -> Option<()> {
263263
let usage = first_usage(cx, binding_id, local_stmt.hir_id, block)?;
264-
let binding_name = cx.tcx.hir().opt_name(binding_id)?;
264+
let binding_name = cx.tcx.hir_opt_name(binding_id)?;
265265
let let_snippet = local_snippet_without_semicolon(cx, local)?;
266266

267267
match usage.expr.kind {

clippy_lints/src/needless_pass_by_ref_mut.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> {
147147
// We don't check unsafe functions.
148148
return;
149149
}
150-
let attrs = cx.tcx.hir().attrs(hir_id);
150+
let attrs = cx.tcx.hir_attrs(hir_id);
151151
if header.abi != ExternAbi::Rust || requires_exact_signature(attrs) {
152152
return;
153153
}

clippy_lints/src/needless_pass_by_value.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
8888

8989
match kind {
9090
FnKind::ItemFn(.., header) => {
91-
let attrs = cx.tcx.hir().attrs(hir_id);
91+
let attrs = cx.tcx.hir_attrs(hir_id);
9292
if header.abi != ExternAbi::Rust || requires_exact_signature(attrs) {
9393
return;
9494
}

clippy_lints/src/no_mangle_with_rust_abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl<'tcx> LateLintPass<'tcx> for NoMangleWithRustAbi {
4040
if let ItemKind::Fn { sig: fn_sig, .. } = &item.kind
4141
&& !item.span.from_expansion()
4242
{
43-
let attrs = cx.tcx.hir().attrs(item.hir_id());
43+
let attrs = cx.tcx.hir_attrs(item.hir_id());
4444
let mut app = Applicability::MaybeIncorrect;
4545
let fn_snippet = snippet_with_applicability(cx, fn_sig.span.with_hi(item.ident.span.lo()), "..", &mut app);
4646
for attr in attrs {

clippy_lints/src/non_copy_const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst<'tcx> {
351351
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx ImplItem<'_>) {
352352
if let ImplItemKind::Const(_, body_id) = &impl_item.kind {
353353
let item_def_id = cx.tcx.hir_get_parent_item(impl_item.hir_id()).def_id;
354-
let item = cx.tcx.hir().expect_item(item_def_id);
354+
let item = cx.tcx.hir_expect_item(item_def_id);
355355

356356
match &item.kind {
357357
ItemKind::Impl(Impl {

clippy_lints/src/operators/op_ref.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ fn in_impl<'tcx>(
181181
) -> Option<(&'tcx rustc_hir::Ty<'tcx>, &'tcx rustc_hir::Ty<'tcx>)> {
182182
if let Some(block) = get_enclosing_block(cx, e.hir_id)
183183
&& let Some(impl_def_id) = cx.tcx.impl_of_method(block.hir_id.owner.to_def_id())
184-
&& let item = cx.tcx.hir().expect_item(impl_def_id.expect_local())
184+
&& let item = cx.tcx.hir_expect_item(impl_def_id.expect_local())
185185
&& let ItemKind::Impl(item) = &item.kind
186186
&& let Some(of_trait) = &item.of_trait
187187
&& let Some(seg) = of_trait.path.segments.last()
@@ -200,7 +200,7 @@ fn in_impl<'tcx>(
200200
fn are_equal(cx: &LateContext<'_>, middle_ty: Ty<'_>, hir_ty: &rustc_hir::Ty<'_>) -> bool {
201201
if let ty::Adt(adt_def, _) = middle_ty.kind()
202202
&& let Some(local_did) = adt_def.did().as_local()
203-
&& let item = cx.tcx.hir().expect_item(local_did)
203+
&& let item = cx.tcx.hir_expect_item(local_did)
204204
&& let middle_ty_id = item.owner_id.to_def_id()
205205
&& let TyKind::Path(QPath::Resolved(_, path)) = hir_ty.kind
206206
&& let Res::Def(_, hir_ty_id) = path.res

0 commit comments

Comments
 (0)