@@ -4,7 +4,7 @@ use clippy_utils::ty::{is_normalizable, is_type_diagnostic_item, match_type};
44use if_chain:: if_chain;
55use rustc_hir:: { self as hir, HirId , ItemKind , Node } ;
66use rustc_lint:: { LateContext , LateLintPass } ;
7- use rustc_middle:: ty:: { Adt , Ty } ;
7+ use rustc_middle:: ty:: { Adt , Ty , TypeFoldable } ;
88use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
99use rustc_span:: sym;
1010use rustc_target:: abi:: LayoutOf as _;
@@ -52,6 +52,9 @@ impl LateLintPass<'_> for ZeroSizedMapValues {
5252 if is_type_diagnostic_item( cx, ty, sym:: hashmap_type) || match_type( cx, ty, & paths:: BTREEMAP ) ;
5353 if let Adt ( _, substs) = ty. kind( ) ;
5454 let ty = substs. type_at( 1 ) ;
55+ // Fixes https://github.com/rust-lang/rust-clippy/issues/7447 because of
56+ // https://github.com/rust-lang/rust/blob/master/compiler/rustc_middle/src/ty/sty.rs#L968
57+ if !ty. has_escaping_bound_vars( ) ;
5558 // Do this to prevent `layout_of` crashing, being unable to fully normalize `ty`.
5659 if is_normalizable( cx, cx. param_env, ty) ;
5760 if let Ok ( layout) = cx. layout_of( ty) ;
0 commit comments