Stop using `BREAK` & `CONTINUE` in compiler

Switching them to `Break(())` and `Continue(())` instead.

libs-api would like to remove these constants, so stop using them in compiler to make the removal PR later smaller.
This commit is contained in:
Scott McMurray 2023-01-17 23:17:13 -08:00
parent e08b379d5d
commit 925dc37313
31 changed files with 110 additions and 106 deletions

View File

@ -225,7 +225,7 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> {
/// `align_offset(ptr, target_align)` needs special handling in const eval, because the pointer
/// may not have an address.
///
/// If `ptr` does have a known address, then we return `CONTINUE` and the function call should
/// If `ptr` does have a known address, then we return `Continue(())` and the function call should
/// proceed as normal.
///
/// If `ptr` doesn't have an address, but its underlying allocation's alignment is at most
@ -273,18 +273,18 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> {
ret,
StackPopUnwind::NotAllowed,
)?;
Ok(ControlFlow::BREAK)
Ok(ControlFlow::Break(()))
} else {
// Not alignable in const, return `usize::MAX`.
let usize_max = Scalar::from_machine_usize(self.machine_usize_max(), self);
self.write_scalar(usize_max, dest)?;
self.return_to_block(ret)?;
Ok(ControlFlow::BREAK)
Ok(ControlFlow::Break(()))
}
}
Err(_addr) => {
// The pointer has an address, continue with function call.
Ok(ControlFlow::CONTINUE)
Ok(ControlFlow::Continue(()))
}
}
}

View File

@ -26,7 +26,7 @@ where
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
if !ty.needs_subst() {
return ControlFlow::CONTINUE;
return ControlFlow::Continue(());
}
match *ty.kind() {
@ -48,7 +48,7 @@ where
return subst.visit_with(self);
}
}
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
_ => ty.super_visit_with(self),
}

View File

@ -317,12 +317,12 @@ where
_node: G::Node,
_prior_status: Option<NodeStatus>,
) -> ControlFlow<Self::BreakVal> {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
/// Called after all nodes reachable from this one have been examined.
fn node_settled(&mut self, _node: G::Node) -> ControlFlow<Self::BreakVal> {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
/// Behave as if no edges exist from `source` to `target`.
@ -346,8 +346,8 @@ where
prior_status: Option<NodeStatus>,
) -> ControlFlow<Self::BreakVal> {
match prior_status {
Some(NodeStatus::Visited) => ControlFlow::BREAK,
_ => ControlFlow::CONTINUE,
Some(NodeStatus::Visited) => ControlFlow::Break(()),
_ => ControlFlow::Continue(()),
}
}
}

View File

