-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Should lossy conversions be compiler warning #2784
Copy link
Copy link
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.
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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
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
usizeand for exampleusize::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