Do not lint for wildcard_imports in external macro
This commit is contained in:
parent
264bc97b26
commit
6c7fa3b2cb
4 changed files with 26 additions and 4 deletions
|
|
@ -118,7 +118,7 @@ impl_lint_pass!(WildcardImports => [ENUM_GLOB_USE, WILDCARD_IMPORTS]);
|
|||
|
||||
impl LateLintPass<'_> for WildcardImports {
|
||||
fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
|
||||
if cx.sess().is_test_crate() {
|
||||
if cx.sess().is_test_crate() || item.span.in_external_macro(cx.sess().source_map()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
//@aux-build:../../ui/auxiliary/proc_macros.rs
|
||||
#![warn(clippy::wildcard_imports)]
|
||||
|
||||
mod prelude {
|
||||
|
|
@ -13,6 +14,10 @@ mod my_crate {
|
|||
pub mod utils {
|
||||
pub fn my_util_fn() {}
|
||||
}
|
||||
|
||||
pub mod utils2 {
|
||||
pub const SOME_CONST: u32 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
pub use utils::{BAR, print};
|
||||
|
|
@ -22,6 +27,12 @@ use my_crate::utils::my_util_fn;
|
|||
use prelude::FOO;
|
||||
//~^ ERROR: usage of wildcard import
|
||||
|
||||
proc_macros::external! {
|
||||
use my_crate::utils2::*;
|
||||
|
||||
static SOME_STATIC: u32 = SOME_CONST;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _ = FOO;
|
||||
let _ = BAR;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
//@aux-build:../../ui/auxiliary/proc_macros.rs
|
||||
#![warn(clippy::wildcard_imports)]
|
||||
|
||||
mod prelude {
|
||||
|
|
@ -13,6 +14,10 @@ mod my_crate {
|
|||
pub mod utils {
|
||||
pub fn my_util_fn() {}
|
||||
}
|
||||
|
||||
pub mod utils2 {
|
||||
pub const SOME_CONST: u32 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
pub use utils::*;
|
||||
|
|
@ -22,6 +27,12 @@ use my_crate::utils::*;
|
|||
use prelude::*;
|
||||
//~^ ERROR: usage of wildcard import
|
||||
|
||||
proc_macros::external! {
|
||||
use my_crate::utils2::*;
|
||||
|
||||
static SOME_STATIC: u32 = SOME_CONST;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _ = FOO;
|
||||
let _ = BAR;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: usage of wildcard import
|
||||
--> tests/ui-toml/wildcard_imports/wildcard_imports.rs:18:9
|
||||
--> tests/ui-toml/wildcard_imports/wildcard_imports.rs:23:9
|
||||
|
|
||||
LL | pub use utils::*;
|
||||
| ^^^^^^^^ help: try: `utils::{BAR, print}`
|
||||
|
|
@ -8,13 +8,13 @@ LL | pub use utils::*;
|
|||
= help: to override `-D warnings` add `#[allow(clippy::wildcard_imports)]`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> tests/ui-toml/wildcard_imports/wildcard_imports.rs:20:5
|
||||
--> tests/ui-toml/wildcard_imports/wildcard_imports.rs:25:5
|
||||
|
|
||||
LL | use my_crate::utils::*;
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try: `my_crate::utils::my_util_fn`
|
||||
|
||||
error: usage of wildcard import
|
||||
--> tests/ui-toml/wildcard_imports/wildcard_imports.rs:22:5
|
||||
--> tests/ui-toml/wildcard_imports/wildcard_imports.rs:27:5
|
||||
|
|
||||
LL | use prelude::*;
|
||||
| ^^^^^^^^^^ help: try: `prelude::FOO`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue