1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 use ast::{MetaItem, MetaWord, Item};
13 use ext::base::ExtCtxt;
14 use ext::deriving::generic::*;
15 use ext::deriving::generic::ty::*;
18 pub fn expand_deriving_bound<F>(cx: &mut ExtCtxt,
25 let name = match mitem.node {
26 MetaWord(ref tname) => {
30 return cx.span_err(span,
31 format!("{} is an unsafe trait and it \
32 should be implemented explicitly",
37 format!("expected built-in trait name but \
38 found {}", *tname).as_slice())
43 return cx.span_err(span, "unexpected value in deriving, expected \
48 let trait_def = TraitDef {
50 attributes: Vec::new(),
51 path: Path::new(vec!("std", "marker", name)),
52 additional_bounds: Vec::new(),
53 generics: LifetimeBounds::empty(),
55 associated_types: Vec::new(),
58 trait_def.expand(cx, mitem, item, push)