diff options
| author | bors <bors@rust-lang.org> | 2018-07-12 10:16:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-07-12 10:16:19 +0000 |
| commit | d334027c58060449cc45b8e5cc37dd51ca077d30 (patch) | |
| tree | 60321db9ce8000ebef7bf4651e0e1856935b3dbc /src/test | |
| parent | de857bbcf02d192986efc380b4735d8c9bea85ac (diff) | |
| parent | 743a8171a99748890c7922d15c3f63ba180e2de8 (diff) | |
| download | rust-d334027c58060449cc45b8e5cc37dd51ca077d30.tar.gz rust-d334027c58060449cc45b8e5cc37dd51ca077d30.zip | |
Auto merge of #52230 - alexcrichton:attr-and-derive, r=petrochenkov
rustc: Search all derives for inert attributes This commit fixes an apparent mistake in librustc_resolve where when the `proc_macro` feature is enabled (or `rust_2018_preview`) the resolution of custom attributes for custom derive was tweaked. Previously when an attribute failed to resolve it was attempted to locate if there is a custom derive also in scope which declares the attribute, but only the first custom derive directive was search. Instead this commit fixes the loop to search all custom derive invocations looking for any which register the attribute in question. Closes #52219
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-pass-fulldeps/proc-macro/auxiliary/custom-attr-only-one-derive.rs | 27 | ||||
| -rw-r--r-- | src/test/run-pass-fulldeps/proc-macro/custom-attr-only-one-derive.rs | 25 |
2 files changed, 52 insertions, 0 deletions
diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/custom-attr-only-one-derive.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/custom-attr-only-one-derive.rs new file mode 100644 index 00000000000..4609f57bddf --- /dev/null +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/custom-attr-only-one-derive.rs @@ -0,0 +1,27 @@ +// 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::TokenStream; + +#[proc_macro_derive(Foo)] +pub fn foo(a: TokenStream) -> TokenStream { + "".parse().unwrap() +} + +#[proc_macro_derive(Bar, attributes(custom))] +pub fn bar(a: TokenStream) -> TokenStream { + "".parse().unwrap() +} diff --git a/src/test/run-pass-fulldeps/proc-macro/custom-attr-only-one-derive.rs b/src/test/run-pass-fulldeps/proc-macro/custom-attr-only-one-derive.rs new file mode 100644 index 00000000000..3b2833a4bcf --- /dev/null +++ b/src/test/run-pass-fulldeps/proc-macro/custom-attr-only-one-derive.rs @@ -0,0 +1,25 @@ +// 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:custom-attr-only-one-derive.rs + +#![feature(rust_2018_preview)] + +#[macro_use] +extern crate custom_attr_only_one_derive; + +#[derive(Bar, Foo)] +#[custom = "test"] +pub enum A { + B, + C, +} + +fn main() {} |
