Skip to content

Commit efca32e

Browse files
committed
Rename some OwnerId fields.
spastorino noticed some silly expressions like `item_id.def_id.def_id`. This commit renames several `def_id: OwnerId` fields as `owner_id`, so those expressions become `item_id.owner_id.def_id`. `item_id.owner_id.local_def_id` would be even clearer, but the use of `def_id` for values of type `LocalDefId` is *very* widespread, so I left that alone.
1 parent 26eeeee commit efca32e

Some content is hidden

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

46 files changed

+115
-115
lines changed

clippy_lints/src/copy_iterator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<'tcx> LateLintPass<'tcx> for CopyIterator {
4343
of_trait: Some(ref trait_ref),
4444
..
4545
}) = item.kind;
46-
let ty = cx.tcx.type_of(item.def_id);
46+
let ty = cx.tcx.type_of(item.owner_id);
4747
if is_copy(cx, ty);
4848
if let Some(trait_id) = trait_ref.trait_def_id();
4949
if cx.tcx.is_diagnostic_item(sym::Iterator, trait_id);

clippy_lints/src/default_union_representation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<'tcx> LateLintPass<'tcx> for DefaultUnionRepresentation {
6161
None,
6262
&format!(
6363
"consider annotating `{}` with `#[repr(C)]` to explicitly specify memory layout",
64-
cx.tcx.def_path_str(item.def_id.to_def_id())
64+
cx.tcx.def_path_str(item.owner_id.to_def_id())
6565
),
6666
);
6767
}

clippy_lints/src/dereference.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -715,47 +715,47 @@ fn walk_parents<'tcx>(
715715
},
716716
Node::Item(&Item {
717717
kind: ItemKind::Static(..) | ItemKind::Const(..),
718-
def_id,
718+
owner_id,
719719
span,
720720
..
721721
})
722722
| Node::TraitItem(&TraitItem {
723723
kind: TraitItemKind::Const(..),
724-
def_id,
724+
owner_id,
725725
span,
726726
..
727727
})
728728
| Node::ImplItem(&ImplItem {
729729
kind: ImplItemKind::Const(..),
730-
def_id,
730+
owner_id,
731731
span,
732732
..
733733
}) if span.ctxt() == ctxt => {
734-
let ty = cx.tcx.type_of(def_id.def_id);
734+
let ty = cx.tcx.type_of(owner_id.def_id);
735735
Some(ty_auto_deref_stability(cx, ty, precedence).position_for_result(cx))
736736
},
737737

738738
Node::Item(&Item {
739739
kind: ItemKind::Fn(..),
740-
def_id,
740+
owner_id,
741741
span,
742742
..
743743
})
744744
| Node::TraitItem(&TraitItem {
745745
kind: TraitItemKind::Fn(..),
746-
def_id,
746+
owner_id,
747747
span,
748748
..
749749
})
750750
| Node::ImplItem(&ImplItem {
751751
kind: ImplItemKind::Fn(..),
752-
def_id,
752+
owner_id,
753753
span,
754754
..
755755
}) if span.ctxt() == ctxt => {
756756
let output = cx
757757
.tcx
758-
.erase_late_bound_regions(cx.tcx.fn_sig(def_id.to_def_id()).output());
758+
.erase_late_bound_regions(cx.tcx.fn_sig(owner_id.to_def_id()).output());
759759
Some(ty_auto_deref_stability(cx, output, precedence).position_for_result(cx))
760760
},
761761

clippy_lints/src/derivable_impls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
7070
self_ty,
7171
..
7272
}) = item.kind;
73-
if !cx.tcx.has_attr(item.def_id.to_def_id(), sym::automatically_derived);
73+
if !cx.tcx.has_attr(item.owner_id.to_def_id(), sym::automatically_derived);
7474
if !item.span.from_expansion();
7575
if let Some(def_id) = trait_ref.trait_def_id();
7676
if cx.tcx.is_diagnostic_item(sym::Default, def_id);
7777
if let impl_item_hir = child.id.hir_id();
7878
if let Some(Node::ImplItem(impl_item)) = cx.tcx.hir().find(impl_item_hir);
7979
if let ImplItemKind::Fn(_, b) = &impl_item.kind;
8080
if let Body { value: func_expr, .. } = cx.tcx.hir().body(*b);
81-
if let Some(adt_def) = cx.tcx.type_of(item.def_id).ty_adt_def();
81+
if let Some(adt_def) = cx.tcx.type_of(item.owner_id).ty_adt_def();
8282
if let attrs = cx.tcx.hir().attrs(item.hir_id());
8383
if !attrs.iter().any(|attr| attr.doc_str().is_some());
8484
if let child_attrs = cx.tcx.hir().attrs(impl_item_hir);

