ty.flags -> ty.flags()

This commit is contained in:
LeSeulArtichaut 2020-08-06 17:49:46 +02:00
parent 085e417087
commit 4d28a82c59
8 changed files with 23 additions and 11 deletions

View File

@ -418,7 +418,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
| ty::Foreign(..) | ty::Foreign(..)
| ty::Param(..) | ty::Param(..)
| ty::Opaque(..) => { | ty::Opaque(..) => {
if t.flags.intersects(self.needs_canonical_flags) { if t.flags().intersects(self.needs_canonical_flags) {
t.super_fold_with(self) t.super_fold_with(self)
} else { } else {
t t

View File

@ -1828,9 +1828,9 @@ macro_rules! sty_debug_print {
ty::Error(_) => /* unimportant */ continue, ty::Error(_) => /* unimportant */ continue,
$(ty::$variant(..) => &mut $variant,)* $(ty::$variant(..) => &mut $variant,)*
}; };
let lt = t.flags.intersects(ty::TypeFlags::HAS_RE_INFER); let lt = t.flags().intersects(ty::TypeFlags::HAS_RE_INFER);
let ty = t.flags.intersects(ty::TypeFlags::HAS_TY_INFER); let ty = t.flags().intersects(ty::TypeFlags::HAS_TY_INFER);
let ct = t.flags.intersects(ty::TypeFlags::HAS_CT_INFER); let ct = t.flags().intersects(ty::TypeFlags::HAS_CT_INFER);
variant.total += 1; variant.total += 1;
total.total += 1; total.total += 1;

View File

@ -253,7 +253,7 @@ impl FlagComputation {
} }
fn add_ty(&mut self, ty: Ty<'_>) { 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); self.add_exclusive_binder(ty.outer_exclusive_binder);
} }

View File

@ -352,7 +352,7 @@ impl<'tcx> TyCtxt<'tcx> {
fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool {
// We're only interested in types involving regions // 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) ty.super_visit_with(self)
} else { } else {
false // keep visiting false // keep visiting
@ -922,8 +922,13 @@ struct HasTypeFlagsVisitor {
impl<'tcx> TypeVisitor<'tcx> for HasTypeFlagsVisitor { impl<'tcx> TypeVisitor<'tcx> for HasTypeFlagsVisitor {
fn visit_ty(&mut self, t: Ty<'_>) -> bool { fn visit_ty(&mut self, t: Ty<'_>) -> bool {
debug!("HasTypeFlagsVisitor: t={:?} t.flags={:?} self.flags={:?}", t, t.flags, self.flags); debug!(
t.flags.intersects(self.flags) "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 { fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool {

View File

@ -583,7 +583,9 @@ pub struct TyS<'tcx> {
/// This field shouldn't be used directly and may be removed in the future. /// This field shouldn't be used directly and may be removed in the future.
/// Use `TyS::kind()` instead. /// Use `TyS::kind()` instead.
kind: TyKind<'tcx>, 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 /// This is a kind of confusing thing: it stores the smallest
/// binder such that /// binder such that

View File

@ -1748,6 +1748,11 @@ impl<'tcx> TyS<'tcx> {
&self.kind &self.kind
} }
#[inline(always)]
pub fn flags(&self) -> TypeFlags {
self.flags
}
#[inline] #[inline]
pub fn is_unit(&self) -> bool { pub fn is_unit(&self) -> bool {
match self.kind() { match self.kind() {

View File

@ -708,7 +708,7 @@ where
fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool {
// We're only interested in types involving regions // 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 return false; // keep visiting
} }

View File

@ -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)"); diag.span_label(const_kw_span, "make this a static item (maybe with lazy_static)");
}, },
Source::Assoc { ty: ty_span, .. } => { 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)); diag.span_label(ty_span, &format!("consider requiring `{}` to be `Copy`", ty));
} }
}, },