Skip to content

Commit

Permalink
Set the default BreakTy to !
Browse files Browse the repository at this point in the history
  • Loading branch information
LeSeulArtichaut committed Nov 14, 2020
1 parent df6e87c commit 65cdc21
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions compiler/rustc_lint/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,8 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
};

impl<'a, 'tcx> ty::fold::TypeVisitor<'tcx> for ProhibitOpaqueTypes<'a, 'tcx> {
type BreakTy = ();

fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
match ty.kind() {
ty::Opaque(..) => {
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_middle/src/ty/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
pub struct Visitor<F>(F);

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

pub trait TypeVisitor<'tcx>: Sized {
type BreakTy = ();
type BreakTy = !;

fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> ControlFlow<Self::BreakTy> {
t.super_visit_with(self)
Expand Down Expand Up @@ -331,6 +332,8 @@ impl<'tcx> TyCtxt<'tcx> {
where
F: FnMut(ty::Region<'tcx>) -> bool,
{
type BreakTy = ();

fn visit_binder<T: TypeFoldable<'tcx>>(
&mut self,
t: &Binder<T>,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_mir/src/interpret/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ where
};

impl<'tcx> TypeVisitor<'tcx> for UsedParamsNeedSubstVisitor<'tcx> {
type BreakTy = ();

fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
if !c.needs_subst() {
return ControlFlow::CONTINUE;
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_mir/src/monomorphize/polymorphize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ struct HasUsedGenericParams<'a> {
}

impl<'a, 'tcx> TypeVisitor<'tcx> for HasUsedGenericParams<'a> {
type BreakTy = ();

fn visit_const(&mut self, c: &'tcx Const<'tcx>) -> ControlFlow<Self::BreakTy> {
debug!("visit_const: c={:?}", c);
if !c.has_param_types_or_consts() {
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_trait_selection/src/traits/object_safety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,8 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeFoldable<'tcx>>(
}

impl<'tcx> TypeVisitor<'tcx> for IllegalSelfTypeVisitor<'tcx> {
type BreakTy = ();

fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
match t.kind() {
ty::Param(_) => {
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_typeck/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,8 @@ fn check_where_clauses<'tcx, 'fcx>(
params: FxHashSet<u32>,
}
impl<'tcx> ty::fold::TypeVisitor<'tcx> for CountParams {
type BreakTy = ();

fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
if let ty::Param(param) = t.kind() {
self.params.insert(param.index);
Expand Down
2 changes: 2 additions & 0 deletions src/tools/clippy/clippy_lints/src/redundant_clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,8 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> {
struct ContainsRegion;

impl TypeVisitor<'_> for ContainsRegion {
type BreakTy = ();

fn visit_region(&mut self, _: ty::Region<'_>) -> ControlFlow<Self::BreakTy> {
ControlFlow::BREAK
}
Expand Down

0 comments on commit 65cdc21

Please sign in to comment.