Skip to content

Commit 8d2a3e0

Browse files
committed
Use node_type_opt over node_type
1 parent 187bbf0 commit 8d2a3e0

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

clippy_lints/src/shadow.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,14 @@ fn check_local<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, local: &'tcx Local<'_>, bin
154154
}
155155

156156
fn is_binding(cx: &LateContext<'_, '_>, pat_id: HirId) -> bool {
157-
let var_ty = cx.tables.node_type(pat_id);
158-
match var_ty.kind {
159-
ty::Adt(..) => false,
160-
_ => true,
157+
let var_ty = cx.tables.node_type_opt(pat_id);
158+
if let Some(var_ty) = var_ty {
159+
match var_ty.kind {
160+
ty::Adt(..) => false,
161+
_ => true,
162+
}
163+
} else {
164+
false
161165
}
162166
}
163167

tests/ui/crashes/shadow.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn main() {
2+
let x: [i32; {
3+
let u = 2;
4+
4
5+
}] = [2; { 4 }];
6+
}

0 commit comments

Comments
 (0)