Skip to main content

Crate incin_diagnostics

Crate incin_diagnostics 

Source
Expand description

Typenum-to-decimal diagnostic humanization for Incin tooling.

Split by concern per docs/CONVENTIONS.md: humanize is the public entry-point API (humanize_diagnostic, inlay/hover label handling, path-qualifier stripping); mismatch is the family of structured shape-mismatch diagnostic parsers (MatMulMismatch, ConcatMismatch, and friends); typenum is the lower-level typenum expression parsing and substitution machinery humanize builds on.

Structs§

BmmMismatch
A bmm rank or shape mismatch.
BroadcastMismatch
A broadcast shape mismatch, parsed from the BroadcastShape trait’s message.
ConcatMismatch
A concat shape mismatch, parsed from the ConcatShape trait’s message.
Conv1dMismatch
A conv1d shape mismatch, parsed from the SpatialConv1d trait’s message.
Conv2dMismatch
A conv2d shape mismatch, parsed from the Conv2dShape trait’s message.
FlattenMismatch
A flatten shape mismatch, parsed from the Flatten trait’s message.
GroupNormMismatch
A group_norm channel divisibility mismatch.
InPlaceShapeMismatch
An in-place shape mismatch diagnostic.
MatMulMismatch
A matmul shape mismatch, parsed from the MatMulShape trait’s #[diagnostic::on_unimplemented] message, with the specific conflicting dimension identified and ready to render as a pointed-out explanation.
MathDomainError
A math domain error diagnostic (e.g., asin/acos out of bounds, rsqrt non-positive).
ModuleForwardMismatch
A Module::forward input shape mismatch, parsed from compiler output.
PixelShuffleMismatch
A pixel_shuffle channel divisibility mismatch.
Pool2dMismatch
A 2D pooling shape mismatch, parsed from the Pool2dShape trait’s message.
ReduceDimMismatch
A reduce shape mismatch, parsed from the ReduceDim trait’s message.
ReshapeMismatch
A reshape shape mismatch, parsed from the ReshapeShape trait’s message.
ShapeEqMismatch
A shape equality mismatch, parsed from the ShapeEq trait’s compile-time error.
SliceMismatch
A slice target shape mismatch, parsed from the SliceTarget trait’s message.
Translated
The result of humanizing a diagnostic: the rewritten text, plus the (decimal, original_typenum_expr) hint pairs discovered along the way.
TransposeMismatch
A transpose shape mismatch, parsed from the Transpose trait’s message.
UnfoldMismatch
An unfold dimension bound mismatch.

Functions§

collapse_dimcons_chains
Rewrites every DimCons<H, DimCons<H2, ... DimCons<Hn, Nil>...>> chain in text into [H, H2, ..., Hn] - the same bracket-list rendering crate::humanize_type_signature already gives a Tensor<(...)> shape tuple, extended to the cons-list shape encoding that shows up bare in trait-bound diagnostics (MatMulShape<DimCons<...>> and similar), which never passes through the Tensor<( special case at all.
expand_and_substitute_type_files
Scans diagnostic text for rustc’s “the full type name was written to ‘PATH’” notes, attempts to read the referenced files, humanizes their type signatures/typenums, substitutes any truncated ... type spans in the diagnostic message with the full types, and appends an expanded full type section directly into the diagnostic text.
humanize_diagnostic
Rewrites a compiler diagnostic (or any text) by replacing every typenum expression with its decimal value. This is the single entry point the CLI and any IDE tooling should call, so their output stays identical.
humanize_inlay_label
Rewrites a rust-analyzer inlay-hint (or hover) label for a Incin tensor type into a compact shape form: Tensor<(U2, U3), CpuBackendImpl<Cpu>> becomes Tensor<[2, 3], CpuBackendImpl<Cpu>> - or, with shorten_backend: true, Tensor<[2, 3]>.
humanize_type_signature
Same rewrite as humanize_inlay_label, but also returns the (decimal, original) hint pairs discovered along the way - for callers like hover, which (unlike an inlay hint’s cramped ghost text) have room to show a legend mapping each humanized number back to its raw typenum expression.
parse_bmm_mismatch
Parses a bmm mismatch from diagnostic text; None when the text is not this message.
parse_broadcast_mismatch
Parses a broadcast mismatch from diagnostic text; None when the text is not this message.
parse_concat_mismatch
Parses a concat mismatch from diagnostic text; None when the text is not this message.
parse_conv1d_mismatch
Parses a conv1d mismatch from diagnostic text; None when the text is not this message.
parse_conv2d_mismatch
Parses a conv2d mismatch from diagnostic text; None when the text is not this message.
parse_flatten_mismatch
Parses a flatten mismatch from diagnostic text; None when the text is not this message.
parse_group_norm_mismatch
Parses a group_norm mismatch from diagnostic text; None when the text is not this message.
parse_inplace_shape_mismatch
Parses a inplace_shape mismatch from diagnostic text; None when the text is not this message.
parse_math_domain_error
Parses a math_domain_error mismatch from diagnostic text; None when the text is not this message.
parse_matmul_mismatch
Parses the MatMulShape trait’s fixed on_unimplemented message - Cannot matrix-multiply shape `{Self}` with `{Rhs}` - and, if the inner dimensions (last element of Self, second-to-last of Rhs, per the trait’s own rule) actually differ, returns a MatMulMismatch ready to render. Returns None if text isn’t this message, either shape isn’t a plain tuple, or the inner dimensions match (nothing to explain - the real failure is something else, e.g. a rank mismatch).
parse_module_forward_mismatch
Parses a module_forward mismatch from diagnostic text; None when the text is not this message.
parse_pixel_shuffle_mismatch
Parses a pixel_shuffle mismatch from diagnostic text; None when the text is not this message.
parse_pool2d_mismatch
Parses a pool2d mismatch from diagnostic text; None when the text is not this message.
parse_reduce_dim_mismatch
Parses a reduce_dim mismatch from diagnostic text; None when the text is not this message.
parse_reshape_mismatch
Parses a reshape mismatch from diagnostic text; None when the text is not this message.
parse_shape_eq_mismatch
Parses a shape_eq mismatch from diagnostic text; None when the text is not this message.
parse_single_typenum
Recursively parses a typenum string like UInt<UInt<UTerm, B1>, B0> into an integer.
parse_slice_mismatch
Parses a slice mismatch from diagnostic text; None when the text is not this message.
parse_transpose_mismatch
Parses a transpose mismatch from diagnostic text; None when the text is not this message.
parse_unfold_mismatch
Parses a unfold mismatch from diagnostic text; None when the text is not this message.
replace_truncated_spans
Replaces backticked spans in text that contain ... or UInt< with the corresponding full humanized type strings read from a rustc long-type file.
strip_path_qualifiers
Collapses every qualified path in a type signature down to its last segment: incin::cpu::Tensor becomes Tensor, typenum::B1 becomes B1. Intended for rust-analyzer’s inlay-hint textEdits[0].newText, which spells every type fully-qualified (so it inserts correctly at any scope) - that fully-qualified form is otherwise identical in shape to the short-path form humanize_inlay_label already knows how to parse, so normalizing it first lets the same parser handle both.
translate_typenum_text
Scans text for typenum expressions, translates them into human-readable numbers, and collects translation mapping hints.