diff --git a/clippy_lints/src/cyclomatic_complexity.rs b/clippy_lints/src/cyclomatic_complexity.rs index 3e3237ffe087..faa56bccb228 100644 --- a/clippy_lints/src/cyclomatic_complexity.rs +++ b/clippy_lints/src/cyclomatic_complexity.rs @@ -142,7 +142,7 @@ impl<'a, 'b, 'tcx, 'gcx> Visitor<'a> for CCHelper<'b, 'gcx, 'tcx> { let ty = self.tcx.node_id_to_type(callee.id); match ty.sty { ty::TyFnDef(_, _, ty) | - ty::TyFnPtr(ty) if ty.sig.skip_binder().output.diverges() => { + ty::TyFnPtr(ty) if ty.sig.skip_binder().output.sty == ty::TyNever => { self.divergence += 1; } _ => (), diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index 1d9eb70b008d..ad7da71eab05 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -71,7 +71,7 @@ fn check_closure(cx: &LateContext, expr: &Expr) { ty::TyFnDef(_, _, fn_ty) | ty::TyFnPtr(fn_ty) => { if fn_ty.unsafety == Unsafety::Unsafe || - fn_ty.sig.skip_binder().output == ty::FnOutput::FnDiverging { + fn_ty.sig.skip_binder().output.sty == ty::TyNever { return; } } diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index 75f41661d7e2..c914d5210ecf 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -590,7 +590,7 @@ impl LateLintPass for Pass { let ret_ty = return_ty(cx, implitem.id); if &name.as_str() == &"new" && - !ret_ty.map_or(false, |ret_ty| ret_ty.walk().any(|t| same_tys(cx, t, ty, implitem.id))) { + !ret_ty.walk().any(|t| same_tys(cx, t, ty, implitem.id)) { span_lint(cx, NEW_RET_NO_SELF, explicit_self.span, diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index 7a2db85b3c71..b1bffb8c2362 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -106,8 +106,7 @@ impl LateLintPass for NewWithoutDefault { .ty; if_let_chain!{[ self_ty.walk_shallow().next().is_none(), // implements_trait does not work with generics - let Some(ret_ty) = return_ty(cx, id), - same_tys(cx, self_ty, ret_ty, id), + same_tys(cx, self_ty, return_ty(cx, id), id), let Some(default_trait_id) = get_trait_def_id(cx, &paths::DEFAULT_TRAIT), !implements_trait(cx, self_ty, default_trait_id, Vec::new()) ], { diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index 62174f035959..c458bb1dff39 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -692,16 +692,12 @@ pub fn camel_case_from(s: &str) -> usize { last_i } -/// Convenience function to get the return type of a function or `None` if the function diverges. -pub fn return_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, fn_item: NodeId) -> Option> { +/// Convenience function to get the return type of a function +pub fn return_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, fn_item: NodeId) -> ty::Ty<'tcx> { let parameter_env = ty::ParameterEnvironment::for_item(cx.tcx, fn_item); let fn_sig = cx.tcx.node_id_to_type(fn_item).fn_sig().subst(cx.tcx, parameter_env.free_substs); let fn_sig = cx.tcx.liberate_late_bound_regions(parameter_env.free_id_outlive, &fn_sig); - if let ty::FnConverging(ret_ty) = fn_sig.output { - Some(ret_ty) - } else { - None - } + fn_sig.output } /// Check if two types are the same.