Skip to content

Commit 65cdc21

Browse files
Set the default BreakTy to !
1 parent df6e87c commit 65cdc21

File tree

7 files changed

+16
-1
lines changed

7 files changed

+16
-1
lines changed

compiler/rustc_lint/src/types.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,8 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
11351135
};
11361136

11371137
impl<'a, 'tcx> ty::fold::TypeVisitor<'tcx> for ProhibitOpaqueTypes<'a, 'tcx> {
1138+
type BreakTy = ();
1139+
11381140
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
11391141
match ty.kind() {
11401142
ty::Opaque(..) => {

compiler/rustc_middle/src/ty/fold.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
148148
pub struct Visitor<F>(F);
149149

150150
impl<'tcx, F: FnMut(Ty<'tcx>) -> ControlFlow<()>> TypeVisitor<'tcx> for Visitor<F> {
151+
type BreakTy = ();
151152
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<()> {
152153
self.0(ty)
153154
}
@@ -195,7 +196,7 @@ pub trait TypeFolder<'tcx>: Sized {
195196
}
196197

197198
pub trait TypeVisitor<'tcx>: Sized {
198-
type BreakTy = ();
199+
type BreakTy = !;
199200

200201
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> ControlFlow<Self::BreakTy> {
201202
t.super_visit_with(self)
@@ -331,6 +332,8 @@ impl<'tcx> TyCtxt<'tcx> {
331332
where
332333
F: FnMut(ty::Region<'tcx>) -> bool,
333334
{
335+
type BreakTy = ();
336+
334337
fn visit_binder<T: TypeFoldable<'tcx>>(
335338
&mut self,
336339
t: &Binder<T>,

compiler/rustc_mir/src/interpret/util.rs

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ where
1818
};
1919

2020
impl<'tcx> TypeVisitor<'tcx> for UsedParamsNeedSubstVisitor<'tcx> {
21+
type BreakTy = ();
22+
2123
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
2224
if !c.needs_subst() {
2325
return ControlFlow::CONTINUE;

compiler/rustc_mir/src/monomorphize/polymorphize.rs

+2
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ struct HasUsedGenericParams<'a> {
318318
}
319319

320320
impl<'a, 'tcx> TypeVisitor<'tcx> for HasUsedGenericParams<'a> {
321+
type BreakTy = ();
322+
321323
fn visit_const(&mut self, c: &'tcx Const<'tcx>) -> ControlFlow<Self::BreakTy> {
322324
debug!("visit_const: c={:?}", c);
323325
if !c.has_param_types_or_consts() {

compiler/rustc_trait_selection/src/traits/object_safety.rs

+2
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeFoldable<'tcx>>(
771771
}
772772

773773
impl<'tcx> TypeVisitor<'tcx> for IllegalSelfTypeVisitor<'tcx> {
774+
type BreakTy = ();
775+
774776
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
775777
match t.kind() {
776778
ty::Param(_) => {

compiler/rustc_typeck/src/check/wfcheck.rs

+2
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,8 @@ fn check_where_clauses<'tcx, 'fcx>(
800800
params: FxHashSet<u32>,
801801
}
802802
impl<'tcx> ty::fold::TypeVisitor<'tcx> for CountParams {
803+
type BreakTy = ();
804+
803805
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
804806
if let ty::Param(param) = t.kind() {
805807
self.params.insert(param.index);

src/tools/clippy/clippy_lints/src/redundant_clone.rs

+2
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,8 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> {
563563
struct ContainsRegion;
564564

565565
impl TypeVisitor<'_> for ContainsRegion {
566+
type BreakTy = ();
567+
566568
fn visit_region(&mut self, _: ty::Region<'_>) -> ControlFlow<Self::BreakTy> {
567569
ControlFlow::BREAK
568570
}

0 commit comments

Comments
 (0)