From b37fb23d9f6946a9b9d7b43590105ed22a081940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Sun, 1 May 2022 00:00:00 +0000 Subject: [PATCH] Update `RValue::Discriminant` documentation `RValue::Discriminant` returns zero for types without discriminant. This guarantee is already documented for `discriminant_value` intrinsics which is implemented in terms of `RValue::Discriminant`. --- compiler/rustc_middle/src/mir/mod.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 45999f8765897..5e493b52ed641 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -2559,16 +2559,12 @@ pub enum Rvalue<'tcx> { UnaryOp(UnOp, Operand<'tcx>), /// Computes the discriminant of the place, returning it as an integer of type - /// [`discriminant_ty`]. + /// [`discriminant_ty`]. Returns zero for types without discriminant. /// /// The validity requirements for the underlying value are undecided for this rvalue, see /// [#91095]. Note too that the value of the discriminant is not the same thing as the /// variant index; use [`discriminant_for_variant`] to convert. /// - /// For types defined in the source code as enums, this is well behaved. This is also well - /// formed for other types, but yields no particular value - there is no reason it couldn't be - /// defined to yield eg zero though. - /// /// [`discriminant_ty`]: crate::ty::Ty::discriminant_ty /// [#91095]: https://github.com/rust-lang/rust/issues/91095 /// [`discriminant_for_variant`]: crate::ty::Ty::discriminant_for_variant