mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-17 06:28:42 +00:00
Possibly fix an ICE on test
This commit is contained in:
parent
0fec5905d8
commit
fbdb13cfb0
1 changed files with 13 additions and 8 deletions
|
@ -103,18 +103,23 @@ 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(Some(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 {
|
||||
match ty.kind {
|
||||
RawPtr(TypeAndMut { ty: inner_ty, .. }) | Ref(_, inner_ty, _) => is_concrete_type(inner_ty),
|
||||
Dynamic(..) | Opaque(..) | Param(..) => false,
|
||||
_ => true,
|
||||
fn concrete_type(ty: Option<Ty<'_>>) -> Option<Ty<'_>> {
|
||||
if let Some(ty) = ty {
|
||||
match ty.kind {
|
||||
RawPtr(TypeAndMut { ty: inner_ty, .. }) | Ref(_, inner_ty, _) => return concrete_type(Some(inner_ty)),
|
||||
Dynamic(..) | Opaque(..) | Param(..) => return None,
|
||||
_ => return Some(ty),
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue