rustc_builtin_macros/deriving/
bounds.rs1use rustc_ast::MetaItem;
2use rustc_expand::base::{Annotatable, ExtCtxt};
3use rustc_span::Span;
4
5use crate::deriving::generic::*;
6use crate::deriving::path_std;
7
8pub(crate) fn expand_deriving_copy(
9 cx: &ExtCtxt<'_>,
10 span: Span,
11 mitem: &MetaItem,
12 item: &Annotatable,
13 push: &mut dyn FnMut(Annotatable),
14 is_const: bool,
15) {
16 let trait_def = TraitDef {
17 span,
18 path: path_std!(marker::Copy),
19 skip_path_as_bound: false,
20 needs_copy_as_bound_if_packed: false,
21 additional_bounds: Vec::new(),
22 supports_unions: true,
23 methods: Vec::new(),
24 associated_types: Vec::new(),
25 is_const,
26 is_staged_api_crate: cx.ecfg.features.staged_api(),
27 };
28
29 trait_def.expand(cx, mitem, item, push);
30}
31
32pub(crate) fn expand_deriving_const_param_ty(
33 cx: &ExtCtxt<'_>,
34 span: Span,
35 mitem: &MetaItem,
36 item: &Annotatable,
37 push: &mut dyn FnMut(Annotatable),
38 is_const: bool,
39) {
40 let trait_def = TraitDef {
41 span,
42 path: path_std!(marker::ConstParamTy_),
43 skip_path_as_bound: false,
44 needs_copy_as_bound_if_packed: false,
45 additional_bounds: vec![ty::Ty::Path(path_std!(cmp::Eq))],
46 supports_unions: false,
47 methods: Vec::new(),
48 associated_types: Vec::new(),
49 is_const,
50 is_staged_api_crate: cx.ecfg.features.staged_api(),
51 };
52
53 trait_def.expand(cx, mitem, item, push);
54}