1
Fork 0

TypeVisitor: use ControlFlow in rustc_{infer,lint,trait_selection}

This commit is contained in:
LeSeulArtichaut 2020-10-21 14:24:35 +02:00
parent 2c85b6fae0
commit 4fe735b320
13 changed files with 106 additions and 82 deletions

View file

@ -37,6 +37,7 @@
#![feature(or_patterns)]
#![feature(half_open_range_patterns)]
#![feature(exclusive_range_pattern)]
#![feature(control_flow_enum)]
#![recursion_limit = "256"]
#[macro_use]

View file

@ -18,6 +18,7 @@ use rustc_target::abi::{Integer, LayoutOf, TagEncoding, VariantIdx, Variants};
use rustc_target::spec::abi::Abi as SpecAbi;
use std::cmp;
use std::ops::ControlFlow;
use tracing::debug;
declare_lint! {
@ -1135,11 +1136,11 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
};
impl<'a, 'tcx> ty::fold::TypeVisitor<'tcx> for ProhibitOpaqueTypes<'a, 'tcx> {
fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool {
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<(), ()> {
match ty.kind() {
ty::Opaque(..) => {
self.ty = Some(ty);
true
ControlFlow::BREAK
}
// Consider opaque types within projections FFI-safe if they do not normalize
// to more opaque types.
@ -1148,7 +1149,11 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
// If `ty` is a opaque type directly then `super_visit_with` won't invoke
// this function again.
if ty.has_opaque_types() { self.visit_ty(ty) } else { false }
if ty.has_opaque_types() {
self.visit_ty(ty)
} else {
ControlFlow::CONTINUE
}
}
_ => ty.super_visit_with(self),
}