Auto merge of #78182 - LeSeulArtichaut:ty-visitor-contolflow, r=lcnr,oli-obk
TypeVisitor: use `std::ops::ControlFlow` instead of `bool` Implements MCP rust-lang/compiler-team#374. Blocked on FCP in rust-lang/compiler-team#374. r? `@lcnr` cc `@jonas-schievink`
This commit is contained in:
commit
0d033dee3e
38 changed files with 523 additions and 376 deletions
|
@ -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]
|
||||
|
|
|
@ -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),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue