diff --git a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs index b37227366d874..871fc4fafe269 100644 --- a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs +++ b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs @@ -418,7 +418,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> { | ty::Foreign(..) | ty::Param(..) | ty::Opaque(..) => { - if t.flags.intersects(self.needs_canonical_flags) { + if t.flags().intersects(self.needs_canonical_flags) { t.super_fold_with(self) } else { t diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 421cfce200612..aa34dedc4b286 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1828,9 +1828,9 @@ macro_rules! sty_debug_print { ty::Error(_) => /* unimportant */ continue, $(ty::$variant(..) => &mut $variant,)* }; - let lt = t.flags.intersects(ty::TypeFlags::HAS_RE_INFER); - let ty = t.flags.intersects(ty::TypeFlags::HAS_TY_INFER); - let ct = t.flags.intersects(ty::TypeFlags::HAS_CT_INFER); + let lt = t.flags().intersects(ty::TypeFlags::HAS_RE_INFER); + let ty = t.flags().intersects(ty::TypeFlags::HAS_TY_INFER); + let ct = t.flags().intersects(ty::TypeFlags::HAS_CT_INFER); variant.total += 1; total.total += 1; diff --git a/compiler/rustc_middle/src/ty/flags.rs b/compiler/rustc_middle/src/ty/flags.rs index 27f50c240db67..f7871c4fffddb 100644 --- a/compiler/rustc_middle/src/ty/flags.rs +++ b/compiler/rustc_middle/src/ty/flags.rs @@ -253,7 +253,7 @@ impl FlagComputation { } fn add_ty(&mut self, ty: Ty<'_>) { - self.add_flags(ty.flags); + self.add_flags(ty.flags()); self.add_exclusive_binder(ty.outer_exclusive_binder); } diff --git a/compiler/rustc_middle/src/ty/fold.rs b/compiler/rustc_middle/src/ty/fold.rs index 9a542190b2752..5e8fb95dc2985 100644 --- a/compiler/rustc_middle/src/ty/fold.rs +++ b/compiler/rustc_middle/src/ty/fold.rs @@ -352,7 +352,7 @@ impl<'tcx> TyCtxt<'tcx> { fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { // We're only interested in types involving regions - if ty.flags.intersects(TypeFlags::HAS_FREE_REGIONS) { + if ty.flags().intersects(TypeFlags::HAS_FREE_REGIONS) { ty.super_visit_with(self) } else { false // keep visiting @@ -922,8 +922,13 @@ struct HasTypeFlagsVisitor { impl<'tcx> TypeVisitor<'tcx> for HasTypeFlagsVisitor { fn visit_ty(&mut self, t: Ty<'_>) -> bool { - debug!("HasTypeFlagsVisitor: t={:?} t.flags={:?} self.flags={:?}", t, t.flags, self.flags); - t.flags.intersects(self.flags) + debug!( + "HasTypeFlagsVisitor: t={:?} t.flags={:?} self.flags={:?}", + t, + t.flags(), + self.flags + ); + t.flags().intersects(self.flags) } fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool { diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index d87e5888111a9..29fa3f9bb65e0 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -583,7 +583,9 @@ pub struct TyS<'tcx> { /// This field shouldn't be used directly and may be removed in the future. /// Use `TyS::kind()` instead. kind: TyKind<'tcx>, - pub flags: TypeFlags, + /// This field shouldn't be used directly and may be removed in the future. + /// Use `TyS::flags()` instead. + flags: TypeFlags, /// This is a kind of confusing thing: it stores the smallest /// binder such that diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index e58f6085323f6..9f5fc5a2d3fbc 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -1748,6 +1748,11 @@ impl<'tcx> TyS<'tcx> { &self.kind } + #[inline(always)] + pub fn flags(&self) -> TypeFlags { + self.flags + } + #[inline] pub fn is_unit(&self) -> bool { match self.kind() { diff --git a/compiler/rustc_trait_selection/src/opaque_types.rs b/compiler/rustc_trait_selection/src/opaque_types.rs index 62fff46fabe83..9cf3bbd94e03d 100644 --- a/compiler/rustc_trait_selection/src/opaque_types.rs +++ b/compiler/rustc_trait_selection/src/opaque_types.rs @@ -708,7 +708,7 @@ where fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { // We're only interested in types involving regions - if !ty.flags.intersects(ty::TypeFlags::HAS_FREE_REGIONS) { + if !ty.flags().intersects(ty::TypeFlags::HAS_FREE_REGIONS) { return false; // keep visiting } diff --git a/src/tools/clippy/clippy_lints/src/non_copy_const.rs b/src/tools/clippy/clippy_lints/src/non_copy_const.rs index f1df634701dd2..73eabd4207e77 100644 --- a/src/tools/clippy/clippy_lints/src/non_copy_const.rs +++ b/src/tools/clippy/clippy_lints/src/non_copy_const.rs @@ -128,7 +128,7 @@ fn verify_ty_bound<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, source: Source) { diag.span_label(const_kw_span, "make this a static item (maybe with lazy_static)"); }, Source::Assoc { ty: ty_span, .. } => { - if ty.flags.intersects(TypeFlags::HAS_FREE_LOCAL_NAMES) { + if ty.flags().intersects(TypeFlags::HAS_FREE_LOCAL_NAMES) { diag.span_label(ty_span, &format!("consider requiring `{}` to be `Copy`", ty)); } },