Skip to content

Commit 76a4044

Browse files
committed
const_items_unit_type_default: unbreak clippy
1 parent 6b25cc9 commit 76a4044

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/tools/clippy/clippy_lints/src/redundant_static_lifetimes.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_config::Conf;
22
use clippy_utils::diagnostics::span_lint_and_then;
33
use clippy_utils::msrvs::{self, MsrvStack};
44
use clippy_utils::source::snippet;
5-
use rustc_ast::ast::{ConstItem, Item, ItemKind, StaticItem, Ty, TyKind};
5+
use rustc_ast::ast::{ConstItem, FnRetTy, Item, ItemKind, StaticItem, Ty, TyKind};
66
use rustc_errors::Applicability;
77
use rustc_lint::{EarlyContext, EarlyLintPass};
88
use rustc_session::impl_lint_pass;
@@ -103,7 +103,9 @@ impl EarlyLintPass for RedundantStaticLifetimes {
103103
}
104104

105105
if !item.span.from_expansion() {
106-
if let ItemKind::Const(box ConstItem { ty: ref var_type, .. }) = item.kind {
106+
if let ItemKind::Const(box ConstItem { ty: ref var_type, .. }) = item.kind
107+
&& let FnRetTy::Ty(var_type) = var_type
108+
{
107109
Self::visit_type(var_type, cx, "constants have by default a `'static` lifetime");
108110
// Don't check associated consts because `'static` cannot be elided on those (issue
109111
// #2438)

src/tools/clippy/clippy_utils/src/ast_utils/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
370370
eq_defaultness(*ld, *rd)
371371
&& eq_id(*li, *ri)
372372
&& eq_generics(lg, rg)
373-
&& eq_ty(lt, rt)
373+
&& eq_fn_ret_ty(lt, rt)
374374
&& both(lb.as_ref(), rb.as_ref(), eq_const_item_rhs)
375375
},
376376
(
@@ -630,7 +630,7 @@ pub fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool {
630630
eq_defaultness(*ld, *rd)
631631
&& eq_id(*li, *ri)
632632
&& eq_generics(lg, rg)
633-
&& eq_ty(lt, rt)
633+
&& eq_fn_ret_ty(lt, rt)
634634
&& both(lb.as_ref(), rb.as_ref(), eq_const_item_rhs)
635635
},
636636
(

0 commit comments

Comments
 (0)