Skip to content

Commit c086676

Browse files
committed
Auto merge of rust-lang#85178 - cjgillot:local-crate, r=oli-obk
Remove CrateNum parameter for queries that only work on local crate The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea. Using `()` as query key in those cases avoids having to worry about the validity of the query key.
2 parents 9013bf2 + 44c1ef8 commit c086676

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

clippy_lints/src/derive.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_lint::{LateContext, LateLintPass};
1212
use rustc_middle::hir::map::Map;
1313
use rustc_middle::ty::{self, Ty};
1414
use rustc_session::{declare_lint_pass, declare_tool_lint};
15-
use rustc_span::{def_id::LOCAL_CRATE, source_map::Span};
15+
use rustc_span::{source_map::Span};
1616

1717
declare_clippy_lint! {
1818
/// **What it does:** Checks for deriving `Hash` but implementing `PartialEq`
@@ -312,7 +312,7 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &T
312312
if ty_subs.non_erasable_generics().next().is_some() {
313313
let has_copy_impl = cx
314314
.tcx
315-
.all_local_trait_impls(LOCAL_CRATE)
315+
.all_local_trait_impls(())
316316
.get(&copy_id)
317317
.map_or(false, |impls| {
318318
impls

clippy_lints/src/inherent_impl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use clippy_utils::diagnostics::span_lint_and_then;
44
use clippy_utils::in_macro;
55
use rustc_hir::def_id::DefIdMap;
6-
use rustc_hir::{def_id, Crate, Impl, Item, ItemKind};
6+
use rustc_hir::{Crate, Impl, Item, ItemKind};
77
use rustc_lint::{LateContext, LateLintPass};
88
use rustc_session::{declare_tool_lint, impl_lint_pass};
99
use rustc_span::Span;
@@ -68,7 +68,7 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
6868
fn check_crate_post(&mut self, cx: &LateContext<'tcx>, krate: &'tcx Crate<'_>) {
6969
if !krate.items.is_empty() {
7070
// Retrieve all inherent implementations from the crate, grouped by type
71-
for impls in cx.tcx.crate_inherent_impls(def_id::LOCAL_CRATE).inherent_impls.values() {
71+
for impls in cx.tcx.crate_inherent_impls(()).inherent_impls.values() {
7272
// Filter out implementations that have generic params (type or lifetime)
7373
let mut impl_spans = impls.iter().filter_map(|impl_def| self.impls.get(impl_def));
7474
if let Some(initial_span) = impl_spans.next() {

clippy_utils/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ use rustc_ast::ast::{self, Attribute, BorrowKind, LitKind};
6060
use rustc_data_structures::fx::FxHashMap;
6161
use rustc_hir as hir;
6262
use rustc_hir::def::{DefKind, Res};
63-
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
63+
use rustc_hir::def_id::DefId;
6464
use rustc_hir::intravisit::{self, walk_expr, ErasedMap, FnKind, NestedVisitorMap, Visitor};
6565
use rustc_hir::LangItem::{ResultErr, ResultOk};
6666
use rustc_hir::{
@@ -677,7 +677,7 @@ pub fn method_chain_args<'a>(expr: &'a Expr<'_>, methods: &[&str]) -> Option<Vec
677677
/// Returns `true` if the provided `def_id` is an entrypoint to a program.
678678
pub fn is_entrypoint_fn(cx: &LateContext<'_>, def_id: DefId) -> bool {
679679
cx.tcx
680-
.entry_fn(LOCAL_CRATE)
680+
.entry_fn(())
681681
.map_or(false, |(entry_fn_def_id, _)| def_id == entry_fn_def_id)
682682
}
683683

0 commit comments

Comments
 (0)