diff options
| author | kennytm <kennytm@gmail.com> | 2018-07-21 02:59:09 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2018-07-21 04:08:10 +0800 |
| commit | 863ed13c6c079e835fbd4aa6706cc68356229ea8 (patch) | |
| tree | c756a6ce17335593d503569d9ce18625828dd9cf /src/test | |
| parent | 63da8122fb93838dc3a20c0ba94665658df55166 (diff) | |
| parent | f2f7ab9da835f5fd66722f2efec9285ea72ad0f4 (diff) | |
| download | rust-863ed13c6c079e835fbd4aa6706cc68356229ea8.tar.gz rust-863ed13c6c079e835fbd4aa6706cc68356229ea8.zip | |
Rollup merge of #52539 - alexcrichton:two-attrs, r=petrochenkov
rustc: Fix two custom attributes with custom derive This commit fixes an issue where multiple custom attributes could not be fed into a custom derive in some situations with the `use_extern_macros` feature enabled. The problem was that the macro expander didn't consider that it was making progress when we were deducing that attributes should be lumped in with custom derive invocations. The fix applied here was to track in the expander if our attribute is changing (getting stashed away elsewhere and replaced with a new invocation). If it is swapped then it's considered progress, otherwise behavior should remain the same. Closes #52525
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-two-attrs.rs | 22 | ||||
| -rw-r--r-- | src/test/run-pass-fulldeps/proc-macro/derive-two-attrs.rs | 24 |
2 files changed, 46 insertions, 0 deletions
diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-two-attrs.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-two-attrs.rs new file mode 100644 index 00000000000..d02edb50fb2 --- /dev/null +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-two-attrs.rs @@ -0,0 +1,22 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::*; + +#[proc_macro_derive(A, attributes(b))] +pub fn foo(_x: TokenStream) -> TokenStream { + TokenStream::new() +} diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-two-attrs.rs b/src/test/run-pass-fulldeps/proc-macro/derive-two-attrs.rs new file mode 100644 index 00000000000..6a0a3b3a941 --- /dev/null +++ b/src/test/run-pass-fulldeps/proc-macro/derive-two-attrs.rs @@ -0,0 +1,24 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:derive-two-attrs.rs + +#![feature(use_extern_macros)] + +extern crate derive_two_attrs as foo; + +use foo::A; + +#[derive(A)] +#[b] +#[b] +struct B; + +fn main() {} |