@ -267,7 +267,7 @@ pub(super) fn check_opaque_for_inheriting_lifetimes(
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
debug!(?t, "root_visit_ty");
if t == self.opaque_identity_ty {
ControlFlow::CONTINUE
ControlFlow::Continue(())
} else {
t.visit_with(&mut ConstrainOpaqueTypeRegionVisitor {
tcx: self.tcx,
@ -282,7 +282,7 @@ pub(super) fn check_opaque_for_inheriting_lifetimes(
if self.references_parent_regions {
ControlFlow::Break(t)
} else {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
}
@ -1439,7 +1439,7 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'_>, def_id: LocalDefId, span: Span) -> E
match *t.kind() {
ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => {
self.0.push(def);
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
_ => t.super_visit_with(self),
}

View File

@ -1428,7 +1428,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
}
fn visit_region(&mut self, _: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
ControlFlow::BREAK
ControlFlow::Break(())
}
fn visit_const(&mut self, c: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {

View File

@ -416,13 +416,13 @@ fn fast_reject_auto_impl<'tcx>(tcx: TyCtxt<'tcx>, trait_def_id: DefId, self_ty:
if t != self.self_ty_root {
for impl_def_id in tcx.non_blanket_impls_for_ty(self.trait_def_id, t) {
match tcx.impl_polarity(impl_def_id) {
ImplPolarity::Negative => return ControlFlow::BREAK,
ImplPolarity::Negative => return ControlFlow::Break(()),
ImplPolarity::Reservation => {}
// FIXME(@lcnr): That's probably not good enough, idk
//
// We might just want to take the rustdoc code and somehow avoid
// explicit impls for `Self`.
ImplPolarity::Positive => return ControlFlow::CONTINUE,
ImplPolarity::Positive => return ControlFlow::Continue(()),
}
}
}
@ -440,7 +440,7 @@ fn fast_reject_auto_impl<'tcx>(tcx: TyCtxt<'tcx>, trait_def_id: DefId, self_ty:
}
}
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
_ => t.super_visit_with(self),
}

View File

@ -61,7 +61,7 @@ impl<'tcx> TypeVisitor<'tcx> for ParameterCollector {
match *t.kind() {
ty::Alias(ty::Projection, ..) if !self.include_nonconstraining => {
// projections are not injective
return ControlFlow::CONTINUE;
return ControlFlow::Continue(());
}
ty::Param(data) => {
self.parameters.push(Parameter::from(data));
@ -76,7 +76,7 @@ impl<'tcx> TypeVisitor<'tcx> for ParameterCollector {
if let ty::ReEarlyBound(data) = *r {
self.parameters.push(Parameter::from(data));
}
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
fn visit_const(&mut self, c: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {

View File

@ -92,7 +92,7 @@ fn variance_of_opaque(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Varianc
a.visit_with(self)?;
}
}
ControlFlow::CONTINUE
ControlFlow::Continue(())
} else {
substs.visit_with(self)
}

View File

@ -236,7 +236,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
if t == self.expected_ty {
ControlFlow::BREAK
ControlFlow::Break(())
} else {
t.super_visit_with(self)
}

View File

@ -543,7 +543,7 @@ impl<'tcx> TypeVisitor<'tcx> for TraitObjectVisitor {
if let Some(def_id) = preds.principal_def_id() {
self.0.insert(def_id);
}
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
_ => t.super_visit_with(self),
}

View File

@ -849,7 +849,7 @@ impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> {
t.super_visit_with(self);
self.target_index.shift_out(1);
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
@ -863,7 +863,7 @@ impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> {
_ => {}
}
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}

View File

@ -440,16 +440,16 @@ where
t: &ty::Binder<'tcx, T>,
) -> ControlFlow<Self::BreakTy> {
t.super_visit_with(self);
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
match *r {
// ignore bound regions, keep visiting
ty::ReLateBound(_, _) => ControlFlow::CONTINUE,
ty::ReLateBound(_, _) => ControlFlow::Continue(()),
_ => {
(self.op)(r);
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
}
@ -457,7 +457,7 @@ where
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
// We're only interested in types involving regions
if !ty.flags().intersects(ty::TypeFlags::HAS_FREE_REGIONS) {
return ControlFlow::CONTINUE;
return ControlFlow::Continue(());
}
match ty.kind() {
@ -507,7 +507,7 @@ where
}
}
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}

View File

@ -147,7 +147,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeOrConstFinder<'a, 'tcx> {
} else if !t.has_non_region_infer() {
// All const/type variables in inference types must already be resolved,
// no need to visit the contents.
ControlFlow::CONTINUE
ControlFlow::Continue(())
} else {
// Otherwise, keep visiting.
t.super_visit_with(self)
@ -178,7 +178,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeOrConstFinder<'a, 'tcx> {
} else if !ct.has_non_region_infer() {
// All const/type variables in inference types must already be resolved,
// no need to visit the contents.
ControlFlow::CONTINUE
ControlFlow::Continue(())
} else {
// Otherwise, keep visiting.
ct.super_visit_with(self)

View File

@ -1147,7 +1147,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
if !ty.has_opaque_types() {
return ControlFlow::CONTINUE;
return ControlFlow::Continue(());
}
if let ty::Alias(ty::Opaque, ..) = ty.kind() {

View File

@ -26,7 +26,7 @@ pub fn type_visitable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:
__visitor: &mut __V
) -> ::std::ops::ControlFlow<__V::BreakTy> {
match *self { #body_visit }
::std::ops::ControlFlow::CONTINUE
::std::ops::ControlFlow::Continue(())
}
},
)

View File

@ -93,7 +93,7 @@ macro_rules! TrivialTypeTraversalImpls {
_: &mut F)
-> ::std::ops::ControlFlow<F::BreakTy>
{
::std::ops::ControlFlow::CONTINUE
::std::ops::ControlFlow::Continue(())
}
}
)+
@ -219,7 +219,7 @@ macro_rules! EnumTypeTraversalImpl {
$($crate::ty::visit::TypeVisitable::visit_with(
$variant_arg, $visitor
)?;)*
::std::ops::ControlFlow::CONTINUE
::std::ops::ControlFlow::Continue(())
}
$($output)*
)
@ -237,7 +237,7 @@ macro_rules! EnumTypeTraversalImpl {
$($crate::ty::visit::TypeVisitable::visit_with(
$variant_arg, $visitor
)?;)*
::std::ops::ControlFlow::CONTINUE
::std::ops::ControlFlow::Continue(())
}
$($output)*
)
@ -251,7 +251,7 @@ macro_rules! EnumTypeTraversalImpl {
@VisitVariants($this, $visitor)
input($($input)*)
output(
$variant => { ::std::ops::ControlFlow::CONTINUE }
$variant => { ::std::ops::ControlFlow::Continue(()) }
$($output)*
)
)

View File

@ -4,6 +4,6 @@ use super::*;
impl<'tcx, R: Idx, C: Idx> TypeVisitable<'tcx> for BitMatrix<R, C> {
fn visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<V::BreakTy> {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}

View File

@ -2481,7 +2481,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
if not_previously_inserted {
ty.super_visit_with(self)
} else {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
}

View File

@ -367,7 +367,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::AdtDef<'tcx> {
impl<'tcx> TypeVisitable<'tcx> for ty::AdtDef<'tcx> {
fn visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> ControlFlow<V::BreakTy> {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
@ -714,7 +714,7 @@ impl<'tcx> TypeSuperVisitable<'tcx> for Ty<'tcx> {
| ty::Placeholder(..)
| ty::Param(..)
| ty::Never
| ty::Foreign(..) => ControlFlow::CONTINUE,
| ty::Foreign(..) => ControlFlow::Continue(()),
}
}
}
@ -742,7 +742,7 @@ impl<'tcx> TypeSuperFoldable<'tcx> for ty::Region<'tcx> {
impl<'tcx> TypeSuperVisitable<'tcx> for ty::Region<'tcx> {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> ControlFlow<V::BreakTy> {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
@ -844,7 +844,7 @@ impl<'tcx> TypeFoldable<'tcx> for InferConst<'tcx> {
impl<'tcx> TypeVisitable<'tcx> for InferConst<'tcx> {
fn visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> ControlFlow<V::BreakTy> {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}

View File

@ -2015,7 +2015,7 @@ impl<'tcx> Ty<'tcx> {
type BreakTy = ();
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
if self.0 == t { ControlFlow::BREAK } else { t.super_visit_with(self) }
if self.0 == t { ControlFlow::Break(()) } else { t.super_visit_with(self) }
}
}

View File

@ -294,13 +294,13 @@ impl<'tcx> TyCtxt<'tcx> {
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
match *r {
ty::ReLateBound(debruijn, _) if debruijn < self.outer_index => {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
_ => {
if (self.callback)(r) {
ControlFlow::BREAK
ControlFlow::Break(())
} else {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
}
@ -311,7 +311,7 @@ impl<'tcx> TyCtxt<'tcx> {
if ty.flags().intersects(TypeFlags::HAS_FREE_REGIONS) {
ty.super_visit_with(self)
} else {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
}
@ -394,7 +394,7 @@ impl<'tcx> TypeVisitor<'tcx> for ValidateBoundVars<'tcx> {
if t.outer_exclusive_binder() < self.binder_index
|| !self.visited.insert((self.binder_index, t))
{
return ControlFlow::BREAK;
return ControlFlow::Break(());
}
match *t.kind() {
ty::Bound(debruijn, bound_ty) if debruijn == self.binder_index => {
@ -512,7 +512,7 @@ impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
if t.outer_exclusive_binder() > self.outer_index {
ControlFlow::Break(FoundEscapingVars)
} else {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
@ -524,7 +524,7 @@ impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
if r.bound_at_or_above_binder(self.outer_index) {
ControlFlow::Break(FoundEscapingVars)
} else {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
@ -547,7 +547,7 @@ impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
if predicate.outer_exclusive_binder() > self.outer_index {
ControlFlow::Break(FoundEscapingVars)
} else {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
}
@ -575,7 +575,7 @@ impl<'tcx> TypeVisitor<'tcx> for HasTypeFlagsVisitor {
if flags.intersects(self.flags) {
ControlFlow::Break(FoundFlags)
} else {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
@ -585,7 +585,7 @@ impl<'tcx> TypeVisitor<'tcx> for HasTypeFlagsVisitor {
if flags.intersects(self.flags) {
ControlFlow::Break(FoundFlags)
} else {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
@ -596,7 +596,7 @@ impl<'tcx> TypeVisitor<'tcx> for HasTypeFlagsVisitor {
if flags.intersects(self.flags) {
ControlFlow::Break(FoundFlags)
} else {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
@ -605,7 +605,7 @@ impl<'tcx> TypeVisitor<'tcx> for HasTypeFlagsVisitor {
if predicate.flags().intersects(self.flags) {
ControlFlow::Break(FoundFlags)
} else {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
}
@ -653,7 +653,7 @@ impl<'tcx> TypeVisitor<'tcx> for LateBoundRegionsCollector {
// in the normalized form
if self.just_constrained {
if let ty::Alias(..) = t.kind() {
return ControlFlow::CONTINUE;
return ControlFlow::Continue(());
}
}
@ -666,7 +666,7 @@ impl<'tcx> TypeVisitor<'tcx> for LateBoundRegionsCollector {
// in the normalized form
if self.just_constrained {
if let ty::ConstKind::Unevaluated(..) = c.kind() {
return ControlFlow::CONTINUE;
return ControlFlow::Continue(());
}
}
@ -679,7 +679,7 @@ impl<'tcx> TypeVisitor<'tcx> for LateBoundRegionsCollector {
self.regions.insert(br.kind);
}
}
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
@ -726,6 +726,6 @@ impl<'tcx> TypeVisitor<'tcx> for MaxUniverse {
);
}
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}

View File

@ -118,7 +118,7 @@ impl<'mir, 'tcx> TriColorVisitor<BasicBlocks<'tcx>> for Search<'mir, 'tcx> {
// A diverging InlineAsm is treated as non-recursing
TerminatorKind::InlineAsm { destination, .. } => {
if destination.is_some() {
ControlFlow::CONTINUE
ControlFlow::Continue(())
} else {
ControlFlow::Break(NonRecursive)
}
@ -132,7 +132,7 @@ impl<'mir, 'tcx> TriColorVisitor<BasicBlocks<'tcx>> for Search<'mir, 'tcx> {
| TerminatorKind::FalseEdge { .. }
| TerminatorKind::FalseUnwind { .. }
| TerminatorKind::Goto { .. }
| TerminatorKind::SwitchInt { .. } => ControlFlow::CONTINUE,
| TerminatorKind::SwitchInt { .. } => ControlFlow::Continue(()),
}
}
@ -145,7 +145,7 @@ impl<'mir, 'tcx> TriColorVisitor<BasicBlocks<'tcx>> for Search<'mir, 'tcx> {
}
}
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
fn ignore_edge(&mut self, bb: BasicBlock, target: BasicBlock) -> bool {

View File

@ -300,20 +300,20 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> {
#[instrument(level = "debug", skip(self))]
fn visit_const(&mut self, c: Const<'tcx>) -> ControlFlow<Self::BreakTy> {
if !c.has_non_region_param() {
return ControlFlow::CONTINUE;
return ControlFlow::Continue(());
}
match c.kind() {
ty::ConstKind::Param(param) => {
debug!(?param);
self.unused_parameters.mark_used(param.index);
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs })
if matches!(self.tcx.def_kind(def.did), DefKind::AnonConst) =>
{
self.visit_child_body(def.did, substs);
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
_ => c.super_visit_with(self),
}
@ -322,7 +322,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> {
#[instrument(level = "debug", skip(self))]
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
if !ty.has_non_region_param() {
return ControlFlow::CONTINUE;
return ControlFlow::Continue(());
}
match *ty.kind() {
@ -330,18 +330,18 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> {
debug!(?def_id);
// Avoid cycle errors with generators.
if def_id == self.def_id {
return ControlFlow::CONTINUE;
return ControlFlow::Continue(());
}
// Consider any generic parameters used by any closures/generators as used in the
// parent.
self.visit_child_body(def_id, substs);
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
ty::Param(param) => {
debug!(?param);
self.unused_parameters.mark_used(param.index);
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
_ => ty.super_visit_with(self),
}

View File

@ -112,7 +112,11 @@ where
fn visit_trait(&mut self, trait_ref: TraitRef<'tcx>) -> ControlFlow<V::BreakTy> {
let TraitRef { def_id, substs, .. } = trait_ref;
self.def_id_visitor.visit_def_id(def_id, "trait", &trait_ref.print_only_trait_path())?;
if self.def_id_visitor.shallow() { ControlFlow::CONTINUE } else { substs.visit_with(self) }
if self.def_id_visitor.shallow() {
ControlFlow::Continue(())
} else {
substs.visit_with(self)
}
}
fn visit_projection_ty(&mut self, projection: ty::AliasTy<'tcx>) -> ControlFlow<V::BreakTy> {
@ -131,7 +135,7 @@ where
};
self.visit_trait(trait_ref)?;
if self.def_id_visitor.shallow() {
ControlFlow::CONTINUE
ControlFlow::Continue(())
} else {
assoc_substs.iter().try_for_each(|subst| subst.visit_with(self))
}
@ -155,7 +159,7 @@ where
ty,
_region,
))) => ty.visit_with(self),
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..)) => ControlFlow::CONTINUE,
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..)) => ControlFlow::Continue(()),
ty::PredicateKind::ConstEvaluatable(ct) => ct.visit_with(self),
ty::PredicateKind::WellFormed(arg) => arg.visit_with(self),
_ => bug!("unexpected predicate: {:?}", predicate),
@ -189,7 +193,7 @@ where
| ty::Generator(def_id, ..) => {
self.def_id_visitor.visit_def_id(def_id, "type", &ty)?;
if self.def_id_visitor.shallow() {
return ControlFlow::CONTINUE;
return ControlFlow::Continue(());
}
// Default type visitor doesn't visit signatures of fn types.
// Something like `fn() -> Priv {my_func}` is considered a private type even if
@ -214,7 +218,7 @@ where
// as visible/reachable even if both `Type` and `Trait` are private.
// Ideally, associated types should be substituted in the same way as
// free type aliases, but this isn't done yet.
return ControlFlow::CONTINUE;
return ControlFlow::Continue(());
}
// This will also visit substs if necessary, so we don't need to recurse.
return self.visit_projection_ty(proj);
@ -274,7 +278,7 @@ where
}
if self.def_id_visitor.shallow() {
ControlFlow::CONTINUE
ControlFlow::Continue(())
} else {
ty.super_visit_with(self)
}
@ -319,7 +323,7 @@ impl<'a, 'tcx, VL: VisibilityLike> DefIdVisitor<'tcx> for FindMin<'a, 'tcx, VL>
if let Some(def_id) = def_id.as_local() {
self.min = VL::new_min(self, def_id);
}
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
@ -881,7 +885,7 @@ impl<'tcx> DefIdVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'_, 'tcx>
self.ev.update(def_id, self.level);
}
}
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
@ -1368,9 +1372,9 @@ impl<'tcx> DefIdVisitor<'tcx> for TypePrivacyVisitor<'tcx> {
descr: &dyn fmt::Display,
) -> ControlFlow<Self::BreakTy> {
if self.check_def_id(def_id, kind, descr) {
ControlFlow::BREAK
ControlFlow::Break(())
} else {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
}
@ -1865,9 +1869,9 @@ impl<'tcx> DefIdVisitor<'tcx> for SearchInterfaceForPrivateItemsVisitor<'tcx> {
descr: &dyn fmt::Display,
) -> ControlFlow<Self::BreakTy> {
if self.check_def_id(def_id, kind, descr) {
ControlFlow::BREAK
ControlFlow::Break(())
} else {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
}

View File

@ -614,12 +614,12 @@ impl<'tcx> OrphanChecker<'tcx> {
fn found_non_local_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<OrphanCheckEarlyExit<'tcx>> {
self.non_local_tys.push((t, self.in_self_ty));
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
fn found_param_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<OrphanCheckEarlyExit<'tcx>> {
if self.search_first_local_ty {
ControlFlow::CONTINUE
ControlFlow::Continue(())
} else {
ControlFlow::Break(OrphanCheckEarlyExit::ParamTy(t))
}
@ -641,7 +641,7 @@ enum OrphanCheckEarlyExit<'tcx> {
impl<'tcx> TypeVisitor<'tcx> for OrphanChecker<'tcx> {
type BreakTy = OrphanCheckEarlyExit<'tcx>;
fn visit_region(&mut self, _r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
@ -756,6 +756,6 @@ impl<'tcx> TypeVisitor<'tcx> for OrphanChecker<'tcx> {
/// parameters, allowing uncovered const parameters in impls seems more useful
/// than allowing `impl<T> Trait<local_fn_ptr, T> for i32` to compile.
fn visit_const(&mut self, _c: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}

View File

@ -198,7 +198,7 @@ fn satisfied_from_param_env<'tcx>(
// If we start allowing directly writing `ConstKind::Expr` without an intermediate anon const
// this will be incorrect. It might be worth investigating making `predicates_of` elaborate
// all of the `ConstEvaluatable` bounds rather than having a visitor here.
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
}

View File

@ -2932,7 +2932,7 @@ impl<'tcx> ty::TypeVisitor<'tcx> for HasNumericInferVisitor {
if matches!(ty.kind(), ty::Infer(ty::FloatVar(_) | ty::IntVar(_))) {
ControlFlow::Break(())
} else {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
}

View File

@ -493,7 +493,7 @@ fn is_impossible_method(tcx: TyCtxt<'_>, (impl_def_id, trait_item_def_id): (DefI
&& let param_def_id = self.generics.type_param(param, self.tcx).def_id
&& self.tcx.parent(param_def_id) == self.trait_item_def_id
{
return ControlFlow::BREAK;
return ControlFlow::Break(());
}
t.super_visit_with(self)
}
@ -502,7 +502,7 @@ fn is_impossible_method(tcx: TyCtxt<'_>, (impl_def_id, trait_item_def_id): (DefI
&& let param_def_id = self.generics.region_param(&param, self.tcx).def_id
&& self.tcx.parent(param_def_id) == self.trait_item_def_id
{
return ControlFlow::BREAK;
return ControlFlow::Break(());
}
r.super_visit_with(self)
}
@ -511,7 +511,7 @@ fn is_impossible_method(tcx: TyCtxt<'_>, (impl_def_id, trait_item_def_id): (DefI
&& let param_def_id = self.generics.const_param(&param, self.tcx).def_id
&& self.tcx.parent(param_def_id) == self.trait_item_def_id
{
return ControlFlow::BREAK;
return ControlFlow::Break(());
}
ct.super_visit_with(self)
}

View File

@ -783,16 +783,16 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeVisitable<'tcx>>(
match t.kind() {
ty::Param(_) => {
if t == self.tcx.types.self_param {
ControlFlow::BREAK
ControlFlow::Break(())
} else {
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
}
ty::Alias(ty::Projection, ref data)
if self.tcx.def_kind(data.def_id) == DefKind::ImplTraitPlaceholder =>
{
// We'll deny these later in their own pass
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
ty::Alias(ty::Projection, ref data) => {
// This is a projected type `<Foo as SomeTrait>::X`.
@ -820,7 +820,7 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeVisitable<'tcx>>(
.contains(&data.trait_ref(self.tcx).def_id);
if is_supertrait_of_current_trait {
ControlFlow::CONTINUE // do not walk contained types, do not report error, do collect $200
ControlFlow::Continue(()) // do not walk contained types, do not report error, do collect $200
} else {
t.super_visit_with(self) // DO walk contained types, POSSIBLY reporting an error
}

View File

@ -133,7 +133,7 @@ impl<'tcx> TypeVisitor<'tcx> for MaxEscapingBoundVarVisitor {
.escaping
.max(t.outer_exclusive_binder().as_usize() - self.outer_index.as_usize());
}
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
#[inline]
@ -145,7 +145,7 @@ impl<'tcx> TypeVisitor<'tcx> for MaxEscapingBoundVarVisitor {
}
_ => {}
}
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
fn visit_const(&mut self, ct: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
@ -153,7 +153,7 @@ impl<'tcx> TypeVisitor<'tcx> for MaxEscapingBoundVarVisitor {
ty::ConstKind::Bound(debruijn, _) if debruijn >= self.outer_index => {
self.escaping =
self.escaping.max(debruijn.as_usize() - self.outer_index.as_usize());
ControlFlow::CONTINUE
ControlFlow::Continue(())
}
_ => ct.super_visit_with(self),
}

View File

@ -107,25 +107,25 @@ impl<'tcx> TypeVisitor<'tcx> for Search<'tcx> {
ty::FnDef(..) => {
// Types of formals and return in `fn(_) -> _` are also irrelevant;
// so we do not recur into them via `super_visit_with`
return ControlFlow::CONTINUE;
return ControlFlow::Continue(());
}
ty::Array(_, n)
if { n.try_eval_usize(self.tcx, ty::ParamEnv::reveal_all()) == Some(0) } =>
{
// rust-lang/rust#62336: ignore type of contents
// for empty array.
return ControlFlow::CONTINUE;
return ControlFlow::Continue(());
}
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Str | ty::Never => {
// These primitive types are always structural match.
//
// `Never` is kind of special here, but as it is not inhabitable, this should be fine.
return ControlFlow::CONTINUE;
return ControlFlow::Continue(());
}
ty::FnPtr(..) => {
if !self.adt_const_param {
return ControlFlow::CONTINUE;
return ControlFlow::Continue(());
} else {
return ControlFlow::Break(ty);
}
@ -147,7 +147,7 @@ impl<'tcx> TypeVisitor<'tcx> for Search<'tcx> {
// Even though `NonStructural` does not implement `PartialEq`,
// structural equality on `T` does not recur into the raw
// pointer. Therefore, one can still use `C` in a pattern.
return ControlFlow::CONTINUE;
return ControlFlow::Continue(());
} else {
return ControlFlow::Break(ty);
}
@ -155,7 +155,7 @@ impl<'tcx> TypeVisitor<'tcx> for Search<'tcx> {
ty::Float(_) => {
if !self.adt_const_param {
return ControlFlow::CONTINUE;
return ControlFlow::Continue(());
} else {
return ControlFlow::Break(ty);
}
@ -172,13 +172,13 @@ impl<'tcx> TypeVisitor<'tcx> for Search<'tcx> {
self.tcx.sess.delay_span_bug(self.span, "ty::Error in structural-match check");
// We still want to check other types after encountering an error,
// as this may still emit relevant errors.
return ControlFlow::CONTINUE;
return ControlFlow::Continue(());
}
};
if !self.seen.insert(adt_def.did()) {
debug!("Search already seen adt_def: {:?}", adt_def);
return ControlFlow::CONTINUE;
return ControlFlow::Continue(());
}
if !self.type_marked_structural(ty) {