]> git.lizzy.rs Git - rust.git/blob - src/test/ui/hygiene/auxiliary/unhygienic_example.rs
Merge commit '0eff589afc83e21a03a168497bbab6b4dfbb4ef6' into clippyup
[rust.git] / src / test / ui / hygiene / auxiliary / unhygienic_example.rs
1 #![crate_type = "lib"]
2
3 extern crate my_crate;
4
5 pub fn g() {} // (a)
6
7 #[macro_export]
8 macro_rules! unhygienic_macro {
9     () => {
10         // (1) unhygienic: depends on `my_crate` in the crate root at the invocation site.
11         ::my_crate::f();
12
13         // (2) unhygienic: defines `f` at the invocation site (in addition to the above point).
14         use my_crate::f;
15         f();
16
17         g(); // (3) unhygienic: `g` needs to be in scope at use site.
18
19         $crate::g(); // (4) hygienic: this always resolves to (a)
20     }
21 }
22
23 #[allow(unused)]
24 fn test_unhygienic() {
25     unhygienic_macro!();
26     f(); // `f` was defined at the use site
27 }