Skip to content

Commit 8dc2278

Browse files
Remove unused functions from ast CoroutineKind
1 parent 594de02 commit 8dc2278

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

Diff for: compiler/rustc_ast/src/ast.rs

-8
Original file line numberDiff line numberDiff line change
@@ -2610,14 +2610,6 @@ impl CoroutineKind {
26102610
}
26112611
}
26122612

2613-
pub fn is_async(self) -> bool {
2614-
matches!(self, CoroutineKind::Async { .. })
2615-
}
2616-
2617-
pub fn is_gen(self) -> bool {
2618-
matches!(self, CoroutineKind::Gen { .. })
2619-
}
2620-
26212613
pub fn closure_id(self) -> NodeId {
26222614
match self {
26232615
CoroutineKind::Async { closure_id, .. }

Diff for: src/tools/clippy/clippy_utils/src/ast_utils.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
221221
) => {
222222
eq_closure_binder(lb, rb)
223223
&& lc == rc
224-
&& la.map_or(false, CoroutineKind::is_async) == ra.map_or(false, CoroutineKind::is_async)
224+
&& eq_coroutine_kind(*la, *ra)
225225
&& lm == rm
226226
&& eq_fn_decl(lf, rf)
227227
&& eq_expr(le, re)
@@ -241,6 +241,16 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
241241
}
242242
}
243243

244+
fn eq_coroutine_kind(a: Option<CoroutineKind>, b: Option<CoroutineKind>) -> bool {
245+
match (a, b) {
246+
(Some(CoroutineKind::Async { .. }), Some(CoroutineKind::Async { .. }))
247+
| (Some(CoroutineKind::Gen { .. }), Some(CoroutineKind::Gen { .. }))
248+
| (Some(CoroutineKind::AsyncGen { .. }), Some(CoroutineKind::AsyncGen { .. }))
249+
| (None, None) => true,
250+
_ => false,
251+
}
252+
}
253+
244254
pub fn eq_field(l: &ExprField, r: &ExprField) -> bool {
245255
l.is_placeholder == r.is_placeholder
246256
&& eq_id(l.ident, r.ident)

0 commit comments

Comments
 (0)