The clipper :3c
This commit is contained in:
parent
5c4e9401dc
commit
109440b830
42 changed files with 167 additions and 170 deletions
|
|
@ -399,7 +399,7 @@ fn ty_search_pat(ty: &Ty<'_>) -> (Pat, Pat) {
|
|||
TyKind::Tup([head, .., tail]) => (ty_search_pat(head).0, ty_search_pat(tail).1),
|
||||
TyKind::OpaqueDef(..) => (Pat::Str("impl"), Pat::Str("")),
|
||||
TyKind::Path(qpath) => qpath_search_pat(&qpath),
|
||||
TyKind::Infer => (Pat::Str("_"), Pat::Str("_")),
|
||||
TyKind::Infer(()) => (Pat::Str("_"), Pat::Str("_")),
|
||||
TyKind::TraitObject(_, tagged_ptr) if let TraitObjectSyntax::Dyn = tagged_ptr.tag() => (Pat::Str("dyn"), Pat::Str("")),
|
||||
// NOTE: `TraitObject` is incomplete. It will always return true then.
|
||||
_ => (Pat::Str(""), Pat::Str("")),
|
||||
|
|
|
|||
|
|
@ -459,9 +459,9 @@ impl HirEqInterExpr<'_, '_, '_> {
|
|||
|
||||
fn eq_generic_arg(&mut self, left: &GenericArg<'_>, right: &GenericArg<'_>) -> bool {
|
||||
match (left, right) {
|
||||
(GenericArg::Const(l), GenericArg::Const(r)) => self.eq_const_arg(l, r),
|
||||
(GenericArg::Const(l), GenericArg::Const(r)) => self.eq_const_arg(l.as_unambig_ct(), r.as_unambig_ct()),
|
||||
(GenericArg::Lifetime(l_lt), GenericArg::Lifetime(r_lt)) => Self::eq_lifetime(l_lt, r_lt),
|
||||
(GenericArg::Type(l_ty), GenericArg::Type(r_ty)) => self.eq_ty(l_ty, r_ty),
|
||||
(GenericArg::Type(l_ty), GenericArg::Type(r_ty)) => self.eq_ty(l_ty.as_unambig_ty(), r_ty.as_unambig_ty()),
|
||||
(GenericArg::Infer(l_inf), GenericArg::Infer(r_inf)) => self.eq_ty(&l_inf.to_ty(), &r_inf.to_ty()),
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -618,7 +618,7 @@ impl HirEqInterExpr<'_, '_, '_> {
|
|||
},
|
||||
(TyKind::Path(l), TyKind::Path(r)) => self.eq_qpath(l, r),
|
||||
(&TyKind::Tup(l), &TyKind::Tup(r)) => over(l, r, |l, r| self.eq_ty(l, r)),
|
||||
(&TyKind::Infer, &TyKind::Infer) => true,
|
||||
(&TyKind::Infer(()), &TyKind::Infer(())) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
@ -1291,7 +1291,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
|
|||
self.hash_ty(binder.inner_ty);
|
||||
},
|
||||
TyKind::Err(_)
|
||||
| TyKind::Infer
|
||||
| TyKind::Infer(())
|
||||
| TyKind::Never
|
||||
| TyKind::InferDelegation(..)
|
||||
| TyKind::OpaqueDef(_)
|
||||
|
|
@ -1318,8 +1318,8 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
|
|||
for arg in arg_list {
|
||||
match *arg {
|
||||
GenericArg::Lifetime(l) => self.hash_lifetime(l),
|
||||
GenericArg::Type(ty) => self.hash_ty(ty),
|
||||
GenericArg::Const(ca) => self.hash_const_arg(ca),
|
||||
GenericArg::Type(ty) => self.hash_ty(ty.as_unambig_ty()),
|
||||
GenericArg::Const(ca) => self.hash_const_arg(ca.as_unambig_ct()),
|
||||
GenericArg::Infer(ref inf) => self.hash_ty(&inf.to_ty()),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -437,7 +437,7 @@ pub fn qpath_generic_tys<'tcx>(qpath: &QPath<'tcx>) -> impl Iterator<Item = &'tc
|
|||
.map_or(&[][..], |a| a.args)
|
||||
.iter()
|
||||
.filter_map(|a| match a {
|
||||
hir::GenericArg::Type(ty) => Some(*ty),
|
||||
hir::GenericArg::Type(ty) => Some(ty.as_unambig_ty()),
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
|
|
@ -2148,7 +2148,7 @@ fn is_body_identity_function(cx: &LateContext<'_>, func: &Body<'_>) -> bool {
|
|||
pub fn is_expr_untyped_identity_function(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
|
||||
match expr.kind {
|
||||
ExprKind::Closure(&Closure { body, fn_decl, .. })
|
||||
if fn_decl.inputs.iter().all(|ty| matches!(ty.kind, TyKind::Infer)) =>
|
||||
if fn_decl.inputs.iter().all(|ty| matches!(ty.kind, TyKind::Infer(()))) =>
|
||||
{
|
||||
is_body_identity_function(cx, cx.tcx.hir().body(body))
|
||||
},
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
use crate::def_path_res;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::intravisit::{Visitor, walk_qpath, walk_ty};
|
||||
use rustc_hir::{self as hir, Expr, ExprKind, GenericArgs, HirId, Node, PathSegment, QPath, TyKind};
|
||||
use rustc_hir::intravisit::{InferKind, Visitor, VisitorExt, walk_qpath, walk_ty};
|
||||
use rustc_hir::{self as hir, AmbigArg, Expr, ExprKind, GenericArgs, HirId, Node, PathSegment, QPath, TyKind};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ty::{self, AdtDef, GenericArgKind, Ty};
|
||||
use rustc_span::{Span, Symbol};
|
||||
|
|
@ -116,14 +116,15 @@ impl<'cx> Visitor<'cx> for CertaintyVisitor<'cx, '_> {
|
|||
}
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &'cx hir::Ty<'_>) {
|
||||
if matches!(ty.kind, TyKind::Infer) {
|
||||
self.certainty = Certainty::Uncertain;
|
||||
}
|
||||
fn visit_ty(&mut self, ty: &'cx hir::Ty<'_, AmbigArg>) {
|
||||
if self.certainty != Certainty::Uncertain {
|
||||
walk_ty(self, ty);
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_infer(&mut self, _inf_id: HirId, _inf_span: Span, _kind: InferKind<'cx>) -> Self::Result {
|
||||
self.certainty = Certainty::Uncertain;
|
||||
}
|
||||
}
|
||||
|
||||
fn type_certainty(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> Certainty {
|
||||
|
|
@ -139,7 +140,7 @@ fn type_certainty(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> Certainty {
|
|||
}
|
||||
|
||||
let mut visitor = CertaintyVisitor::new(cx);
|
||||
visitor.visit_ty(ty);
|
||||
visitor.visit_unambig_ty(ty);
|
||||
visitor.certainty
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use crate::ty::needs_ordered_drop;
|
|||
use crate::{get_enclosing_block, path_to_local_id};
|
||||
use core::ops::ControlFlow;
|
||||
use rustc_ast::visit::{VisitorResult, try_visit};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::{self as hir, AmbigArg};
|
||||
use rustc_hir::def::{CtorKind, DefKind, Res};
|
||||
use rustc_hir::intravisit::{self, Visitor, walk_block, walk_expr};
|
||||
use rustc_hir::{
|
||||
|
|
@ -122,7 +122,7 @@ pub fn for_each_expr_without_closures<'tcx, B, C: Continue>(
|
|||
}
|
||||
|
||||
// Avoid unnecessary `walk_*` calls.
|
||||
fn visit_ty(&mut self, _: &'tcx hir::Ty<'tcx>) -> Self::Result {
|
||||
fn visit_ty(&mut self, _: &'tcx hir::Ty<'tcx, AmbigArg>) -> Self::Result {
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
fn visit_pat(&mut self, _: &'tcx Pat<'tcx>) -> Self::Result {
|
||||
|
|
@ -172,7 +172,7 @@ pub fn for_each_expr<'tcx, B, C: Continue>(
|
|||
ControlFlow::Continue(())
|
||||
}
|
||||
// Avoid unnecessary `walk_*` calls.
|
||||
fn visit_ty(&mut self, _: &'tcx hir::Ty<'tcx>) -> Self::Result {
|
||||
fn visit_ty(&mut self, _: &'tcx hir::Ty<'tcx, AmbigArg>) -> Self::Result {
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
fn visit_pat(&mut self, _: &'tcx Pat<'tcx>) -> Self::Result {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue