-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-inferenceArea: Type inferenceArea: Type inferenceA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsA-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.
Description
This compiles:
trait Trait<'a> {}
struct S<T>(T);
impl<'a, T> Trait<'a> for S<T> where T: for<'b> Trait<'b> {}
fn main() {}
This following does not. It seems like the impl already has T: for<'b> Trait<'b>
so adding T: Trait<'a>
should not affect the behavior.
trait Trait<'a> {}
struct S<T>(T);
// Added T: Trait<'a>
impl<'a, T> Trait<'a> for S<T> where T: for<'b> Trait<'b>, T: Trait<'a> {}
fn main() {}
error[E0283]: type annotations required: cannot resolve `T: Trait<'a>`
--> src/main.rs:6:1
|
6 | impl<'a, T> Trait<'a> for S<T> where T: for<'b> Trait<'b>, T: Trait<'a> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: required by `Trait`
This currently affects the following and many people have run into it. The workaround is to remove the bound (rust-lang/rust-clippy#1689).
#[derive(Deserialize)]
struct S<T: serde::de::DeserializeOwned>(T);
shouc, dzmitry-lahoda, barmettlerl, michael-2956, jacquescoronal and 1 more
Metadata
Metadata
Assignees
Labels
A-inferenceArea: Type inferenceArea: Type inferenceA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsA-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.