Skip to content

Commit 3ecc105

Browse files
committed
const_items_unit_type_default: unbreak clippy
1 parent e9badd6 commit 3ecc105

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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
(
@@ -626,7 +626,7 @@ pub fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool {
626626
eq_defaultness(*ld, *rd)
627627
&& eq_id(*li, *ri)
628628
&& eq_generics(lg, rg)
629-
&& eq_ty(lt, rt)
629+
&& eq_fn_ret_ty(lt, rt)
630630
&& both(lb.as_ref(), rb.as_ref(), eq_const_item_rhs)
631631
},
632632
(

0 commit comments

Comments
 (0)