-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Closed
Copy link
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.
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
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.