Skip to content

Commit

Permalink
enable macro visits in deriving
Browse files Browse the repository at this point in the history
  • Loading branch information
durka committed May 21, 2016
1 parent 179539f commit e47384f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/libsyntax_ext/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ use std::collections::HashSet;
use std::vec;

use syntax::abi::Abi;
use syntax::ast::{self, EnumDef, Expr, Ident, Generics, VariantData, BinOpKind, PatKind};
use syntax::ast::{self, EnumDef, Expr, Ident, Generics, Mac, VariantData, BinOpKind, PatKind};
use syntax::attr;
use syntax::attr::AttrMetaMethods;
use syntax::ext::base::{ExtCtxt, Annotatable};
Expand Down Expand Up @@ -371,6 +371,10 @@ fn find_type_parameters(ty: &ast::Ty, ty_param_names: &[ast::Name]) -> Vec<P<ast

visit::walk_ty(self, ty)
}

fn visit_mac(&mut self, mac: &'a Mac) {
visit::walk_mac(self, mac)
}
}

let mut visitor = Visitor {
Expand Down
28 changes: 28 additions & 0 deletions src/test/run-pass/derive-type-macros.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2016 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.
//
// regression test for #32950

#![feature(type_macros)]

macro_rules! passthru {
($t:ty) => { $t }
}

#[derive(Debug)]
struct Thing<T> {
thing: passthru!(T)
}

fn main() {
let t: passthru!(Thing<passthru!(i32)>) = Thing { thing: 42 };
println!("{:?}", t);
}

0 comments on commit e47384f

Please sign in to comment.