Skip to content

Commit 2909b1c

Browse files
committed
Remove unit_types::utils::is_unit
1 parent 4d9f8b2 commit 2909b1c

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

clippy_lints/src/unit_types/let_unit_value.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ use rustc_middle::lint::in_external_macro;
66
use crate::utils::source::snippet_with_macro_callsite;
77
use crate::utils::{higher, span_lint_and_then};
88

9-
use super::{utils, LET_UNIT_VALUE};
9+
use super::LET_UNIT_VALUE;
1010

1111
pub(super) fn check(cx: &LateContext<'_>, stmt: &Stmt<'_>) {
1212
if let StmtKind::Local(ref local) = stmt.kind {
13-
if utils::is_unit(cx.typeck_results().pat_ty(&local.pat)) {
13+
if cx.typeck_results().pat_ty(&local.pat).is_unit() {
1414
if in_external_macro(cx.sess(), stmt.span) || local.pat.span.from_expansion() {
1515
return;
1616
}

clippy_lints/src/unit_types/unit_arg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
3636
let args_to_recover = args
3737
.iter()
3838
.filter(|arg| {
39-
if utils::is_unit(cx.typeck_results().expr_ty(arg)) && !utils::is_unit_literal(arg) {
39+
if cx.typeck_results().expr_ty(arg).is_unit() && !utils::is_unit_literal(arg) {
4040
!matches!(
4141
&arg.kind,
4242
ExprKind::Match(.., MatchSource::TryDesugar) | ExprKind::Path(..)

clippy_lints/src/unit_types/unit_cmp.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ use rustc_span::hygiene::{ExpnKind, MacroKind};
44

55
use crate::utils::span_lint;
66

7-
use super::{utils, UNIT_CMP};
7+
use super::UNIT_CMP;
88

99
pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
1010
if expr.span.from_expansion() {
1111
if let Some(callee) = expr.span.source_callee() {
1212
if let ExpnKind::Macro(MacroKind::Bang, symbol) = callee.kind {
1313
if let ExprKind::Binary(ref cmp, ref left, _) = expr.kind {
1414
let op = cmp.node;
15-
if op.is_comparison() && utils::is_unit(cx.typeck_results().expr_ty(left)) {
15+
if op.is_comparison() && cx.typeck_results().expr_ty(left).is_unit() {
1616
let result = match &*symbol.as_str() {
1717
"assert_eq" | "debug_assert_eq" => "succeed",
1818
"assert_ne" | "debug_assert_ne" => "fail",
@@ -37,7 +37,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
3737

3838
if let ExprKind::Binary(ref cmp, ref left, _) = expr.kind {
3939
let op = cmp.node;
40-
if op.is_comparison() && utils::is_unit(cx.typeck_results().expr_ty(left)) {
40+
if op.is_comparison() && cx.typeck_results().expr_ty(left).is_unit() {
4141
let result = match op {
4242
BinOpKind::Eq | BinOpKind::Le | BinOpKind::Ge => "true",
4343
_ => "false",

clippy_lints/src/unit_types/utils.rs

-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
use rustc_hir::{Expr, ExprKind};
2-
use rustc_middle::ty::{self, Ty};
3-
4-
pub(super) fn is_unit(ty: Ty<'_>) -> bool {
5-
matches!(ty.kind(), ty::Tuple(slice) if slice.is_empty())
6-
}
72

83
pub(super) fn is_unit_literal(expr: &Expr<'_>) -> bool {
94
matches!(expr.kind, ExprKind::Tup(ref slice) if slice.is_empty())

0 commit comments

Comments
 (0)