rapx/preprocess/
dummy_fns.rs1use super::doc_attr;
2use rustc_ast::*;
3use rustc_span::{DUMMY_SP, symbol::Ident};
4use thin_vec::ThinVec;
5
6fn make_dummy_fn_sig() -> FnSig {
7 let fn_decl = FnDecl {
8 inputs: ThinVec::new(),
9 output: FnRetTy::Default(DUMMY_SP),
10 };
11
12 FnSig {
13 decl: Box::new(fn_decl),
14 header: FnHeader {
15 safety: Safety::Default,
16 constness: Const::No,
17 ext: Extern::None,
18 coroutine_kind: None,
19 },
20 span: DUMMY_SP,
21 }
22}
23
24fn make_dummy_block() -> Block {
25 Block {
26 stmts: ThinVec::new(),
27 id: DUMMY_NODE_ID,
28 rules: BlockCheckMode::Default,
29 span: DUMMY_SP,
30 tokens: None,
31 }
32}
33
34fn make_dummy_fn(ident_name: &str) -> Box<Item> {
35 let ident = Ident::from_str(ident_name);
36
37 let fn_ast = Fn {
38 defaultness: Defaultness::Final,
39 ident,
40 generics: Generics::default(),
41 sig: make_dummy_fn_sig(),
42 contract: None,
43 define_opaque: None,
44 body: Some(Box::new(make_dummy_block())),
45 };
46
47 Box::new(Item {
48 attrs: ThinVec::from([doc_attr()]),
49 id: DUMMY_NODE_ID,
50 kind: ItemKind::Fn(Box::new(fn_ast)),
51 vis: Visibility {
52 span: DUMMY_SP,
53 kind: VisibilityKind::Public,
54 tokens: None,
55 },
56 span: DUMMY_SP,
57 tokens: None,
58 })
59}
60
61pub(crate) fn create_dummy_fns(krate: &mut Crate) {
62 let raw_ptr_fn = make_dummy_fn("__raw_ptr_deref_dummy");
63 krate.items.push(raw_ptr_fn);
66 }