Skip to content

Commit 206588e

Browse files
committed
feat: define SerFunction in lib.rs
NOTE: lib.rs can't use rustc_internal APIs. `extern crate rustc_*` in lib.rs will cause compilation errrors: error: cannot satisfy dependencies so `rustc_driver` only shows up once | = help: having upstream crates all available in one format will likely make this go away = note: `rustc_driver` was unavailable as a static crate, preventing fully static linking = help: `feature(rustc_private)` is needed to link to the compiler's `rustc_driver` library error: cannot satisfy dependencies so `core` only shows up once | = help: having upstream crates all available in one format will likely make this go away = help: `feature(rustc_private)` is needed to link to the compiler's `rustc_driver` library
1 parent c52c8d6 commit 206588e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/lib.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
/// A Rust funtion with its file source, attributes, and raw function content.
4+
#[derive(Debug, Serialize, Deserialize)]
5+
pub struct SerFunction {
6+
pub hash: String,
7+
/// DefId in stable_mir.
8+
pub def_id: String,
9+
/// Every funtion must be declared in a specific file, even for those
10+
/// generated by macros.
11+
pub file: String,
12+
/// Attributes are attached the function, but it seems that attributes
13+
/// and function must be separated to query.
14+
pub attrs: Vec<String>,
15+
/// Raw function string, including name, signature, and body.
16+
pub func: String,
17+
/// Recursive fnction calls inside the body.
18+
pub callees: Vec<Callee>,
19+
}
20+
21+
#[derive(Debug, Serialize, Deserialize)]
22+
pub struct Callee {
23+
pub def_id: String,
24+
pub file: String,
25+
pub func: String,
26+
}

0 commit comments

Comments
 (0)