2019-10-03 17:53:20 -05:00
|
|
|
//@ edition:2018
|
2019-05-21 17:09:58 -05:00
|
|
|
//@ aux-build:test-macros.rs
|
2019-10-05 08:59:52 -05:00
|
|
|
//@ aux-build:derive-helper-shadowing.rs
|
2018-09-12 21:11:13 -05:00
|
|
|
|
2019-05-21 17:09:58 -05:00
|
|
|
#[macro_use]
|
|
|
|
extern crate test_macros;
|
2019-10-05 08:59:52 -05:00
|
|
|
#[macro_use]
|
|
|
|
extern crate derive_helper_shadowing;
|
2018-09-12 21:11:13 -05:00
|
|
|
|
2019-05-21 17:09:58 -05:00
|
|
|
use test_macros::empty_attr as empty_helper;
|
|
|
|
|
2019-10-05 08:59:52 -05:00
|
|
|
macro_rules! gen_helper_use {
|
|
|
|
() => {
|
|
|
|
#[empty_helper] //~ ERROR cannot find attribute `empty_helper` in this scope
|
|
|
|
struct W;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-21 17:09:58 -05:00
|
|
|
#[empty_helper] //~ ERROR `empty_helper` is ambiguous
|
2020-11-14 05:47:14 -06:00
|
|
|
//~| WARN derive helper attribute is used before it is introduced
|
|
|
|
//~| WARN this was previously accepted
|
2019-05-21 17:09:58 -05:00
|
|
|
#[derive(Empty)]
|
2018-12-30 11:07:43 -06:00
|
|
|
struct S {
|
2019-11-18 14:22:58 -06:00
|
|
|
#[empty_helper] // OK, no ambiguity, derive helpers have highest priority
|
2018-12-30 11:07:43 -06:00
|
|
|
field: [u8; {
|
2023-05-29 15:36:06 -05:00
|
|
|
use empty_helper; // OK, no ambiguity, derive helpers have highest priority
|
2018-09-12 21:11:13 -05:00
|
|
|
|
2019-11-18 14:22:58 -06:00
|
|
|
#[empty_helper] // OK, no ambiguity, derive helpers have highest priority
|
2018-12-30 11:07:43 -06:00
|
|
|
struct U;
|
|
|
|
|
|
|
|
mod inner {
|
2019-10-05 08:30:08 -05:00
|
|
|
// OK, no ambiguity, the non-helper attribute is not in scope here, only the helper.
|
2019-08-24 13:12:13 -05:00
|
|
|
#[empty_helper]
|
2018-12-30 11:07:43 -06:00
|
|
|
struct V;
|
2019-10-05 08:59:52 -05:00
|
|
|
|
|
|
|
gen_helper_use!();
|
|
|
|
|
|
|
|
#[derive(GenHelperUse)] //~ ERROR cannot find attribute `empty_helper` in this scope
|
|
|
|
struct Owo;
|
|
|
|
|
|
|
|
use empty_helper as renamed;
|
|
|
|
#[renamed] //~ ERROR cannot use a derive helper attribute through an import
|
|
|
|
struct Wow;
|
2018-12-30 11:07:43 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
0
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
|
2019-10-05 08:59:52 -05:00
|
|
|
// OK, no ambiguity, only the non-helper attribute is in scope.
|
|
|
|
#[empty_helper]
|
|
|
|
struct Z;
|
|
|
|
|
2018-12-30 11:07:43 -06:00
|
|
|
fn main() {
|
|
|
|
let s = S { field: [] };
|
|
|
|
}
|