Skip to content

Commit 21aeb21

Browse files
committed
1 parent c036c4f commit 21aeb21

9 files changed

+14
-14
lines changed

clippy_lints/src/functions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ fn is_mutable_pat(cx: &LateContext<'_, '_>, pat: &hir::Pat<'_>, tys: &mut FxHash
486486
if let hir::PatKind::Wild = pat.kind {
487487
return false; // ignore `_` patterns
488488
}
489-
let def_id = pat.hir_id.owner_def_id();
489+
let def_id = pat.hir_id.owner.to_def_id();
490490
if cx.tcx.has_typeck_tables(def_id) {
491491
is_mutable_ty(cx, &cx.tcx.typeck_tables_of(def_id).pat_ty(pat), pat.span, tys)
492492
} else {
@@ -601,7 +601,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for StaticMutVisitor<'a, 'tcx> {
601601
Call(_, args) | MethodCall(_, _, args) => {
602602
let mut tys = FxHashSet::default();
603603
for arg in args {
604-
let def_id = arg.hir_id.owner_def_id();
604+
let def_id = arg.hir_id.owner.to_def_id();
605605
if self.cx.tcx.has_typeck_tables(def_id)
606606
&& is_mutable_ty(
607607
self.cx,

clippy_lints/src/inherent_impl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MultipleInherentImpl {
5959
// but filter out implementations that have generic params (type or lifetime)
6060
// or are derived from a macro
6161
if !in_macro(item.span) && generics.params.is_empty() {
62-
self.impls.insert(item.hir_id.owner_def_id(), item.span);
62+
self.impls.insert(item.hir_id.owner.to_def_id(), item.span);
6363
}
6464
}
6565
}
@@ -69,7 +69,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MultipleInherentImpl {
6969
// Retrieve all inherent implementations from the crate, grouped by type
7070
for impls in cx
7171
.tcx
72-
.crate_inherent_impls(item.hir_id.owner_def_id().krate)
72+
.crate_inherent_impls(item.hir_id.owner.to_def_id().krate)
7373
.inherent_impls
7474
.values()
7575
{

clippy_lints/src/loops.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1679,7 +1679,7 @@ fn check_for_mutation(
16791679
span_low: None,
16801680
span_high: None,
16811681
};
1682-
let def_id = def_id::DefId::local(body.hir_id.owner);
1682+
let def_id = body.hir_id.owner.to_def_id();
16831683
cx.tcx.infer_ctxt().enter(|infcx| {
16841684
ExprUseVisitor::new(&mut delegate, &infcx, def_id, cx.param_env, cx.tables).walk_expr(body);
16851685
});

clippy_lints/src/missing_doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
135135
hir::ItemKind::Fn(..) => {
136136
// ignore main()
137137
if it.ident.name == sym!(main) {
138-
let def_id = cx.tcx.hir().local_def_id(it.hir_id);
138+
let def_id = it.hir_id.owner;
139139
let def_key = cx.tcx.hir().def_key(def_id);
140140
if def_key.parent == Some(hir::def_id::CRATE_DEF_INDEX) {
141141
return;

clippy_lints/src/new_without_default.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
149149
if_chain! {
150150
if let Some(ref impling_types) = self.impling_types;
151151
if let Some(self_def) = cx.tcx.type_of(self_did).ty_adt_def();
152-
if self_def.did.is_local();
152+
if let Some(self_def_id) = self_def.did.as_local();
153153
then {
154-
let self_id = cx.tcx.hir().local_def_id_to_hir_id(self_def.did.to_local());
154+
let self_id = cx.tcx.hir().local_def_id_to_hir_id(self_def_id);
155155
if impling_types.contains(&self_id) {
156156
return;
157157
}

clippy_lints/src/swap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ fn check_manual_swap(cx: &LateContext<'_, '_>, block: &Block<'_>) {
9999
then {
100100
if let ExprKind::Field(ref lhs1, _) = lhs1.kind {
101101
if let ExprKind::Field(ref lhs2, _) = lhs2.kind {
102-
if lhs1.hir_id.owner_def_id() == lhs2.hir_id.owner_def_id() {
102+
if lhs1.hir_id.owner == lhs2.hir_id.owner {
103103
return;
104104
}
105105
}

clippy_lints/src/utils/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ pub fn qpath_res(cx: &LateContext<'_, '_>, qpath: &hir::QPath<'_>, id: hir::HirI
297297
match qpath {
298298
hir::QPath::Resolved(_, path) => path.res,
299299
hir::QPath::TypeRelative(..) => {
300-
if cx.tcx.has_typeck_tables(id.owner_def_id()) {
301-
cx.tcx.typeck_tables_of(id.owner_def_id()).qpath_res(qpath, id)
300+
if cx.tcx.has_typeck_tables(id.owner.to_def_id()) {
301+
cx.tcx.typeck_tables_of(id.owner.to_def_id()).qpath_res(qpath, id)
302302
} else {
303303
Res::Err
304304
}

clippy_lints/src/utils/usage.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_ast::ast;
55
use rustc_data_structures::fx::FxHashSet;
66
use rustc_hir::def::Res;
77
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
8-
use rustc_hir::{def_id, Expr, HirId, Path};
8+
use rustc_hir::{Expr, HirId, Path};
99
use rustc_infer::infer::TyCtxtInferExt;
1010
use rustc_lint::LateContext;
1111
use rustc_span::symbol::Ident;
@@ -17,7 +17,7 @@ pub fn mutated_variables<'a, 'tcx>(expr: &'tcx Expr<'_>, cx: &'a LateContext<'a,
1717
used_mutably: FxHashSet::default(),
1818
skip: false,
1919
};
20-
let def_id = def_id::DefId::local(expr.hir_id.owner);
20+
let def_id = expr.hir_id.owner.to_def_id();
2121
cx.tcx.infer_ctxt().enter(|infcx| {
2222
ExprUseVisitor::new(&mut delegate, &infcx, def_id, cx.param_env, cx.tables).walk_expr(expr);
2323
});

clippy_lints/src/wildcard_imports.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl LateLintPass<'_, '_> for WildcardImports {
8585
if let ItemKind::Use(use_path, UseKind::Glob) = &item.kind;
8686
// don't lint prelude glob imports
8787
if !use_path.segments.iter().last().map_or(false, |ps| ps.ident.as_str() == "prelude");
88-
let used_imports = cx.tcx.names_imported_by_glob_use(item.hir_id.owner_def_id());
88+
let used_imports = cx.tcx.names_imported_by_glob_use(item.hir_id.owner.to_def_id());
8989
if !used_imports.is_empty(); // Already handled by `unused_imports`
9090
then {
9191
let mut applicability = Applicability::MachineApplicable;

0 commit comments

Comments
 (0)