Skip to content

Commit b37fb23

Browse files
committed
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`.
1 parent f75d884 commit b37fb23

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
@@ -2559,16 +2559,12 @@ pub enum Rvalue<'tcx> {
25592559
UnaryOp(UnOp, Operand<'tcx>),
25602560

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

0 commit comments

Comments
 (0)