Skip to content

Commit

Permalink
ty.flags -> ty.flags()
Browse files Browse the repository at this point in the history
  • Loading branch information
LeSeulArtichaut committed Sep 4, 2020
1 parent 085e417 commit 4d28a82
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/canonical/canonicalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
11 changes: 8 additions & 3 deletions compiler/rustc_middle/src/ty/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/non_copy_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
},
Expand Down

0 comments on commit 4d28a82

Please sign in to comment.