diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-11-24 21:34:56 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-24 21:34:56 +0100 |
| commit | 83d1aab9ff50f9c2e07ee8e3845d525b906dc97a (patch) | |
| tree | da2539955ddf762e338520293da4b18ea8777455 | |
| parent | ed2d9369f4373a2c275fe3b73c23a1d5d0377957 (diff) | |
| parent | 97d95d48e2ef72d9ededeb5821f0bfcbd8fcf7c6 (diff) | |
| download | rust-83d1aab9ff50f9c2e07ee8e3845d525b906dc97a.tar.gz rust-83d1aab9ff50f9c2e07ee8e3845d525b906dc97a.zip | |
Rollup merge of #104796 - notriddle:notriddle/unused-issue-104397, r=oli-obk
lint: do not warn unused parens around higher-ranked function pointers Fixes #104397
| -rw-r--r-- | compiler/rustc_lint/src/unused.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/lint/unused/issue-104397.rs | 18 |
2 files changed, 19 insertions, 0 deletions
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 @@ impl EarlyLintPass for UnusedParens { 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(); +} |
