One thought I've had for a while is having semi-magical "compile-time only" types.
Imagine for a moment that integer literals are actually of type
IntegerLiteral has infinite (practical) precision. It's also flagged in some way as
CompileTimeOnly: instances of it cannot exist in the final output. As a relevant aside, note that
const items can be viewed as not making it into the output.
IntegerLiteral would have rules regarding how it decays into the primitive integer types (
usize, etc.), defaulting to
i32 in the absence of any more specific conversion. It would probably also be useful for it to decay into something like an
IntegerLiteralStr type (newtype around
&'static str), for the use of things like bignum types.
This would mean that
const LIFE = 42; would be equivalent to
const LIFE: IntegerLiteral = 42; and, in any context where it was actually used, could decay into an appropriate runtime type based on context.
If/when Rust gets CTFE, such types could be moved into the standard library, complete with custom coercions, allowing things like bignums to be initialised directly from literals.
And it wouldn't interfere with