Skip to content

Commit caa1c43

Browse files
committed
Remove duplicated Flags methods.
The `Flags` trait has two methods: `flags` and `outer_exclusive_binder`. Multiple types impl this trait and then also have duplicate inherent methods with the same names; these are all marked with "Think about removing this" comments. This is left over from things being moved into `rustc_type_ir`. This commit removes those inherent methods. This requires adding `use Flags` to a number of files.
1 parent 9620eae commit caa1c43

14 files changed

Lines changed: 17 additions & 57 deletions

File tree

compiler/rustc_borrowck/src/region_infer/opaque_types/member_constraints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use rustc_data_structures::fx::FxHashMap;
22
use rustc_hir::def_id::DefId;
33
use rustc_middle::bug;
44
use rustc_middle::ty::{
5-
self, GenericArgsRef, Region, RegionVid, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable,
5+
self, Flags, GenericArgsRef, Region, RegionVid, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable,
66
TypeVisitor,
77
};
88
use tracing::{debug, instrument};

compiler/rustc_borrowck/src/region_infer/opaque_types/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_infer::traits::ObligationCause;
1010
use rustc_macros::extension;
1111
use rustc_middle::mir::{Body, ConstraintCategory};
1212
use rustc_middle::ty::{
13-
self, DefiningScopeKind, DefinitionSiteHiddenType, FallibleTypeFolder, GenericArg,
13+
self, DefiningScopeKind, DefinitionSiteHiddenType, FallibleTypeFolder, Flags, GenericArg,
1414
GenericArgsRef, OpaqueTypeKey, ProvisionalHiddenType, Region, RegionVid, Ty, TyCtxt,
1515
TypeFoldable, TypeSuperFoldable, TypeVisitableExt, fold_regions,
1616
};

compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_hir_analysis::hir_ty_lowering::{
1717
};
1818
use rustc_infer::infer::{self, RegionVariableOrigin};
1919
use rustc_infer::traits::{DynCompatibilityViolation, Obligation};
20-
use rustc_middle::ty::{self, Const, Ty, TyCtxt, TypeVisitableExt};
20+
use rustc_middle::ty::{self, Const, Flags, Ty, TyCtxt, TypeVisitableExt};
2121
use rustc_session::Session;
2222
use rustc_span::{self, DUMMY_SP, ErrorGuaranteed, Ident, Span};
2323
use rustc_trait_selection::error_reporting::TypeErrCtxt;

compiler/rustc_hir_typeck/src/writeback.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc_infer::traits::solve::Goal;
2121
use rustc_middle::traits::ObligationCause;
2222
use rustc_middle::ty::adjustment::{Adjust, Adjustment, PointerCoercion};
2323
use rustc_middle::ty::{
24-
self, DefiningScopeKind, DefinitionSiteHiddenType, Ty, TyCtxt, TypeFoldable, TypeFolder,
24+
self, DefiningScopeKind, DefinitionSiteHiddenType, Flags, Ty, TyCtxt, TypeFoldable, TypeFolder,
2525
TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor,
2626
fold_regions,
2727
};
@@ -932,7 +932,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
932932
fn handle_term<T>(
933933
&mut self,
934934
value: T,
935-
outer_exclusive_binder: impl FnOnce(T) -> ty::DebruijnIndex,
935+
outer_exclusive_binder: impl FnOnce(&T) -> ty::DebruijnIndex,
936936
new_err: impl Fn(TyCtxt<'tcx>, ErrorGuaranteed) -> T,
937937
) -> T
938938
where
@@ -945,7 +945,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
945945
let body_id = tcx.hir_body_owner_def_id(self.body.id());
946946
let cause = ObligationCause::misc(self.span.to_span(tcx), body_id);
947947
let at = self.fcx.at(&cause, self.fcx.param_env);
948-
let universes = vec![None; outer_exclusive_binder(value).as_usize()];
948+
let universes = vec![None; outer_exclusive_binder(&value).as_usize()];
949949
match solve::deeply_normalize_with_skipped_universes_and_ambiguous_coroutine_goals(
950950
at, value, universes,
951951
) {

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ use rustc_data_structures::sso::SsoHashMap;
1010
use rustc_index::Idx;
1111
use rustc_middle::bug;
1212
use rustc_middle::ty::{
13-
self, BoundVar, GenericArg, InferConst, List, Ty, TyCtxt, TypeFlags, TypeFoldable, TypeFolder,
14-
TypeSuperFoldable, TypeVisitableExt,
13+
self, BoundVar, Flags, GenericArg, InferConst, List, Ty, TyCtxt, TypeFlags, TypeFoldable,
14+
TypeFolder, TypeSuperFoldable, TypeVisitableExt, TypingModeEqWrapper,
1515
};
16-
use rustc_type_ir::TypingModeEqWrapper;
1716
use smallvec::SmallVec;
1817
use tracing::debug;
1918

compiler/rustc_infer/src/infer/canonical/instantiate.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
99
use rustc_macros::extension;
1010
use rustc_middle::ty::{
11-
self, DelayedMap, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeSuperVisitable,
12-
TypeVisitableExt, TypeVisitor,
11+
self, DelayedMap, Ty, TyCtxt, TypeFlags, TypeFoldable, TypeFolder, TypeSuperFoldable,
12+
TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor,
1313
};
14-
use rustc_type_ir::{TypeFlags, TypeVisitable};
1514

1615
use crate::infer::canonical::{Canonical, CanonicalVarValues};
1716

compiler/rustc_infer/src/infer/outlives/for_liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rustc_middle::ty::{
2-
self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor,
2+
self, Flags, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor,
33
};
44

55
use crate::infer::outlives::test_type_match;

compiler/rustc_middle/src/ty/consts.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,6 @@ impl<'tcx> Const<'tcx> {
5555
*a
5656
}
5757

58-
// FIXME(compiler-errors): Think about removing this.
59-
#[inline]
60-
pub fn flags(self) -> TypeFlags {
61-
self.0.flags
62-
}
63-
64-
// FIXME(compiler-errors): Think about removing this.
65-
#[inline]
66-
pub fn outer_exclusive_binder(self) -> ty::DebruijnIndex {
67-
self.0.outer_exclusive_binder
68-
}
69-
7058
#[inline]
7159
pub fn new(tcx: TyCtxt<'tcx>, kind: ty::ConstKind<'tcx>) -> Const<'tcx> {
7260
tcx.mk_ct_from_kind(kind)

compiler/rustc_middle/src/ty/predicate.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ use rustc_hir::def_id::DefId;
55
use rustc_macros::{HashStable, extension};
66
use rustc_type_ir as ir;
77

8-
use crate::ty::{
9-
self, DebruijnIndex, EarlyBinder, Ty, TyCtxt, TypeFlags, Upcast, UpcastFrom, WithCachedTypeInfo,
10-
};
8+
use crate::ty::{self, EarlyBinder, Ty, TyCtxt, TypeFlags, Upcast, UpcastFrom, WithCachedTypeInfo};
119

1210
pub type TraitRef<'tcx> = ir::TraitRef<TyCtxt<'tcx>>;
1311
pub type AliasTerm<'tcx> = ir::AliasTerm<TyCtxt<'tcx>>;
@@ -76,18 +74,6 @@ impl<'tcx> Predicate<'tcx> {
7674
self.0.internee
7775
}
7876

79-
// FIXME(compiler-errors): Think about removing this.
80-
#[inline(always)]
81-
pub fn flags(self) -> TypeFlags {
82-
self.0.flags
83-
}
84-
85-
// FIXME(compiler-errors): Think about removing this.
86-
#[inline(always)]
87-
pub fn outer_exclusive_binder(self) -> DebruijnIndex {
88-
self.0.outer_exclusive_binder
89-
}
90-
9177
/// Flips the polarity of a Predicate.
9278
///
9379
/// Given `T: Trait` predicate it returns `T: !Trait` and given `T: !Trait` returns `T: Trait`.

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::traits::ObligationCause;
2727
use crate::ty::InferTy::*;
2828
use crate::ty::{
2929
self, AdtDef, Const, Discr, GenericArg, GenericArgs, GenericArgsRef, List, ParamEnv, Region,
30-
Ty, TyCtxt, TypeFlags, TypeSuperVisitable, TypeVisitable, TypeVisitor, UintTy, ValTree,
30+
Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor, UintTy, ValTree,
3131
};
3232

3333
// Re-export and re-parameterize some `I = TyCtxt<'tcx>` types here
@@ -1121,12 +1121,6 @@ impl<'tcx> Ty<'tcx> {
11211121
self.0.0
11221122
}
11231123

1124-
// FIXME(compiler-errors): Think about removing this.
1125-
#[inline(always)]
1126-
pub fn flags(self) -> TypeFlags {
1127-
self.0.0.flags
1128-
}
1129-
11301124
#[inline]
11311125
pub fn is_unit(self) -> bool {
11321126
match self.kind() {

0 commit comments

Comments
 (0)