-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #5279 - DevinR528:macro-use-sugg, r=flip1995
Macro use sugg changelog: Add auto applicable suggstion to macro_use_imports fixes #5275 <s>Where exactly is the `wildcard_imports_helper` I haven't been able to import anything ex. `use lazy_static;` or something like for that I get version/compiler conflicts?</s> Found it. Should we also check for `#[macro_use] extern crate`, although this is still depended on for stuff like `rustc_private`?
- Loading branch information
Showing
6 changed files
with
360 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
extern crate macro_rules; | ||
|
||
// STMT | ||
#[macro_export] | ||
macro_rules! pub_macro { | ||
() => { | ||
let _ = "hello Mr. Vonnegut"; | ||
}; | ||
} | ||
|
||
pub mod inner { | ||
pub use super::*; | ||
|
||
// RE-EXPORT | ||
// this will stick in `inner` module | ||
pub use macro_rules::foofoo; | ||
pub use macro_rules::try_err; | ||
|
||
pub mod nested { | ||
pub use macro_rules::string_add; | ||
} | ||
|
||
// ITEM | ||
#[macro_export] | ||
macro_rules! inner_mod_macro { | ||
() => { | ||
#[allow(dead_code)] | ||
pub struct Tardis; | ||
}; | ||
} | ||
} | ||
|
||
// EXPR | ||
#[macro_export] | ||
macro_rules! function_macro { | ||
() => { | ||
if true { | ||
} else { | ||
} | ||
}; | ||
} | ||
|
||
// TYPE | ||
#[macro_export] | ||
macro_rules! ty_macro { | ||
() => { | ||
Vec<u8> | ||
}; | ||
} | ||
|
||
mod extern_exports { | ||
pub(super) mod private_inner { | ||
#[macro_export] | ||
macro_rules! pub_in_private_macro { | ||
($name:ident) => { | ||
let $name = String::from("secrets and lies"); | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// compile-flags: --edition 2018 | ||
// aux-build:macro_rules.rs | ||
// aux-build:macro_use_helper.rs | ||
// run-rustfix | ||
// ignore-32bit | ||
|
||
#![allow(unused_imports, unreachable_code, unused_variables, dead_code)] | ||
#![allow(clippy::single_component_path_imports)] | ||
#![warn(clippy::macro_use_imports)] | ||
|
||
#[macro_use] | ||
extern crate macro_use_helper as mac; | ||
|
||
#[macro_use] | ||
extern crate clippy_mini_macro_test as mini_mac; | ||
|
||
mod a { | ||
use mac::{pub_macro, inner_mod_macro, function_macro, ty_macro, pub_in_private_macro}; | ||
use mac; | ||
use mini_mac::ClippyMiniMacroTest; | ||
use mini_mac; | ||
use mac::{inner::foofoo, inner::try_err}; | ||
use mac::inner; | ||
use mac::inner::nested::string_add; | ||
use mac::inner::nested; | ||
|
||
#[derive(ClippyMiniMacroTest)] | ||
struct Test; | ||
|
||
fn test() { | ||
pub_macro!(); | ||
inner_mod_macro!(); | ||
pub_in_private_macro!(_var); | ||
function_macro!(); | ||
let v: ty_macro!() = Vec::default(); | ||
|
||
inner::try_err!(); | ||
inner::foofoo!(); | ||
nested::string_add!(); | ||
} | ||
} | ||
|
||
fn main() {} |
Oops, something went wrong.