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
bmmrank or shape mismatch. - Broadcast
Mismatch - A
broadcastshape mismatch, parsed from theBroadcastShapetrait’s message. - Concat
Mismatch - A
concatshape mismatch, parsed from theConcatShapetrait’s message. - Conv1d
Mismatch - A
conv1dshape mismatch, parsed from theSpatialConv1dtrait’s message. - Conv2d
Mismatch - A
conv2dshape mismatch, parsed from theConv2dShapetrait’s message. - Flatten
Mismatch - A
flattenshape mismatch, parsed from theFlattentrait’s message. - Group
Norm Mismatch - A
group_normchannel divisibility mismatch. - InPlace
Shape Mismatch - An in-place shape mismatch diagnostic.
- MatMul
Mismatch - A
matmulshape mismatch, parsed from theMatMulShapetrait’s#[diagnostic::on_unimplemented]message, with the specific conflicting dimension identified and ready to render as a pointed-out explanation. - Math
Domain Error - A math domain error diagnostic (e.g., asin/acos out of bounds, rsqrt non-positive).
- Module
Forward Mismatch - A
Module::forwardinput shape mismatch, parsed from compiler output. - Pixel
Shuffle Mismatch - A
pixel_shufflechannel divisibility mismatch. - Pool2d
Mismatch - A 2D pooling shape mismatch, parsed from the
Pool2dShapetrait’s message. - Reduce
DimMismatch - A
reduceshape mismatch, parsed from theReduceDimtrait’s message. - Reshape
Mismatch - A
reshapeshape mismatch, parsed from theReshapeShapetrait’s message. - Shape
EqMismatch - A shape equality mismatch, parsed from the
ShapeEqtrait’s compile-time error. - Slice
Mismatch - A slice target shape mismatch, parsed from the
SliceTargettrait’s message. - Translated
- The result of humanizing a diagnostic: the rewritten text, plus the
(decimal, original_typenum_expr)hint pairs discovered along the way. - Transpose
Mismatch - A
transposeshape mismatch, parsed from theTransposetrait’s message. - Unfold
Mismatch - An
unfolddimension bound mismatch.
Functions§
- collapse_
dimcons_ chains - Rewrites every
DimCons<H, DimCons<H2, ... DimCons<Hn, Nil>...>>chain intextinto[H, H2, ..., Hn]- the same bracket-list renderingcrate::humanize_type_signaturealready gives aTensor<(...)>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 theTensor<(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>>becomesTensor<[2, 3], CpuBackendImpl<Cpu>>- or, withshorten_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
bmmmismatch from diagnostic text;Nonewhen the text is not this message. - parse_
broadcast_ mismatch - Parses a
broadcastmismatch from diagnostic text;Nonewhen the text is not this message. - parse_
concat_ mismatch - Parses a
concatmismatch from diagnostic text;Nonewhen the text is not this message. - parse_
conv1d_ mismatch - Parses a
conv1dmismatch from diagnostic text;Nonewhen the text is not this message. - parse_
conv2d_ mismatch - Parses a
conv2dmismatch from diagnostic text;Nonewhen the text is not this message. - parse_
flatten_ mismatch - Parses a
flattenmismatch from diagnostic text;Nonewhen the text is not this message. - parse_
group_ norm_ mismatch - Parses a
group_normmismatch from diagnostic text;Nonewhen the text is not this message. - parse_
inplace_ shape_ mismatch - Parses a
inplace_shapemismatch from diagnostic text;Nonewhen the text is not this message. - parse_
math_ domain_ error - Parses a
math_domain_errormismatch from diagnostic text;Nonewhen the text is not this message. - parse_
matmul_ mismatch - Parses the
MatMulShapetrait’s fixed on_unimplemented message -Cannot matrix-multiply shape `{Self}` with `{Rhs}`- and, if the inner dimensions (last element ofSelf, second-to-last ofRhs, per the trait’s own rule) actually differ, returns aMatMulMismatchready to render. ReturnsNoneiftextisn’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_forwardmismatch from diagnostic text;Nonewhen the text is not this message. - parse_
pixel_ shuffle_ mismatch - Parses a
pixel_shufflemismatch from diagnostic text;Nonewhen the text is not this message. - parse_
pool2d_ mismatch - Parses a
pool2dmismatch from diagnostic text;Nonewhen the text is not this message. - parse_
reduce_ dim_ mismatch - Parses a
reduce_dimmismatch from diagnostic text;Nonewhen the text is not this message. - parse_
reshape_ mismatch - Parses a
reshapemismatch from diagnostic text;Nonewhen the text is not this message. - parse_
shape_ eq_ mismatch - Parses a
shape_eqmismatch from diagnostic text;Nonewhen 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
slicemismatch from diagnostic text;Nonewhen the text is not this message. - parse_
transpose_ mismatch - Parses a
transposemismatch from diagnostic text;Nonewhen the text is not this message. - parse_
unfold_ mismatch - Parses a
unfoldmismatch from diagnostic text;Nonewhen the text is not this message. - replace_
truncated_ spans - Replaces backticked spans in
textthat contain...orUInt<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::TensorbecomesTensor,typenum::B1becomesB1. Intended for rust-analyzer’s inlay-hinttextEdits[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 formhumanize_inlay_labelalready 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.