Auto merge of #6582 - rail-rain:ice_6539, r=flip1995
Fix the ICE 6539 Fixes #6539 It happened because `zero_sized_map_values` used `layout_of` with types from type aliases, which is essentially the same as the ICE 4968. --- changelog: Fix an ICE in `zero_sized_map_values`
This commit is contained in:
commit
e0d331fbf4
2 changed files with 19 additions and 1 deletions
|
|
@ -6,7 +6,7 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
|
|||
use rustc_target::abi::LayoutOf as _;
|
||||
use rustc_typeck::hir_ty_to_ty;
|
||||
|
||||
use crate::utils::{is_type_diagnostic_item, match_type, paths, span_lint_and_help};
|
||||
use crate::utils::{is_normalizable, is_type_diagnostic_item, match_type, paths, span_lint_and_help};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for maps with zero-sized value types anywhere in the code.
|
||||
|
|
@ -50,6 +50,8 @@ impl LateLintPass<'_> for ZeroSizedMapValues {
|
|||
if is_type_diagnostic_item(cx, ty, sym!(hashmap_type)) || match_type(cx, ty, &paths::BTREEMAP);
|
||||
if let Adt(_, ref substs) = ty.kind();
|
||||
let ty = substs.type_at(1);
|
||||
// Do this to prevent `layout_of` crashing, being unable to fully normalize `ty`.
|
||||
if is_normalizable(cx, cx.param_env, ty);
|
||||
if let Ok(layout) = cx.layout_of(ty);
|
||||
if layout.is_zst();
|
||||
then {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue