diff options
| author | bors <bors@rust-lang.org> | 2017-03-21 23:11:56 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-03-21 23:11:56 +0000 |
| commit | 50c4e3e8d01020c83255c48d2fdbc58ea5ab34c9 (patch) | |
| tree | a128716ac5d487f29bf192cd96b82e9ffb39a75e | |
| parent | cab4bff3de1a61472f3c2e7752ef54b87344d1c9 (diff) | |
| parent | bd862d29d337ff4a082bef9d4adcad4b6a86b7a5 (diff) | |
| download | rust-50c4e3e8d01020c83255c48d2fdbc58ea5ab34c9.tar.gz rust-50c4e3e8d01020c83255c48d2fdbc58ea5ab34c9.zip | |
Auto merge of #40664 - jseyfried:fix_derive_bug, r=nrc
macros: fix bug in legacy custom derive processing Fixes #40663. r? @nrc
| -rw-r--r-- | src/librustc_resolve/macros.rs | 8 | ||||
| -rw-r--r-- | src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin.rs | 6 | ||||
| -rw-r--r-- | src/test/run-pass-fulldeps/issue-40663.rs | 19 |
3 files changed, 29 insertions, 4 deletions
diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index df3be8fa0f8..f8341309593 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -230,12 +230,12 @@ impl<'a> base::Resolver for Resolver<'a> { attrs.remove(i); } else { let mut tokens = Vec::new(); - for (i, path) in traits.iter().enumerate() { - if i > 0 { + for (j, path) in traits.iter().enumerate() { + if j > 0 { tokens.push(TokenTree::Token(attrs[i].span, Token::Comma).into()); } - for (j, segment) in path.segments.iter().enumerate() { - if j > 0 { + for (k, segment) in path.segments.iter().enumerate() { + if k > 0 { tokens.push(TokenTree::Token(path.span, Token::ModSep).into()); } let tok = Token::Ident(segment.identifier); diff --git a/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin.rs b/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin.rs index e46e4fb3766..16856d30417 100644 --- a/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin.rs +++ b/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin.rs @@ -34,8 +34,14 @@ pub fn plugin_registrar(reg: &mut Registry) { reg.register_custom_derive( Symbol::intern("derive_TotalSum"), MultiDecorator(box expand)); + + reg.register_custom_derive( + Symbol::intern("derive_Nothing"), + MultiDecorator(box noop)); } +fn noop(_: &mut ExtCtxt, _: Span, _: &ast::MetaItem, _: &Annotatable, _: &mut FnMut(Annotatable)) {} + fn expand(cx: &mut ExtCtxt, span: Span, mitem: &ast::MetaItem, diff --git a/src/test/run-pass-fulldeps/issue-40663.rs b/src/test/run-pass-fulldeps/issue-40663.rs new file mode 100644 index 00000000000..d030eab64e5 --- /dev/null +++ b/src/test/run-pass-fulldeps/issue-40663.rs @@ -0,0 +1,19 @@ +// Copyright 2017 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_derive_plugin.rs + +#![feature(plugin, custom_derive)] +#![plugin(custom_derive_plugin)] + +#[derive(Nothing, Nothing, Nothing)] +struct S; + +fn main() {} |
