Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unused_parens: doesn't trigger for higher ranked function pointers #105061

Closed
lcnr opened this issue Nov 29, 2022 · 1 comment · Fixed by #106148
Closed

unused_parens: doesn't trigger for higher ranked function pointers #105061

lcnr opened this issue Nov 29, 2022 · 1 comment · Fixed by #106148
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lcnr
Copy link
Contributor

lcnr commented Nov 29, 2022

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();
}

This should lint as the parens around the function pointer are unnecessary, but stopped doing so due to #104796.

Expected output:

warning: unnecessary parentheses around type
 --> src/main.rs:9:5
  |
9 |     (for<'a> fn(Inv<'a>)): Trait,
  |     ^                   ^
  |
  = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
  |
9 -     (for<'a> fn(Inv<'a>)): Trait,
9 +     for<'a> fn(Inv<'a>): Trait,
  |
@lcnr lcnr added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 29, 2022
@chenyukang
Copy link
Member

@rustbot claim

chenyukang added a commit to chenyukang/rust that referenced this issue Dec 26, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jan 17, 2023
…d, r=lcnr

Fix unused_parens issue for higher ranked function pointers

fixes rust-lang#105061

r? `@lcnr`
@bors bors closed this as completed in 7d99866 Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants