Auto merge of #83908 - Flying-Toast:master, r=davidtwco
Add enum_intrinsics_non_enums lint There is a clippy lint to prevent calling [`mem::discriminant`](https://doc.rust-lang.org/std/mem/fn.discriminant.html) with a non-enum type. I think the lint is worthy of being included in rustc, given that `discriminant::<T>()` where `T` is a non-enum has an unspecified return value, and there are no valid use cases where you'd actually want this. I've also made the lint check [variant_count](https://doc.rust-lang.org/core/mem/fn.variant_count.html) (#73662). closes #83899
This commit is contained in:
commit
5b210643eb
22 changed files with 292 additions and 315 deletions
|
|
@ -1053,6 +1053,7 @@ pub const fn discriminant<T>(v: &T) -> Discriminant<T> {
|
|||
#[inline(always)]
|
||||
#[unstable(feature = "variant_count", issue = "73662")]
|
||||
#[rustc_const_unstable(feature = "variant_count", issue = "73662")]
|
||||
#[rustc_diagnostic_item = "mem_variant_count"]
|
||||
pub const fn variant_count<T>() -> usize {
|
||||
intrinsics::variant_count::<T>()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue