Skip to content

Commit

Permalink
Account for API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Jul 9, 2023
1 parent ad4f0f0 commit 9751dd9
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions clippy_utils/src/ty/type_certainty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ pub fn expr_type_is_certain(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {

fn expr_type_certainty(cx: &LateContext<'_>, expr: &Expr<'_>) -> Certainty {
let certainty = match &expr.kind {
ExprKind::Box(expr)
| ExprKind::Unary(_, expr)
ExprKind::Unary(_, expr)
| ExprKind::Field(expr, _)
| ExprKind::Index(expr, _)
| ExprKind::AddrOf(_, _, expr) => expr_type_certainty(cx, expr),
Expand Down Expand Up @@ -170,8 +169,7 @@ fn qpath_certainty(cx: &LateContext<'_>, qpath: &QPath<'_>, resolves_to_type: bo
QPath::LangItem(lang_item, _, _) => {
cx.tcx
.lang_items()
.require(*lang_item)
.ok()
.get(*lang_item)
.map_or(Certainty::Uncertain, |def_id| {
let generics = cx.tcx.generics_of(def_id);
if generics.parent_count == 0 && generics.params.is_empty() {
Expand Down Expand Up @@ -230,8 +228,8 @@ fn path_segment_certainty(
Certainty::Certain(None)
},

// `get_parent_node` because `hir_id` refers to a `Pat`, and we're interested in the node containing the `Pat`.
Res::Local(hir_id) => match cx.tcx.hir().get(cx.tcx.hir().get_parent_node(hir_id)) {
// `get_parent` because `hir_id` refers to a `Pat`, and we're interested in the node containing the `Pat`.
Res::Local(hir_id) => match cx.tcx.hir().get_parent(hir_id) {
// An argument's type is always certain.
Node::Param(..) => Certainty::Certain(None),
// A local's type is certain if its type annotation is certain or it has an initializer whose
Expand Down Expand Up @@ -292,7 +290,7 @@ fn type_is_inferrable_from_arguments(cx: &LateContext<'_>, expr: &Expr<'_>) -> b

(0..(generics.parent_count + generics.params.len()) as u32).all(|index| {
fn_sig.inputs().iter().any(|input_ty| {
input_ty.walk().any(|arg| {
input_ty.skip_binder().walk().any(|arg| {
if let GenericArgKind::Type(ty) = arg.unpack() {
ty.is_param(index)
} else {
Expand All @@ -304,7 +302,7 @@ fn type_is_inferrable_from_arguments(cx: &LateContext<'_>, expr: &Expr<'_>) -> b
}

fn self_ty<'tcx>(cx: &LateContext<'tcx>, method_def_id: DefId) -> Ty<'tcx> {
cx.tcx.fn_sig(method_def_id).skip_binder().inputs()[0]
cx.tcx.fn_sig(method_def_id).skip_binder().inputs().skip_binder()[0]
}

fn adt_def_id(ty: Ty<'_>) -> Option<DefId> {
Expand Down

0 comments on commit 9751dd9

Please sign in to comment.