diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-04-19 14:43:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-19 14:43:21 +0200 |
| commit | 60bb2a710ee12d2da604c694400bafad4272a997 (patch) | |
| tree | c173c2a2507494d98b5ebb33198affa2a151e92c | |
| parent | cb1924a42a27937760ad4c24daa6745c89700f92 (diff) | |
| parent | 18a44116b866ebf5171b16d917c09dfd44a8fd36 (diff) | |
| download | rust-60bb2a710ee12d2da604c694400bafad4272a997.tar.gz rust-60bb2a710ee12d2da604c694400bafad4272a997.zip | |
Rollup merge of #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.
| -rw-r--r-- | clippy_lints/src/missing_doc.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index fc0483a929a..5816a95dceb 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -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; @@ -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; } } |
