Skip to content

Commit 01e0aea

Browse files
committed
Skip disallowed_* checking for current crate
1 parent fcd1145 commit 01e0aea

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

clippy_config/src/types.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use clippy_utils::paths::{PathNS, find_crates, lookup_path};
22
use rustc_data_structures::fx::FxHashMap;
3+
use rustc_hir::def_id::LOCAL_CRATE;
34
use rustc_errors::{Applicability, Diag};
45
use rustc_hir::PrimTy;
56
use rustc_hir::def::DefKind;
@@ -145,9 +146,14 @@ pub fn create_disallowed_map<const REPLACEMENT_ALLOWED: bool>(
145146
let mut def_ids: DefIdMap<(&'static str, &'static DisallowedPath<REPLACEMENT_ALLOWED>)> = DefIdMap::default();
146147
let mut prim_tys: FxHashMap<PrimTy, (&'static str, &'static DisallowedPath<REPLACEMENT_ALLOWED>)> =
147148
FxHashMap::default();
149+
let local_crate = tcx.crate_name(LOCAL_CRATE);
148150
for disallowed_path in disallowed_paths {
149151
let path = disallowed_path.path();
150152
let sym_path: Vec<Symbol> = path.split("::").map(Symbol::intern).collect();
153+
// Skip checking disallowed type for current crate.
154+
if sym_path.first() == Some(&local_crate) {
155+
continue;
156+
}
151157
let mut resolutions = lookup_path(tcx, ns, &sym_path);
152158
resolutions.retain(|&def_id| def_kind_predicate(tcx.def_kind(def_id)));
153159

tests/ui-cargo/disallowed_types/fail_local_crate/Cargo.stderr

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
warning: expected a type, found an import
2-
--> $DIR/tests/ui-cargo/disallowed_types/fail_local_crate/clippy.toml:2:5
3-
|
4-
2 | { path = "foo::Fooo", reason = "Noooooooooo" },
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6-
|
7-
= help: add `allow-invalid = true` to the entry to suppress this warning
8-
91
error: use of a disallowed type `foo::Fooo`
102
--> src/lib.rs:1:1
113
|

tests/ui-cargo/disallowed_types/fail_local_crate/foo/Cargo.stderr

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)