1
Fork 0

Rollup merge of #124624 - WaffleLapkin:old_unit, r=fmease

Use `tcx.types.unit` instead of `Ty::new_unit(tcx)`

I don't think there is any need for the function, given that we can just access the `.types`, similarly to all other primitives?
This commit is contained in:
Matthias Krüger 2024-05-02 19:42:50 +02:00 committed by GitHub
commit d6940fb43d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 51 additions and 57 deletions

View file

@ -1,7 +1,6 @@
use crate::lints::UnitBindingsDiag;
use crate::{LateLintPass, LintContext};
use rustc_hir as hir;
use rustc_middle::ty::Ty;
use rustc_session::{declare_lint, declare_lint_pass};
declare_lint! {
@ -57,8 +56,8 @@ impl<'tcx> LateLintPass<'tcx> for UnitBindings {
&& let Some(init) = local.init
&& let init_ty = tyck_results.expr_ty(init)
&& let local_ty = tyck_results.node_type(local.hir_id)
&& init_ty == Ty::new_unit(cx.tcx)
&& local_ty == Ty::new_unit(cx.tcx)
&& init_ty == cx.tcx.types.unit
&& local_ty == cx.tcx.types.unit
&& local.ty.is_none()
&& !matches!(init.kind, hir::ExprKind::Tup([]))
&& !matches!(local.pat.kind, hir::PatKind::Tuple([], ..))