Remove unit_types::utils::is_unit
This commit is contained in:
parent
6211b49ac1
commit
5a439f5a82
4 changed files with 6 additions and 11 deletions
|
@ -7,11 +7,11 @@ use crate::utils::diagnostics::span_lint_and_then;
|
|||
use crate::utils::higher;
|
||||
use crate::utils::source::snippet_with_macro_callsite;
|
||||
|
||||
use super::{utils, LET_UNIT_VALUE};
|
||||
use super::LET_UNIT_VALUE;
|
||||
|
||||
pub(super) fn check(cx: &LateContext<'_>, stmt: &Stmt<'_>) {
|
||||
if let StmtKind::Local(ref local) = stmt.kind {
|
||||
if utils::is_unit(cx.typeck_results().pat_ty(&local.pat)) {
|
||||
if cx.typeck_results().pat_ty(&local.pat).is_unit() {
|
||||
if in_external_macro(cx.sess(), stmt.span) || local.pat.span.from_expansion() {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
|
|||
let args_to_recover = args
|
||||
.iter()
|
||||
.filter(|arg| {
|
||||
if utils::is_unit(cx.typeck_results().expr_ty(arg)) && !utils::is_unit_literal(arg) {
|
||||
if cx.typeck_results().expr_ty(arg).is_unit() && !utils::is_unit_literal(arg) {
|
||||
!matches!(
|
||||
&arg.kind,
|
||||
ExprKind::Match(.., MatchSource::TryDesugar) | ExprKind::Path(..)
|
||||
|
|
|
@ -4,7 +4,7 @@ use rustc_span::hygiene::{ExpnKind, MacroKind};
|
|||
|
||||
use crate::utils::diagnostics::span_lint;
|
||||
|
||||
use super::{utils, UNIT_CMP};
|
||||
use super::UNIT_CMP;
|
||||
|
||||
pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
|
||||
if expr.span.from_expansion() {
|
||||
|
@ -12,7 +12,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
|
|||
if let ExpnKind::Macro(MacroKind::Bang, symbol) = callee.kind {
|
||||
if let ExprKind::Binary(ref cmp, ref left, _) = expr.kind {
|
||||
let op = cmp.node;
|
||||
if op.is_comparison() && utils::is_unit(cx.typeck_results().expr_ty(left)) {
|
||||
if op.is_comparison() && cx.typeck_results().expr_ty(left).is_unit() {
|
||||
let result = match &*symbol.as_str() {
|
||||
"assert_eq" | "debug_assert_eq" => "succeed",
|
||||
"assert_ne" | "debug_assert_ne" => "fail",
|
||||
|
@ -37,7 +37,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
|
|||
|
||||
if let ExprKind::Binary(ref cmp, ref left, _) = expr.kind {
|
||||
let op = cmp.node;
|
||||
if op.is_comparison() && utils::is_unit(cx.typeck_results().expr_ty(left)) {
|
||||
if op.is_comparison() && cx.typeck_results().expr_ty(left).is_unit() {
|
||||
let result = match op {
|
||||
BinOpKind::Eq | BinOpKind::Le | BinOpKind::Ge => "true",
|
||||
_ => "false",
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
use rustc_hir::{Expr, ExprKind};
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
|
||||
pub(super) fn is_unit(ty: Ty<'_>) -> bool {
|
||||
matches!(ty.kind(), ty::Tuple(slice) if slice.is_empty())
|
||||
}
|
||||
|
||||
pub(super) fn is_unit_literal(expr: &Expr<'_>) -> bool {
|
||||
matches!(expr.kind, ExprKind::Tup(ref slice) if slice.is_empty())
|
||||
|
|
Loading…
Add table
Reference in a new issue