Skip to main content

rustc_builtin_macros/deriving/
const_param_ty.rs

1use rustc_ast::Safety;
2use rustc_expand::base::ExtCtxt;
3use rustc_span::Span;
4
5use crate::deriving::generic::*;
6use crate::deriving::path_std;
7
8pub(crate) fn expand_deriving_const_param_ty(
9    cx: &ExtCtxt<'_>,
10    span: Span,
11    item: &ast::Item,
12    push: &mut dyn FnMut(Box<ast::Item>),
13    is_const: bool,
14) {
15    let trait_def = TraitDef {
16        span,
17        path: generic::ty::new_path(cx, span, { &[sym::marker, sym::ConstParamTy_] }, &[])path_std!(cx, span, marker::ConstParamTy_),
18        skip_path_as_bound: false,
19        needs_copy_as_bound_if_packed: false,
20        additional_bounds: {
    let count = 0usize + 1usize;
    let mut vec = ::smallvec::SmallVec::new();
    if count <= vec.inline_size() {
        vec.push(generic::ty::new_path(cx, span, { &[sym::cmp, sym::Eq] },
                &[]));
        vec
    } else {
        ::smallvec::SmallVec::from_vec(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
                    [generic::ty::new_path(cx, span, { &[sym::cmp, sym::Eq] },
                                &[])])))
    }
}smallvec![path_std!(cx, span, cmp::Eq)],
21        supports_unions: false,
22        methods: SmallVec::new(),
23        associated_types: SmallVec::new(),
24        is_const,
25        safety: Safety::Default,
26        document: true,
27    };
28
29    trait_def.expand(cx, item, push);
30}