clippy_lints/src/derive.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ impl<'tcx> LateLintPass<'tcx> for Derive {
210210
..
211211
}) = item.kind
212212
{
213-
let ty = cx.tcx.type_of(item.def_id);
214-
let is_automatically_derived = cx.tcx.has_attr(item.def_id.to_def_id(), sym::automatically_derived);
213+
let ty = cx.tcx.type_of(item.owner_id);
214+
let is_automatically_derived = cx.tcx.has_attr(item.owner_id.to_def_id(), sym::automatically_derived);
215215

216216
check_hash_peq(cx, item.span, trait_ref, ty, is_automatically_derived);
217217
check_ord_partial_ord(cx, item.span, trait_ref, ty, is_automatically_derived);

clippy_lints/src/doc.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,17 +257,17 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
257257
let headers = check_attrs(cx, &self.valid_idents, attrs);
258258
match item.kind {
259259
hir::ItemKind::Fn(ref sig, _, body_id) => {
260-
if !(is_entrypoint_fn(cx, item.def_id.to_def_id()) || in_external_macro(cx.tcx.sess, item.span)) {
260+
if !(is_entrypoint_fn(cx, item.owner_id.to_def_id()) || in_external_macro(cx.tcx.sess, item.span)) {
261261
let body = cx.tcx.hir().body(body_id);
262262
let mut fpu = FindPanicUnwrap {
263263
cx,
264-
typeck_results: cx.tcx.typeck(item.def_id.def_id),
264+
typeck_results: cx.tcx.typeck(item.owner_id.def_id),
265265
panic_span: None,
266266
};
267267
fpu.visit_expr(body.value);
268268
lint_for_missing_headers(
269269
cx,
270-
item.def_id.def_id,
270+
item.owner_id.def_id,
271271
item.span,
272272
sig,
273273
headers,
@@ -304,7 +304,7 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
304304
let headers = check_attrs(cx, &self.valid_idents, attrs);
305305
if let hir::TraitItemKind::Fn(ref sig, ..) = item.kind {
306306
if !in_external_macro(cx.tcx.sess, item.span) {
307-
lint_for_missing_headers(cx, item.def_id.def_id, item.span, sig, headers, None, None);
307+
lint_for_missing_headers(cx, item.owner_id.def_id, item.span, sig, headers, None, None);
308308
}
309309
}
310310
}
@@ -319,13 +319,13 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
319319
let body = cx.tcx.hir().body(body_id);
320320
let mut fpu = FindPanicUnwrap {
321321
cx,
322-
typeck_results: cx.tcx.typeck(item.def_id.def_id),
322+
typeck_results: cx.tcx.typeck(item.owner_id.def_id),
323323
panic_span: None,
324324
};
325325
fpu.visit_expr(body.value);
326326
lint_for_missing_headers(
327327
cx,
328-
item.def_id.def_id,
328+
item.owner_id.def_id,
329329
item.span,
330330
sig,
331331
headers,

clippy_lints/src/empty_enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<'tcx> LateLintPass<'tcx> for EmptyEnum {
4949
}
5050

5151
if let ItemKind::Enum(..) = item.kind {
52-
let ty = cx.tcx.type_of(item.def_id);
52+
let ty = cx.tcx.type_of(item.owner_id);
5353
let adt = ty.ty_adt_def().expect("already checked whether this is an enum");
5454
if adt.variants().is_empty() {
5555
span_lint_and_help(

clippy_lints/src/enum_variants.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ impl LateLintPass<'_> for EnumVariantNames {
265265
}
266266
// The `module_name_repetitions` lint should only trigger if the item has the module in its
267267
// name. Having the same name is accepted.
268-
if cx.tcx.visibility(item.def_id).is_public() && item_camel.len() > mod_camel.len() {
268+
if cx.tcx.visibility(item.owner_id).is_public() && item_camel.len() > mod_camel.len() {
269269
let matching = count_match_start(mod_camel, &item_camel);
270270
let rmatching = count_match_end(mod_camel, &item_camel);
271271
let nchars = mod_camel.chars().count();
@@ -296,7 +296,7 @@ impl LateLintPass<'_> for EnumVariantNames {
296296
}
297297
}
298298
if let ItemKind::Enum(ref def, _) = item.kind {
299-
if !(self.avoid_breaking_exported_api && cx.effective_visibilities.is_exported(item.def_id.def_id)) {
299+
if !(self.avoid_breaking_exported_api && cx.effective_visibilities.is_exported(item.owner_id.def_id)) {
300300
check_variant(cx, self.threshold, def, item_name, item.span);
301301
}
302302
}

clippy_lints/src/escape.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
8888
// be sure we have `self` parameter in this function
8989
if trait_item.kind == (AssocItemKind::Fn { has_self: true }) {
9090
trait_self_ty = Some(
91-
TraitRef::identity(cx.tcx, trait_item.id.def_id.to_def_id())
91+
TraitRef::identity(cx.tcx, trait_item.id.owner_id.to_def_id())
9292
.self_ty()
9393
.skip_binder(),
9494
);

clippy_lints/src/exhaustive_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl LateLintPass<'_> for ExhaustiveItems {
7373
fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
7474
if_chain! {
7575
if let ItemKind::Enum(..) | ItemKind::Struct(..) = item.kind;
76-
if cx.effective_visibilities.is_exported(item.def_id.def_id);
76+
if cx.effective_visibilities.is_exported(item.owner_id.def_id);
7777
let attrs = cx.tcx.hir().attrs(item.hir_id());
7878
if !attrs.iter().any(|a| a.has_name(sym::non_exhaustive));
7979
then {

0 commit comments

Comments
 (0)