File tree Expand file tree Collapse file tree 3 files changed +6
-16
lines changed
tests/ui-cargo/disallowed_types/fail_local_crate Expand file tree Collapse file tree 3 files changed +6
-16
lines changed Original file line number Diff line number Diff line change 1
1
use clippy_utils:: paths:: { PathNS , find_crates, lookup_path} ;
2
2
use rustc_data_structures:: fx:: FxHashMap ;
3
+ use rustc_hir:: def_id:: LOCAL_CRATE ;
3
4
use rustc_errors:: { Applicability , Diag } ;
4
5
use rustc_hir:: PrimTy ;
5
6
use rustc_hir:: def:: DefKind ;
@@ -145,9 +146,14 @@ pub fn create_disallowed_map<const REPLACEMENT_ALLOWED: bool>(
145
146
let mut def_ids: DefIdMap < ( & ' static str , & ' static DisallowedPath < REPLACEMENT_ALLOWED > ) > = DefIdMap :: default ( ) ;
146
147
let mut prim_tys: FxHashMap < PrimTy , ( & ' static str , & ' static DisallowedPath < REPLACEMENT_ALLOWED > ) > =
147
148
FxHashMap :: default ( ) ;
149
+ let local_crate = tcx. crate_name ( LOCAL_CRATE ) ;
148
150
for disallowed_path in disallowed_paths {
149
151
let path = disallowed_path. path ( ) ;
150
152
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
+ }
151
157
let mut resolutions = lookup_path ( tcx, ns, & sym_path) ;
152
158
resolutions. retain ( |& def_id| def_kind_predicate ( tcx. def_kind ( def_id) ) ) ;
153
159
Original file line number Diff line number Diff line change 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
-
9
1
error: use of a disallowed type `foo::Fooo`
10
2
--> src/lib.rs:1:1
11
3
|
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments