Skip to content

Commit 63b6bd9

Browse files
Rollup merge of #155425 - nnethercote:rm-dup-Flags-methods, r=nikomatsakis
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. r? @lcnr
2 parents 65fcd87 + e192eec commit 63b6bd9

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, Unnormalized, 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, Unnormalized};
20+
use rustc_middle::ty::{self, Const, Flags, Ty, TyCtxt, TypeVisitableExt, Unnormalized};
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
Unnormalized, fold_regions,
2727
};
@@ -933,7 +933,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
933933
fn handle_term<T>(
934934
&mut self,
935935
value: T,
936-
outer_exclusive_binder: impl FnOnce(T) -> ty::DebruijnIndex,
936+
outer_exclusive_binder: impl FnOnce(&T) -> ty::DebruijnIndex,
937937
new_err: impl Fn(TyCtxt<'tcx>, ErrorGuaranteed) -> T,
938938
) -> T
939939
where
@@ -946,7 +946,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
946946
let body_id = tcx.hir_body_owner_def_id(self.body.id());
947947
let cause = ObligationCause::misc(self.span.to_span(tcx), body_id);
948948
let at = self.fcx.at(&cause, self.fcx.param_env);
949-
let universes = vec![None; outer_exclusive_binder(value).as_usize()];
949+
let universes = vec![None; outer_exclusive_binder(&value).as_usize()];
950950
match solve::deeply_normalize_with_skipped_universes_and_ambiguous_coroutine_goals(
951951
at,
952952
Unnormalized::new_wip(value),

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
Unnormalized,
44
};
55

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>>;
@@ -78,18 +76,6 @@ impl<'tcx> Predicate<'tcx> {
7876
self.0.internee
7977
}
8078

81-
// FIXME(compiler-errors): Think about removing this.
82-
#[inline(always)]
83-
pub fn flags(self) -> TypeFlags {
84-
self.0.flags
85-
}
86-
87-
// FIXME(compiler-errors): Think about removing this.
88-
#[inline(always)]
89-
pub fn outer_exclusive_binder(self) -> DebruijnIndex {
90-
self.0.outer_exclusive_binder
91-
}
92-
9379
/// Flips the polarity of a Predicate.
9480
///
9581
/// 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
@@ -1125,12 +1125,6 @@ impl<'tcx> Ty<'tcx> {
11251125
self.0.0
11261126
}
11271127

1128-
// FIXME(compiler-errors): Think about removing this.
1129-
#[inline(always)]
1130-
pub fn flags(self) -> TypeFlags {
1131-
self.0.0.flags
1132-
}
1133-
11341128
#[inline]
11351129
pub fn is_unit(self) -> bool {
11361130
match self.kind() {

0 commit comments

Comments
 (0)