pub struct BuildDiagnostic {
pub phase: &'static str,
pub branch: String,
pub node: String,
pub source: String,
pub line: usize,
pub function: String,
pub field: String,
pub expected: String,
pub actual: String,
pub provider: String,
pub message: String,
}Expand description
One declaration error before it is rendered for rustc or a terminal. 在输出给 rustc 或终端之前的一条声明错误。
Fields§
§phase: &'static strBuild phase that raised this diagnostic; empty means the phase is not applicable to this diagnostic. 提出该诊断的构建阶段;为空表示该阶段不适用于此诊断。
branch: StringGraft branch the failure was reported under; empty means not applicable. 报告该失败时所在的 graft 分支;为空表示不适用。
node: StringRegistration face identity rendered as name (kind); empty means not
applicable.
渲染为 name (kind) 的注册面身份;为空表示不适用。
source: StringDeclaration source file carrying the failure; empty means not applicable. 携带该失败的声明源文件;为空表示不适用。
line: usize1-based line inside source; 0 when the diagnostic has no line.
source 内以 1 起始的行号;诊断没有行号时为 0。
function: StringLogical function or handle the failure is about; empty means not applicable. 失败所针对的逻辑函数或 handle;为空表示不适用。
field: StringDeclaration field that failed its check; empty means not applicable. 未通过检查的声明字段;为空表示不适用。
expected: StringValue the contract required; empty means not applicable. 契约要求的值;为空表示不适用。
actual: StringValue actually observed; empty means not applicable. 实际观测到的值;为空表示不适用。
provider: StringKind of ancestor expected to provide the missing capability; empty means not applicable. 本应提供缺失能力的祖先类型;为空表示不适用。
message: StringHuman-readable failure summary; empty means no message applies. 人类可读的失败摘要;为空表示没有消息。
Implementations§
Source§impl BuildDiagnostic
impl BuildDiagnostic
Sourcepub fn new(phase: &'static str, message: impl Into<String>) -> BuildDiagnostic
pub fn new(phase: &'static str, message: impl Into<String>) -> BuildDiagnostic
Start a diagnostic in phase with its human-readable message.
以 phase 和人类可读消息开启一条诊断。
Every optional field starts empty, so the builder methods below attach only the facts this diagnostic actually has. 所有可选字段起始为空,由下面的 builder 方法只挂上该诊断真正具有的事实。
Sourcepub fn at(self, source: impl Into<String>, line: usize) -> BuildDiagnostic
pub fn at(self, source: impl Into<String>, line: usize) -> BuildDiagnostic
Attach the declaration source and its 1-based line; pass 0 for no line.
挂上声明源码与以 1 起始的行号;没有行号时传 0。
Sourcepub fn node(
self,
node: impl Into<String>,
kind: impl Into<String>,
) -> BuildDiagnostic
pub fn node( self, node: impl Into<String>, kind: impl Into<String>, ) -> BuildDiagnostic
Attach the failing face identity and kind, stored together as node (kind).
挂上失败注册面的身份与类型,合并存储为 node (kind)。
Sourcepub fn branch(self, branch: impl Into<String>) -> BuildDiagnostic
pub fn branch(self, branch: impl Into<String>) -> BuildDiagnostic
Attach the graft branch the failure belongs to. 挂上该失败所属的 graft 分支。
Sourcepub fn function(self, function: impl Into<String>) -> BuildDiagnostic
pub fn function(self, function: impl Into<String>) -> BuildDiagnostic
Attach the logical function or handle the failure is about. 挂上该失败所针对的逻辑函数或 handle。
Sourcepub fn field(self, field: impl Into<String>) -> BuildDiagnostic
pub fn field(self, field: impl Into<String>) -> BuildDiagnostic
Attach the declaration field that failed its check. 挂上未通过检查的声明字段。
Sourcepub fn expected(self, expected: impl Into<String>) -> BuildDiagnostic
pub fn expected(self, expected: impl Into<String>) -> BuildDiagnostic
Attach the value the contract required. 挂上契约要求的值。
Sourcepub fn actual(self, actual: impl Into<String>) -> BuildDiagnostic
pub fn actual(self, actual: impl Into<String>) -> BuildDiagnostic
Attach the value actually observed. 挂上实际观测到的值。
Sourcepub fn provider(self, provider: impl Into<String>) -> BuildDiagnostic
pub fn provider(self, provider: impl Into<String>) -> BuildDiagnostic
Attach the kind of ancestor expected to provide the missing capability. 挂上本应提供缺失能力的祖先类型。
Trait Implementations§
Source§impl Clone for BuildDiagnostic
impl Clone for BuildDiagnostic
Source§fn clone(&self) -> BuildDiagnostic
fn clone(&self) -> BuildDiagnostic
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more