Skip to content

Commit

Permalink
Rollup merge of rust-lang#96142 - cjgillot:no-crate-def-index, r=petr…
Browse files Browse the repository at this point in the history
…ochenkov

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.
  • Loading branch information
Dylan-DPC authored Apr 19, 2022
2 parents cb1924a + 18a4411 commit 60bb2a7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions clippy_lints/src/missing_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use clippy_utils::diagnostics::span_lint;
use rustc_ast::ast;
use rustc_hir as hir;
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_middle::ty;
use rustc_middle::ty::{self, DefIdTree};
use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_span::def_id::CRATE_DEF_ID;
use rustc_span::source_map::Span;
Expand Down Expand Up @@ -114,8 +114,8 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
hir::ItemKind::Fn(..) => {
// ignore main()
if it.ident.name == sym::main {
let def_key = cx.tcx.hir().def_key(it.def_id);
if def_key.parent == Some(hir::def_id::CRATE_DEF_INDEX) {
let at_root = cx.tcx.local_parent(it.def_id) == Some(CRATE_DEF_ID);
if at_root {
return;
}
}
Expand Down

0 comments on commit 60bb2a7

Please sign in to comment.