-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
A-conversionsConversion related proposals & ideasConversion related proposals & ideasA-lintProposals relating to lints / warnings / clippy.Proposals relating to lints / warnings / clippy.T-langRelevant to the language team, which will review and decide on the RFC.Relevant to the language team, which will review and decide on the RFC.
Description
Hi,
Should lossy conversions (i.e. let a = 300u16 as u8
) be a compile time warning?
that way people can opt in with #![deny(cast_lossy)]
Otherwise maybe a way to make generic that have size constraints?
I'm working on a new library where I'm casting a bunch of stuff to usize
and for example usize::from(0u32)
isn't a thing. even though it should work on both 32bit and 64bit machines.
So right now I have a bunch of static asserts to check that size_of<usize> => size_of<u32>()
.
Edit: Related to #2715
Metadata
Metadata
Assignees
Labels
A-conversionsConversion related proposals & ideasConversion related proposals & ideasA-lintProposals relating to lints / warnings / clippy.Proposals relating to lints / warnings / clippy.T-langRelevant to the language team, which will review and decide on the RFC.Relevant to the language team, which will review and decide on the RFC.