-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Fully integrate derive helpers into name resolution #64694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c064630
a3126a5
8085228
8668c1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// force-host | ||
// no-prefer-dynamic | ||
|
||
#![crate_type = "proc-macro"] | ||
|
||
extern crate proc_macro; | ||
use proc_macro::*; | ||
|
||
#[proc_macro_derive(GenHelperUse)] | ||
pub fn derive_a(_: TokenStream) -> TokenStream { | ||
" | ||
#[empty_helper] | ||
struct Uwu; | ||
".parse().unwrap() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,54 @@ | ||
// edition:2018 | ||
// aux-build:test-macros.rs | ||
// aux-build:derive-helper-shadowing.rs | ||
|
||
#[macro_use] | ||
extern crate test_macros; | ||
#[macro_use] | ||
extern crate derive_helper_shadowing; | ||
|
||
use test_macros::empty_attr as empty_helper; | ||
|
||
macro_rules! gen_helper_use { | ||
() => { | ||
#[empty_helper] //~ ERROR cannot find attribute `empty_helper` in this scope | ||
struct W; | ||
} | ||
} | ||
|
||
#[empty_helper] //~ ERROR `empty_helper` is ambiguous | ||
#[derive(Empty)] | ||
struct S { | ||
// FIXME No ambiguity, attributes in non-macro positions are not resolved properly | ||
#[empty_helper] | ||
#[empty_helper] //~ ERROR `empty_helper` is ambiguous | ||
field: [u8; { | ||
// FIXME No ambiguity, derive helpers are not put into scope for non-attributes | ||
use empty_helper; | ||
use empty_helper; //~ ERROR `empty_helper` is ambiguous | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this were There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The attribute on |
||
|
||
// FIXME No ambiguity, derive helpers are not put into scope for inner items | ||
#[empty_helper] | ||
#[empty_helper] //~ ERROR `empty_helper` is ambiguous | ||
struct U; | ||
|
||
mod inner { | ||
// FIXME No ambiguity, attributes in non-macro positions are not resolved properly | ||
// OK, no ambiguity, the non-helper attribute is not in scope here, only the helper. | ||
#[empty_helper] | ||
struct V; | ||
|
||
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; | ||
} | ||
|
||
0 | ||
}] | ||
} | ||
|
||
// OK, no ambiguity, only the non-helper attribute is in scope. | ||
#[empty_helper] | ||
struct Z; | ||
|
||
fn main() { | ||
let s = S { field: [] }; | ||
} |
Uh oh!
There was an error while loading. Please reload this page.