pub struct MirGraph {
pub functions: BTreeSet<String>,
pub calls: Vec<MirCall>,
pub locals: Vec<MirLocal>,
}Expand description
Every candidate one MIR artifact offered, before any merge. 一份 MIR artifact 提供的全部候选,尚未归并。
Fields§
§functions: BTreeSet<String>Function symbols the artifact declared. artifact 声明过的函数符号。
calls: Vec<MirCall>Direct call sightings, in artifact order. 直接调用观测,按 artifact 顺序。
locals: Vec<MirLocal>Local binding sightings, in artifact order. 局部绑定观测,按 artifact 顺序。
Implementations§
Source§impl MirGraph
impl MirGraph
Sourcepub fn from_jsonl(input: &str) -> Result<MirGraph, MirParseError>
pub fn from_jsonl(input: &str) -> Result<MirGraph, MirParseError>
Parse the compact JSONL artifact, one record per non-blank line. 解析紧凑 JSONL artifact,每个非空行一条记录。
A malformed line fails the whole parse with its 1-based line number;
blank lines are skipped. Each record needs a kind of function,
call, or local, and any other kind is rejected.
任一行格式错误都会以使整个解析失败,并带上其以 1 起始的行号;空行跳过。
每条记录需要 kind 为 function、call 或 local,其他类型一律拒绝。
Source§impl MirGraph
impl MirGraph
Sourcepub fn render(&self) -> String
pub fn render(&self) -> String
Render the human-readable candidate report, with one line per call and per local. 渲染人类可读的候选报告,每条调用与每个局部变量各一行。
Sourcepub fn to_jsonl(&self) -> String
pub fn to_jsonl(&self) -> String
Emit a compact, line-oriented artifact that build tooling can consume. 输出构建工具可消费的紧凑逐行 artifact。
Every string goes through the workspace’s one JSON encoder. A local
replace-based copy used to sit here, and it emitted a raw tab or newline
for a name that contained one: the record stayed readable to this crate’s
lenient parser and became invalid for every strict one. The pinning test
is a_control_character_in_a_name_stays_escaped.
每个字符串都经过工作区唯一的 JSON 编码器。这里以前有一份基于 replace 的本地副本,
遇到含制表符或换行的名字时会原样写出:记录对本 crate 的宽松解析器仍然可读,对任何严格
解析器都非法。钉住它的是 a_control_character_in_a_name_stays_escaped。
Source§impl MirGraph
impl MirGraph
Sourcepub fn from_mir_text(input: &str) -> MirGraph
pub fn from_mir_text(input: &str) -> MirGraph
Parse textual MIR emitted by rustc -Zunpretty=mir. 解析 rustc -Zunpretty=mir 输出的文本。
Only function, local, and direct-call records are kept. Runtime traces remain authoritative for calls that actually executed. 这里只保留函数、局部变量和直接调用;真实执行的调用仍以运行期追踪为准。
This never fails and never reports: text that is not MIR yields an empty
graph, and a graph with no functions is therefore the same answer for “there
is nothing here” and “this is not MIR at all”. Callers that must tell those
apart check the input themselves — the command that produces MIR already
knows whether cargo rustc succeeded — and this is the documented boundary
rather than a defect to be discovered later.
本函数从不失败也从不报告:不是 MIR 的文本会得到一个空图,因此“这里什么都没有“与“这根本
不是 MIR“给出同一个答案。必须区分两者的调用方自己检查输入——产出 MIR 的那条命令本来
就知道 cargo rustc 是否成功——这是写明的边界,而不是留给以后发现的缺陷。
Trait Implementations§
impl Eq for MirGraph
impl StructuralPartialEq for MirGraph
Auto Trait Implementations§
impl Freeze for MirGraph
impl RefUnwindSafe for MirGraph
impl Send for MirGraph
impl Sync for MirGraph
impl Unpin for MirGraph
impl UnsafeUnpin for MirGraph
impl UnwindSafe for MirGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.