Skip to content

Commit 60bb2a7

Browse files
authored
Rollup merge of rust-lang#96142 - cjgillot:no-crate-def-index, r=petrochenkov
Stop using CRATE_DEF_INDEX outside of metadata encoding. `CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want. We should not manipulate raw `DefIndex` outside of metadata encoding.
2 parents cb1924a + 18a4411 commit 60bb2a7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

clippy_lints/src/missing_doc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use clippy_utils::diagnostics::span_lint;
1010
use rustc_ast::ast;
1111
use rustc_hir as hir;
1212
use rustc_lint::{LateContext, LateLintPass, LintContext};
13-
use rustc_middle::ty;
13+
use rustc_middle::ty::{self, DefIdTree};
1414
use rustc_session::{declare_tool_lint, impl_lint_pass};
1515
use rustc_span::def_id::CRATE_DEF_ID;
1616
use rustc_span::source_map::Span;
@@ -114,8 +114,8 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
114114
hir::ItemKind::Fn(..) => {
115115
// ignore main()
116116
if it.ident.name == sym::main {
117-
let def_key = cx.tcx.hir().def_key(it.def_id);
118-
if def_key.parent == Some(hir::def_id::CRATE_DEF_INDEX) {
117+
let at_root = cx.tcx.local_parent(it.def_id) == Some(CRATE_DEF_ID);
118+
if at_root {
119119
return;
120120
}
121121
}

0 commit comments

Comments
 (0)