Skip to content

Commit 5cca751

Browse files
committed
UnusedBrokenConst: Also check associated consts.
Previously, we would only end up doing checks for consts which const_prop was attempted on. This meant associated consts which didn't end up explicitly used in a crate weren't visited, so weren't checked.
1 parent c0036bd commit 5cca751

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/librustc_lint/builtin.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,17 +1183,20 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedBrokenConst {
11831183
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item<'_>) {
11841184
trace!("UnusedBrokenConst: check_item(_, _, {:?}", it);
11851185
match it.kind {
1186-
hir::ItemKind::Const(_, body_id) => {
1187-
trace!("UnusedBrokenConst: checking {:?}", body_id);
1188-
check_const(cx, body_id);
1189-
}
1190-
hir::ItemKind::Static(_, _, body_id) => {
1186+
hir::ItemKind::Const(_, body_id) | hir::ItemKind::Static(_, _, body_id) => {
11911187
trace!("UnusedBrokenConst: checking {:?}", body_id);
11921188
check_const(cx, body_id);
11931189
}
11941190
_ => {}
11951191
}
11961192
}
1193+
fn check_impl_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::ImplItem<'_>) {
1194+
trace!("UnusedBrokenConst: check_impl_item(_, _, it = {:?})", it);
1195+
if let hir::ImplItemKind::Const(_, body_id) = it.kind {
1196+
trace!("UnusedBrokenConst: checking {:?}", body_id);
1197+
check_const(cx, body_id);
1198+
}
1199+
}
11971200
}
11981201

11991202
declare_lint! {

0 commit comments

Comments
 (0)