Skip to main content

MirGraph

Struct MirGraph 

Source
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

Source

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

Source

pub fn render(&self) -> String

Render the human-readable candidate report, with one line per call and per local. 渲染人类可读的候选报告,每条调用与每个局部变量各一行。

Source

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

Source

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§

Source§

impl Clone for MirGraph

Source§

fn clone(&self) -> MirGraph

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MirGraph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for MirGraph

Source§

fn default() -> MirGraph

Returns the “default value” for a type. Read more
Source§

impl Eq for MirGraph

Source§

impl PartialEq for MirGraph

Source§

fn eq(&self, other: &MirGraph) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for MirGraph

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.