]> git.proxmox.com Git - rustc.git/blob - src/libsyntax_ext/deriving/bounds.rs
New upstream version 1.12.0+dfsg1
[rustc.git] / src / libsyntax_ext / deriving / bounds.rs
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.
4 //
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.
10
11 use deriving::generic::*;
12 use deriving::generic::ty::*;
13
14 use syntax::ast::MetaItem;
15 use syntax::ext::base::{Annotatable, ExtCtxt};
16 use syntax_pos::Span;
17
18 pub fn expand_deriving_unsafe_bound(cx: &mut ExtCtxt,
19 span: Span,
20 _: &MetaItem,
21 _: &Annotatable,
22 _: &mut FnMut(Annotatable)) {
23 cx.span_err(span, "this unsafe trait should be implemented explicitly");
24 }
25
26 pub fn expand_deriving_copy(cx: &mut ExtCtxt,
27 span: Span,
28 mitem: &MetaItem,
29 item: &Annotatable,
30 push: &mut FnMut(Annotatable)) {
31 let mut v = cx.crate_root.map(|s| vec![s]).unwrap_or(Vec::new());
32 v.push("marker");
33 v.push("Copy");
34 let path = Path::new(v);
35
36 let trait_def = TraitDef {
37 span: span,
38 attributes: Vec::new(),
39 path: path,
40 additional_bounds: Vec::new(),
41 generics: LifetimeBounds::empty(),
42 is_unsafe: false,
43 methods: Vec::new(),
44 associated_types: Vec::new(),
45 };
46
47 trait_def.expand(cx, mitem, item, push);
48 }