]> git.proxmox.com Git - rustc.git/blob - src/libsyntax/ext/deriving/bounds.rs
Imported Upstream version 1.2.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 ast::MetaItem;
12 use codemap::Span;
13 use ext::base::{ExtCtxt, Annotatable};
14 use ext::deriving::generic::*;
15 use ext::deriving::generic::ty::*;
16
17 pub fn expand_deriving_unsafe_bound(cx: &mut ExtCtxt,
18 span: Span,
19 _: &MetaItem,
20 _: &Annotatable,
21 _: &mut FnMut(Annotatable))
22 {
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 {
32 let path = Path::new(vec![
33 if cx.use_std { "std" } else { "core" },
34 "marker",
35 "Copy",
36 ]);
37
38 let trait_def = TraitDef {
39 span: span,
40 attributes: Vec::new(),
41 path: path,
42 additional_bounds: Vec::new(),
43 generics: LifetimeBounds::empty(),
44 methods: Vec::new(),
45 associated_types: Vec::new(),
46 };
47
48 trait_def.expand(cx, mitem, item, push);
49 }