diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2016-11-09 20:51:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-09 20:51:18 +0200 |
| commit | 5ebd7c50a0b9236af4389b00c97b00a59d9fa747 (patch) | |
| tree | 7ae11942986307fad0aa452b5ee4a9db0cb89e9f /src/librustc_metadata | |
| parent | 3d2ffa06ea4e04dbda99d7038e9afd04c040b472 (diff) | |
| parent | 134ef4f7933b87efdc04eac3e8d9a530d56d9cfe (diff) | |
| download | rust-5ebd7c50a0b9236af4389b00c97b00a59d9fa747.tar.gz rust-5ebd7c50a0b9236af4389b00c97b00a59d9fa747.zip | |
Rollup merge of #37614 - keeperofdakeys:proc_macro, r=jseyfried
macros 1.1: Allow proc_macro functions to declare attributes to be mark as used This PR allows proc macro functions to declare attribute names that should be marked as used when attached to the deriving item. There are a few questions for this PR. - Currently this uses a separate attribute named `#[proc_macro_attributes(..)]`, is this the best choice? - In order to make this work, the `check_attribute` function had to be modified to not error on attributes marked as used. This is a pretty large change in semantics, is there a better way to do this? - I've got a few clones where I don't know if I need them (like turning `item` into a `TokenStream`), can these be avoided? - Is switching to `MultiItemDecorator` the right thing here? Also fixes https://github.com/rust-lang/rust/issues/37563.
Diffstat (limited to 'src/librustc_metadata')
| -rw-r--r-- | src/librustc_metadata/creader.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 43c97cbe004..4385f024b41 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -624,8 +624,12 @@ impl<'a> CrateLoader<'a> { impl Registry for MyRegistrar { fn register_custom_derive(&mut self, trait_name: &str, - expand: fn(TokenStream) -> TokenStream) { - let derive = SyntaxExtension::CustomDerive(Box::new(CustomDerive::new(expand))); + expand: fn(TokenStream) -> TokenStream, + attributes: &[&'static str]) { + let attrs = attributes.iter().map(|s| InternedString::new(s)).collect(); + let derive = SyntaxExtension::CustomDerive( + Box::new(CustomDerive::new(expand, attrs)) + ); self.0.push((intern(trait_name), derive)); } } |
