Fix bug in legacy `#[derive]` processing logic.
This commit is contained in:
parent
58c701f5c7
commit
bd862d29d3
|
@ -230,12 +230,12 @@ impl<'a> base::Resolver for Resolver<'a> {
|
||||||
attrs.remove(i);
|
attrs.remove(i);
|
||||||
} else {
|
} else {
|
||||||
let mut tokens = Vec::new();
|
let mut tokens = Vec::new();
|
||||||
for (i, path) in traits.iter().enumerate() {
|
for (j, path) in traits.iter().enumerate() {
|
||||||
if i > 0 {
|
if j > 0 {
|
||||||
tokens.push(TokenTree::Token(attrs[i].span, Token::Comma).into());
|
tokens.push(TokenTree::Token(attrs[i].span, Token::Comma).into());
|
||||||
}
|
}
|
||||||
for (j, segment) in path.segments.iter().enumerate() {
|
for (k, segment) in path.segments.iter().enumerate() {
|
||||||
if j > 0 {
|
if k > 0 {
|
||||||
tokens.push(TokenTree::Token(path.span, Token::ModSep).into());
|
tokens.push(TokenTree::Token(path.span, Token::ModSep).into());
|
||||||
}
|
}
|
||||||
let tok = Token::Ident(segment.identifier);
|
let tok = Token::Ident(segment.identifier);
|
||||||
|
|
|
@ -34,8 +34,14 @@ pub fn plugin_registrar(reg: &mut Registry) {
|
||||||
reg.register_custom_derive(
|
reg.register_custom_derive(
|
||||||
Symbol::intern("derive_TotalSum"),
|
Symbol::intern("derive_TotalSum"),
|
||||||
MultiDecorator(box expand));
|
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,
|
fn expand(cx: &mut ExtCtxt,
|
||||||
span: Span,
|
span: Span,
|
||||||
mitem: &ast::MetaItem,
|
mitem: &ast::MetaItem,
|
||||||
|
|
|
@ -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() {}
|
Loading…
Reference in New Issue