Skip to content

Commit

Permalink
Support hir::ExprKind::Become in clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
WaffleLapkin committed Jun 26, 2023
1 parent ccb71ff commit e38576a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/tools/clippy/clippy_lints/src/loops/never_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ fn never_loop_expr(expr: &Expr<'_>, ignore_ids: &mut Vec<HirId>, main_loop_id: H
NeverLoopResult::AlwaysBreak,
)
}),
ExprKind::Become(e) => {
combine_seq(
never_loop_expr(e, ignore_ids, main_loop_id),
NeverLoopResult::AlwaysBreak,
)
}
ExprKind::InlineAsm(asm) => asm
.operands
.iter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ impl<'a, 'tcx> Visitor<'tcx> for SigDropHelper<'a, 'tcx> {
ExprKind::Field(..) |
ExprKind::Index(..) |
ExprKind::Ret(..) |
ExprKind::Become(..) |
ExprKind::Repeat(..) |
ExprKind::Yield(..) => walk_expr(self, ex),
ExprKind::AddrOf(_, _, _) |
Expand Down
5 changes: 5 additions & 0 deletions src/tools/clippy/clippy_lints/src/utils/author.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,11 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
kind!("Ret({value})");
value.if_some(|e| self.expr(e));
},
ExprKind::Become(value) => {
bind!(self, value);
kind!("Become({value})");
self.expr(value);
},
ExprKind::InlineAsm(_) => {
kind!("InlineAsm(_)");
out!("// unimplemented: `ExprKind::InlineAsm` is not further destructured at the moment");
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/clippy_utils/src/eager_or_lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ fn expr_eagerness<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> EagernessS
ExprKind::Break(..)
| ExprKind::Continue(_)
| ExprKind::Ret(_)
| ExprKind::Become(_)
| ExprKind::InlineAsm(_)
| ExprKind::Yield(..)
| ExprKind::Err(_) => {
Expand Down
3 changes: 3 additions & 0 deletions src/tools/clippy/clippy_utils/src/hir_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,9 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
self.hash_expr(e);
}
},
ExprKind::Become(f) => {
self.hash_expr(f);
},
ExprKind::Path(ref qpath) => {
self.hash_qpath(qpath);
},
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/clippy_utils/src/sugg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ impl<'a> Sugg<'a> {
| hir::ExprKind::Path(..)
| hir::ExprKind::Repeat(..)
| hir::ExprKind::Ret(..)
| hir::ExprKind::Become(..)
| hir::ExprKind::Struct(..)
| hir::ExprKind::Tup(..)
| hir::ExprKind::Err(_) => Sugg::NonParen(get_snippet(expr.span)),
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/clippy_utils/src/visitors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@ pub fn for_each_unconsumed_temporary<'tcx, B>(
// Either drops temporaries, jumps out of the current expression, or has no sub expression.
ExprKind::DropTemps(_)
| ExprKind::Ret(_)
| ExprKind::Become(_)
| ExprKind::Break(..)
| ExprKind::Yield(..)
| ExprKind::Block(..)
Expand Down

0 comments on commit e38576a

Please sign in to comment.