diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-06-29 06:59:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-29 06:59:30 +0200 |
| commit | 6404d29442a238f4876a10e97de73dc2e22d81a7 (patch) | |
| tree | d6df88385ac2f6dc13a5e1d98d344b3b0b167faa /compiler/rustc_codegen_ssa | |
| parent | fd0062cde4d72d0c943b12127cf2b9d4ba58dd03 (diff) | |
| parent | 1c25bfba9d5bc6e4dfc295e016aac32ff0546f97 (diff) | |
| download | rust-6404d29442a238f4876a10e97de73dc2e22d81a7.tar.gz rust-6404d29442a238f4876a10e97de73dc2e22d81a7.zip | |
Rollup merge of #143088 - firefighterduck:improve-doc-discr-tag, r=RalfJung
Improve documentation of `TagEncoding` This PR is follow-up from the [discussion here](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/.E2.9C.94.20VariantId.3DDiscriminant.20when.20tag.20is.20niche.20encoded.3F/with/524384295). It aims at making the `TagEncoding` documentation less ambiguous and more detailed with references to relevant implementation sides. It especially clears up the ambiguous use of discriminant/variant index, which sparked the discussion referenced above. PS: While working with layout data, I somehow ended up looking at the docs for `FakeBorrowKind` and noticed that the one example was not in a doc comment. I hope that this is minor enough of a fix for it to be okay in this otherwise unrelated PR.
Diffstat (limited to 'compiler/rustc_codegen_ssa')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/mir/operand.rs | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/operand.rs b/compiler/rustc_codegen_ssa/src/mir/operand.rs index 99957c67708..da615cc9a00 100644 --- a/compiler/rustc_codegen_ssa/src/mir/operand.rs +++ b/compiler/rustc_codegen_ssa/src/mir/operand.rs @@ -479,17 +479,8 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { _ => (tag_imm, bx.cx().immediate_backend_type(tag_op.layout)), }; - // Layout ensures that we only get here for cases where the discriminant + // `layout_sanity_check` ensures that we only get here for cases where the discriminant // value and the variant index match, since that's all `Niche` can encode. - // But for emphasis and debugging, let's double-check one anyway. - debug_assert_eq!( - self.layout - .ty - .discriminant_for_variant(bx.tcx(), untagged_variant) - .unwrap() - .val, - u128::from(untagged_variant.as_u32()), - ); let relative_max = niche_variants.end().as_u32() - niche_variants.start().as_u32(); |
