Skip to content

Commit

Permalink
Auto merge of #4964 - JohnTitor:fix-potential-ice, r=flip1995
Browse files Browse the repository at this point in the history
Possibly fix an ICE on test

Fix a potential ICE on test with debug assertion, caused on rust-lang/rust#67661.
r? @oli-obk

changelog: none
  • Loading branch information
bors committed Dec 28, 2019
2 parents 8e493c6 + bca1259 commit 6bf87d5
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions clippy_lints/src/mut_key.rs
Expand Up @@ -103,18 +103,20 @@ fn check_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, span: Span, ty: Ty<'tcx>) {
.iter()
.any(|path| match_def_path(cx, def.did, &**path))
{
let key_type = substs.type_at(0);
if is_concrete_type(key_type) && !key_type.is_freeze(cx.tcx, cx.param_env, span) {
span_lint(cx, MUTABLE_KEY_TYPE, span, "mutable key type");
let key_type = concrete_type(substs.type_at(0));
if let Some(key_type) = key_type {
if !key_type.is_freeze(cx.tcx, cx.param_env, span) {
span_lint(cx, MUTABLE_KEY_TYPE, span, "mutable key type");
}
}
}
}
}

fn is_concrete_type(ty: Ty<'_>) -> bool {
fn concrete_type(ty: Ty<'_>) -> Option<Ty<'_>> {
match ty.kind {
RawPtr(TypeAndMut { ty: inner_ty, .. }) | Ref(_, inner_ty, _) => is_concrete_type(inner_ty),
Dynamic(..) | Opaque(..) | Param(..) => false,
_ => true,
RawPtr(TypeAndMut { ty: inner_ty, .. }) | Ref(_, inner_ty, _) => concrete_type(inner_ty),
Dynamic(..) | Opaque(..) | Param(..) => None,
_ => Some(ty),
}
}

0 comments on commit 6bf87d5

Please sign in to comment.