1
Fork 0

TypeVisitor: use ControlFlow in rustc_{mir,privacy,traits,typeck}

This commit is contained in:
LeSeulArtichaut 2020-10-21 14:26:34 +02:00
parent 4fe735b320
commit 61f8182cec
13 changed files with 171 additions and 122 deletions

View file

@ -42,6 +42,7 @@ use rustc_span::def_id::DefId;
use chalk_ir::{FnSig, ForeignDefId};
use rustc_hir::Unsafety;
use std::collections::btree_map::{BTreeMap, Entry};
use std::ops::ControlFlow;
/// Essentially an `Into` with a `&RustInterner` parameter
crate trait LowerInto<'tcx, T> {
@ -897,14 +898,14 @@ impl<'tcx> BoundVarsCollector<'tcx> {
}
impl<'tcx> TypeVisitor<'tcx> for BoundVarsCollector<'tcx> {
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> bool {
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> ControlFlow<(), ()> {
self.binder_index.shift_in(1);
let result = t.super_visit_with(self);
self.binder_index.shift_out(1);
result
}
fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<(), ()> {
match *t.kind() {
ty::Bound(debruijn, bound_ty) if debruijn == self.binder_index => {
match self.parameters.entry(bound_ty.var.as_u32()) {
@ -924,7 +925,7 @@ impl<'tcx> TypeVisitor<'tcx> for BoundVarsCollector<'tcx> {
t.super_visit_with(self)
}
fn visit_region(&mut self, r: Region<'tcx>) -> bool {
fn visit_region(&mut self, r: Region<'tcx>) -> ControlFlow<(), ()> {
match r {
ty::ReLateBound(index, br) if *index == self.binder_index => match br {
ty::BoundRegion::BrNamed(def_id, _name) => {
@ -1114,7 +1115,7 @@ impl PlaceholdersCollector {
}
impl<'tcx> TypeVisitor<'tcx> for PlaceholdersCollector {
fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<(), ()> {
match t.kind() {
ty::Placeholder(p) if p.universe == self.universe_index => {
self.next_ty_placeholder = self.next_ty_placeholder.max(p.name.as_usize() + 1);
@ -1126,7 +1127,7 @@ impl<'tcx> TypeVisitor<'tcx> for PlaceholdersCollector {
t.super_visit_with(self)
}
fn visit_region(&mut self, r: Region<'tcx>) -> bool {
fn visit_region(&mut self, r: Region<'tcx>) -> ControlFlow<(), ()> {
match r {
ty::RePlaceholder(p) if p.universe == self.universe_index => {
if let ty::BoundRegion::BrAnon(anon) = p.name {

View file

@ -4,6 +4,7 @@
#![feature(crate_visibility_modifier)]
#![feature(in_band_lifetimes)]
#![feature(nll)]
#![feature(control_flow_enum)]
#![recursion_limit = "256"]
#[macro_use]