Closed
Description
I'm working on a library for compile time dimensional analysis. It uses const generics. On unit mismatch I get errors like this:
error[E0308]: mismatched types
--> src/isq.rs:346:23
|
346 | let l3 = l1 + l2;
| ^^ expected `1_i32`, found `2_i32`
|
= note: expected struct `Quantity<isq::Unit<(meter, Const<1_i32>)>, _>`
found struct `Quantity<isq::Unit<(meter, Const<2_i32>)>, _>`
As you can see, rustc
includes this _i32
type suffix into each const generic parameter. I think it's redundant & only makes compilation errors longer (which is important especially if you have complex combinations of units), because if you really want to learn the type of const generic parameter, you can just look at struct
definition in source code.
I'd like error message to look like this:
error[E0308]: mismatched types
--> src/isq.rs:346:23
|
346 | let l3 = l1 + l2;
| ^^ expected `1`, found `2`
|
= note: expected struct `Quantity<isq::Unit<(meter, Const<1>)>, _>`
found struct `Quantity<isq::Unit<(meter, Const<2>)>, _>`
Metadata
Metadata
Assignees
Labels
No labels