Skip to content

Commit e9e5d06

Browse files
committed
Relax constrained generics to TypeVisitable
1 parent f66c06f commit e9e5d06

File tree

23 files changed

+56
-43
lines changed

23 files changed

+56
-43
lines changed

compiler/rustc_borrowck/src/constraint_generation.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rustc_middle::mir::{
77
};
88
use rustc_middle::ty::fold::TypeFoldable;
99
use rustc_middle::ty::subst::SubstsRef;
10+
use rustc_middle::ty::visit::TypeVisitable;
1011
use rustc_middle::ty::{self, RegionVid, Ty};
1112

1213
use crate::{
@@ -163,7 +164,7 @@ impl<'cx, 'cg, 'tcx> ConstraintGeneration<'cx, 'cg, 'tcx> {
163164
/// `location`.
164165
fn add_regular_live_constraint<T>(&mut self, live_ty: T, location: Location)
165166
where
166-
T: TypeFoldable<'tcx>,
167+
T: TypeVisitable<'tcx>,
167168
{
168169
debug!("add_regular_live_constraint(live_ty={:?}, location={:?})", live_ty, location);
169170

compiler/rustc_borrowck/src/type_check/liveness/trace.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rustc_index::bit_set::HybridBitSet;
33
use rustc_index::interval::IntervalSet;
44
use rustc_infer::infer::canonical::QueryRegionConstraints;
55
use rustc_middle::mir::{BasicBlock, Body, ConstraintCategory, Local, Location};
6-
use rustc_middle::ty::{Ty, TypeFoldable};
6+
use rustc_middle::ty::{Ty, TypeFoldable, TypeVisitable};
77
use rustc_trait_selection::traits::query::dropck_outlives::DropckOutlivesResult;
88
use rustc_trait_selection::traits::query::type_op::outlives::DropckOutlives;
99
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
@@ -477,7 +477,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
477477
/// points `live_at`.
478478
fn add_use_live_facts_for(
479479
&mut self,
480-
value: impl TypeFoldable<'tcx>,
480+
value: impl TypeVisitable<'tcx>,
481481
live_at: &IntervalSet<PointIndex>,
482482
) {
483483
debug!("add_use_live_facts_for(value={:?})", value);
@@ -542,7 +542,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
542542
fn make_all_regions_live(
543543
elements: &RegionValueElements,
544544
typeck: &mut TypeChecker<'_, 'tcx>,
545-
value: impl TypeFoldable<'tcx>,
545+
value: impl TypeVisitable<'tcx>,
546546
live_at: &IntervalSet<PointIndex>,
547547
) {
548548
debug!("make_all_regions_live(value={:?})", value);

compiler/rustc_const_eval/src/interpret/util.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use rustc_middle::mir::interpret::InterpResult;
2-
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, TypeVisitor};
2+
use rustc_middle::ty::{
3+
self, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, TypeVisitable, TypeVisitor,
4+
};
35
use std::convert::TryInto;
46
use std::ops::ControlFlow;
57

@@ -10,7 +12,7 @@ use std::ops::ControlFlow;
1012
/// case these parameters are unused.
1113
pub(crate) fn ensure_monomorphic_enough<'tcx, T>(tcx: TyCtxt<'tcx>, ty: T) -> InterpResult<'tcx>
1214
where
13-
T: TypeFoldable<'tcx>,
15+
T: TypeVisitable<'tcx>,
1416
{
1517
debug!("ensure_monomorphic_enough: ty={:?}", ty);
1618
if !ty.needs_subst() {

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::infer::error_reporting::nice_region_error::NiceRegionError;
55
use crate::infer::TyCtxt;
66
use rustc_hir as hir;
77
use rustc_hir::def_id::LocalDefId;
8-
use rustc_middle::ty::{self, Binder, DefIdTree, Region, Ty, TypeFoldable};
8+
use rustc_middle::ty::{self, Binder, DefIdTree, Region, Ty, TypeFoldable, TypeVisitable};
99
use rustc_span::Span;
1010

1111
/// Information about the anonymous region we are searching for.
@@ -142,7 +142,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
142142

143143
fn includes_region(
144144
&self,
145-
ty: Binder<'tcx, impl TypeFoldable<'tcx>>,
145+
ty: Binder<'tcx, impl TypeVisitable<'tcx>>,
146146
region: ty::BoundRegionKind,
147147
) -> bool {
148148
let late_bound_regions = self.tcx().collect_referenced_late_bound_regions(&ty);

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use rustc_middle::ty::error::{ExpectedFound, TypeError};
2525
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
2626
use rustc_middle::ty::relate::RelateResult;
2727
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, InternalSubsts, SubstsRef};
28+
use rustc_middle::ty::visit::TypeVisitable;
2829
pub use rustc_middle::ty::IntVarValue;
2930
use rustc_middle::ty::{self, GenericParamDefKind, InferConst, Ty, TyCtxt};
3031
use rustc_middle::ty::{ConstVid, FloatVid, IntVid, TyVid};
@@ -1438,7 +1439,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
14381439
/// `resolve_vars_if_possible()`.
14391440
pub fn unresolved_type_vars<T>(&self, value: &T) -> Option<(Ty<'tcx>, Option<Span>)>
14401441
where
1441-
T: TypeFoldable<'tcx>,
1442+
T: TypeVisitable<'tcx>,
14421443
{
14431444
value.visit_with(&mut resolve::UnresolvedTypeFinder::new(self)).break_value()
14441445
}

compiler/rustc_infer/src/infer/nll_relate/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use rustc_data_structures::fx::FxHashMap;
2929
use rustc_middle::ty::error::TypeError;
3030
use rustc_middle::ty::fold::{TypeFoldable, TypeSuperFoldable, TypeVisitor};
3131
use rustc_middle::ty::relate::{self, Relate, RelateResult, TypeRelation};
32+
use rustc_middle::ty::visit::TypeVisitable;
3233
use rustc_middle::ty::{self, InferConst, Ty, TyCtxt};
3334
use rustc_span::Span;
3435
use std::fmt::Debug;
@@ -810,7 +811,7 @@ struct ScopeInstantiator<'me, 'tcx> {
810811
}
811812

812813
impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> {
813-
fn visit_binder<T: TypeFoldable<'tcx>>(
814+
fn visit_binder<T: TypeVisitable<'tcx>>(
814815
&mut self,
815816
t: &ty::Binder<'tcx, T>,
816817
) -> ControlFlow<Self::BreakTy> {

compiler/rustc_infer/src/infer/opaque_types.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ use rustc_middle::traits::ObligationCause;
99
use rustc_middle::ty::fold::BottomUpFolder;
1010
use rustc_middle::ty::subst::{GenericArgKind, Subst};
1111
use rustc_middle::ty::{
12-
self, OpaqueHiddenType, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, TypeVisitor,
12+
self, OpaqueHiddenType, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable,
13+
TypeVisitable, TypeVisitor,
1314
};
1415
use rustc_span::Span;
1516

@@ -461,7 +462,7 @@ impl<'tcx, OP> TypeVisitor<'tcx> for ConstrainOpaqueTypeRegionVisitor<OP>
461462
where
462463
OP: FnMut(ty::Region<'tcx>),
463464
{
464-
fn visit_binder<T: TypeFoldable<'tcx>>(
465+
fn visit_binder<T: TypeVisitable<'tcx>>(
465466
&mut self,
466467
t: &ty::Binder<'tcx, T>,
467468
) -> ControlFlow<Self::BreakTy> {

compiler/rustc_middle/src/ty/diagnostics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
use std::ops::ControlFlow;
44

55
use crate::ty::{
6-
fold::TypeFoldable, Const, ConstKind, DefIdTree, ExistentialPredicate, InferTy,
7-
PolyTraitPredicate, Ty, TyCtxt, TypeSuperFoldable, TypeVisitor,
6+
fold::TypeFoldable, visit::TypeVisitable, Const, ConstKind, DefIdTree, ExistentialPredicate,
7+
InferTy, PolyTraitPredicate, Ty, TyCtxt, TypeSuperFoldable, TypeVisitor,
88
};
99

1010
use rustc_data_structures::fx::FxHashMap;
@@ -87,7 +87,7 @@ pub trait IsSuggestable<'tcx> {
8787

8888
impl<'tcx, T> IsSuggestable<'tcx> for T
8989
where
90-
T: TypeFoldable<'tcx>,
90+
T: TypeVisitable<'tcx>,
9191
{
9292
fn is_suggestable(self, tcx: TyCtxt<'tcx>) -> bool {
9393
self.visit_with(&mut IsSuggestableVisitor { tcx }).is_continue()

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,7 @@ impl<'tcx> ParamEnv<'tcx> {
15141514
/// `where Box<u32>: Copy`, which are clearly never
15151515
/// satisfiable. We generally want to behave as if they were true,
15161516
/// although the surrounding function is never reachable.
1517-
pub fn and<T: TypeFoldable<'tcx>>(self, value: T) -> ParamEnvAnd<'tcx, T> {
1517+
pub fn and<T: TypeVisitable<'tcx>>(self, value: T) -> ParamEnvAnd<'tcx, T> {
15181518
match self.reveal() {
15191519
Reveal::UserFacing => ParamEnvAnd { param_env: self, value },
15201520

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::mir::interpret::{AllocRange, GlobalAlloc, Pointer, Provenance, Scalar
22
use crate::ty::subst::{GenericArg, GenericArgKind, Subst};
33
use crate::ty::{
44
self, ConstInt, DefIdTree, ParamConst, ScalarInt, Term, Ty, TyCtxt, TypeFoldable,
5-
TypeSuperFoldable,
5+
TypeSuperFoldable, TypeVisitable,
66
};
77
use rustc_apfloat::ieee::{Double, Single};
88
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
@@ -2277,7 +2277,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
22772277

22782278
fn prepare_late_bound_region_info<T>(&mut self, value: &ty::Binder<'tcx, T>)
22792279
where
2280-
T: TypeFoldable<'tcx>,
2280+
T: TypeVisitable<'tcx>,
22812281
{
22822282
struct LateBoundRegionNameCollector<'a, 'tcx> {
22832283
used_region_names: &'a mut FxHashSet<Symbol>,

0 commit comments

Comments
 (0)