diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index d6a01b42548..5c9217db118 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -1015,6 +1015,7 @@ fn check_ty(&mut self, cx: &EarlyContext<'_>, ty: &ast::Ty) { if let ast::TyKind::Paren(r) = &ty.kind { match &r.kind { ast::TyKind::TraitObject(..) => {} + ast::TyKind::BareFn(b) if b.generic_params.len() > 0 => {} ast::TyKind::ImplTrait(_, bounds) if bounds.len() > 1 => {} ast::TyKind::Array(_, len) => { self.check_unused_delims_expr( diff --git a/src/test/ui/lint/unused/issue-104397.rs b/src/test/ui/lint/unused/issue-104397.rs new file mode 100644 index 00000000000..94e15cd96bc --- /dev/null +++ b/src/test/ui/lint/unused/issue-104397.rs @@ -0,0 +1,18 @@ +// check-pass + +#![warn(unused)] +#![deny(warnings)] + +struct Inv<'a>(&'a mut &'a ()); + +trait Trait {} +impl Trait for for<'a> fn(Inv<'a>) {} + +fn with_bound() +where + (for<'a> fn(Inv<'a>)): Trait, +{} + +fn main() { + with_bound(); +}