Introduce TypeVisitor::BreakTy
This commit is contained in:
parent
30e49a9ead
commit
e0f3119103
31 changed files with 157 additions and 128 deletions
|
@ -1498,7 +1498,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> ty::fold::TypeVisitor<'tcx> for OpaqueTypesVisitor<'tcx> {
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<()> {
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
if let Some((kind, def_id)) = TyCategory::from_ty(t) {
|
||||
let span = self.tcx.def_span(def_id);
|
||||
// Avoid cluttering the output when the "found" and error span overlap:
|
||||
|
|
|
@ -474,7 +474,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
struct TraitObjectVisitor(Vec<DefId>);
|
||||
|
||||
impl TypeVisitor<'_> for TraitObjectVisitor {
|
||||
fn visit_ty(&mut self, t: Ty<'_>) -> ControlFlow<()> {
|
||||
fn visit_ty(&mut self, t: Ty<'_>) -> ControlFlow<Self::BreakTy> {
|
||||
match t.kind() {
|
||||
ty::Dynamic(preds, RegionKind::ReStatic) => {
|
||||
if let Some(def_id) = preds.principal_def_id() {
|
||||
|
|
|
@ -741,7 +741,10 @@ struct ScopeInstantiator<'me, 'tcx> {
|
|||
}
|
||||
|
||||
impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> {
|
||||
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ControlFlow<()> {
|
||||
fn visit_binder<T: TypeFoldable<'tcx>>(
|
||||
&mut self,
|
||||
t: &ty::Binder<T>,
|
||||
) -> ControlFlow<Self::BreakTy> {
|
||||
self.target_index.shift_in(1);
|
||||
t.super_visit_with(self);
|
||||
self.target_index.shift_out(1);
|
||||
|
@ -749,7 +752,7 @@ impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> {
|
|||
ControlFlow::CONTINUE
|
||||
}
|
||||
|
||||
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<()> {
|
||||
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
let ScopeInstantiator { bound_region_scope, next_region, .. } = self;
|
||||
|
||||
match r {
|
||||
|
|
|
@ -123,7 +123,7 @@ impl<'a, 'tcx> UnresolvedTypeFinder<'a, 'tcx> {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'tcx> {
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<()> {
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
let t = self.infcx.shallow_resolve(t);
|
||||
if t.has_infer_types() {
|
||||
if let ty::Infer(infer_ty) = *t.kind() {
|
||||
|
|
|
@ -69,7 +69,7 @@ impl<'tcx, O: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Obligation<'tcx
|
|||
}
|
||||
}
|
||||
|
||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
self.predicate.visit_with(visitor)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue