Closed
Description
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();
}
results in the following lint:
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,
|
following the lint results in a compiler error however:
error: implementation of `Trait` is not general enough
--> src/main.rs:13:5
|
13 | with_bound();
| ^^^^^^^^^^^^ implementation of `Trait` is not general enough
|
= note: `for<'a> fn(Inv<'a>)` must implement `Trait`, for any lifetime `'0`...
= note: ...but `Trait` is actually implemented for the type `for<'a> fn(Inv<'a>)`
By removing the parens this gets parsed as for<'a> (fn(Inv<'a>): Trait)
instead of the original (for<'a> fn(Inv(<'a>))): Trait