From fe29f03e8332fc7d9ebc8f846356ec8639d44cba Mon Sep 17 00:00:00 2001 From: Makai Date: Sat, 21 Feb 2026 01:25:39 +0800 Subject: [PATCH] rustc_public: `pub(crate)` the fields that shouldn't be exposed --- compiler/rustc_public/src/ty.rs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_public/src/ty.rs b/compiler/rustc_public/src/ty.rs index d4f128f87d6f..5d8e833ac63b 100644 --- a/compiler/rustc_public/src/ty.rs +++ b/compiler/rustc_public/src/ty.rs @@ -862,17 +862,11 @@ pub struct Discr { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize)] pub struct VariantDef { /// The variant index. - /// - /// ## Warning - /// Do not access this field directly! - pub idx: VariantIdx, + pub(crate) idx: VariantIdx, /// The data type where this variant comes from. /// For now, we use this to retrieve information about the variant itself so we don't need to /// cache more information. - /// - /// ## Warning - /// Do not access this field directly! - pub adt_def: AdtDef, + pub(crate) adt_def: AdtDef, } impl VariantDef { @@ -894,10 +888,7 @@ pub fn fields(&self) -> Vec { #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub struct FieldDef { /// The field definition. - /// - /// ## Warning - /// Do not access this field directly! This is public for the compiler to have access to it. - pub def: DefId, + pub(crate) def: DefId, /// The field name. pub name: Symbol,