Skip to content

Commit addc520

Browse files
committed
Fix extra_unused_type_parameters lint improperly walking OpaqueDef
1 parent 803f2d0 commit addc520

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

clippy_lints/src/extra_unused_type_parameters.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint;
22
use clippy_utils::trait_ref_of_method;
33
use rustc_data_structures::fx::FxHashMap;
44
use rustc_hir::intravisit::{walk_impl_item, walk_item, walk_param_bound, walk_ty, Visitor};
5-
use rustc_hir::{GenericParamKind, Generics, ImplItem, ImplItemKind, Item, ItemKind, Ty, WherePredicate};
5+
use rustc_hir::{GenericParamKind, Generics, ImplItem, ImplItemKind, Item, ItemKind, Ty, TyKind, WherePredicate};
66
use rustc_lint::{LateContext, LateLintPass};
77
use rustc_middle::hir::nested_filter;
88
use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -74,6 +74,12 @@ impl<'cx, 'tcx> Visitor<'tcx> for TypeWalker<'cx, 'tcx> {
7474
fn visit_ty(&mut self, t: &'tcx Ty<'tcx>) {
7575
if let Some((def_id, _)) = t.peel_refs().as_generic_param() {
7676
self.map.remove(&def_id);
77+
} else if let TyKind::OpaqueDef(id, _, _) = t.kind {
78+
// Explicitly walk OpaqueDef. Normally `walk_ty` would do the job, but it calls
79+
// `visit_nested_item`, which checks that `Self::NestedFilter::INTER` is set. We're
80+
// using `OnlyBodies`, so the check ends up failing and the type isn't fully walked.
81+
let item = self.nested_visit_map().item(id);
82+
walk_item(self, item);
7783
} else {
7884
walk_ty(self, t);
7985
}

0 commit comments

Comments
 (0)