Skip to content

Commit 61c687a

Browse files
authored
Rollup merge of #96599 - tmiasko:discriminant-docs, r=estebank
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`.
2 parents a587036 + b37fb23 commit 61c687a

File tree

1 file changed

+1
-5
lines changed
  • compiler/rustc_middle/src/mir

1 file changed

+1
-5
lines changed

compiler/rustc_middle/src/mir/mod.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -2561,16 +2561,12 @@ pub enum Rvalue<'tcx> {
25612561
UnaryOp(UnOp, Operand<'tcx>),
25622562

25632563
/// Computes the discriminant of the place, returning it as an integer of type
2564-
/// [`discriminant_ty`].
2564+
/// [`discriminant_ty`]. Returns zero for types without discriminant.
25652565
///
25662566
/// The validity requirements for the underlying value are undecided for this rvalue, see
25672567
/// [#91095]. Note too that the value of the discriminant is not the same thing as the
25682568
/// variant index; use [`discriminant_for_variant`] to convert.
25692569
///
2570-
/// For types defined in the source code as enums, this is well behaved. This is also well
2571-
/// formed for other types, but yields no particular value - there is no reason it couldn't be
2572-
/// defined to yield eg zero though.
2573-
///
25742570
/// [`discriminant_ty`]: crate::ty::Ty::discriminant_ty
25752571
/// [#91095]: https://github.com/rust-lang/rust/issues/91095
25762572
/// [`discriminant_for_variant`]: crate::ty::Ty::discriminant_for_variant

0 commit comments

Comments
 (0)