]> git.proxmox.com Git - rustc.git/blame - src/test/ui/proc-macro/derive-helper-shadowing.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / test / ui / proc-macro / derive-helper-shadowing.rs
CommitLineData
60c5eb7d 1// edition:2018
dc9dc135 2// aux-build:test-macros.rs
60c5eb7d 3// aux-build:derive-helper-shadowing.rs
b7449926 4
dc9dc135
XL
5#[macro_use]
6extern crate test_macros;
60c5eb7d
XL
7#[macro_use]
8extern crate derive_helper_shadowing;
b7449926 9
dc9dc135
XL
10use test_macros::empty_attr as empty_helper;
11
60c5eb7d
XL
12macro_rules! gen_helper_use {
13 () => {
14 #[empty_helper] //~ ERROR cannot find attribute `empty_helper` in this scope
15 struct W;
16 }
17}
18
dc9dc135
XL
19#[empty_helper] //~ ERROR `empty_helper` is ambiguous
20#[derive(Empty)]
69743fb6 21struct S {
60c5eb7d 22 #[empty_helper] // OK, no ambiguity, derive helpers have highest priority
69743fb6 23 field: [u8; {
60c5eb7d 24 use empty_helper; //~ ERROR `empty_helper` is ambiguous
b7449926 25
60c5eb7d 26 #[empty_helper] // OK, no ambiguity, derive helpers have highest priority
69743fb6
XL
27 struct U;
28
0731742a 29 mod inner {
60c5eb7d 30 // OK, no ambiguity, the non-helper attribute is not in scope here, only the helper.
e1599b0c 31 #[empty_helper]
0731742a 32 struct V;
60c5eb7d
XL
33
34 gen_helper_use!();
35
36 #[derive(GenHelperUse)] //~ ERROR cannot find attribute `empty_helper` in this scope
37 struct Owo;
38
39 use empty_helper as renamed;
40 #[renamed] //~ ERROR cannot use a derive helper attribute through an import
41 struct Wow;
0731742a
XL
42 }
43
69743fb6
XL
44 0
45 }]
46}
47
60c5eb7d
XL
48// OK, no ambiguity, only the non-helper attribute is in scope.
49#[empty_helper]
50struct Z;
51
69743fb6
XL
52fn main() {
53 let s = S { field: [] };
54}