-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Regression in trait bounds that are redundant with associated type's HRTB #57639
Copy link
Copy link
Closed
Labels
P-highHigh priorityHigh priorityT-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.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Metadata
Metadata
Assignees
Labels
P-highHigh priorityHigh priorityT-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.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Type
Fields
Give feedbackNo fields configured for issues without a type.
The title is a mouthful, so let me explain and give some motivation. Say I have a trait
MyTraitwith an associated typeMessageType. This message type must be deserializable (in the serde sense), i.e.,MessageType: for<'a> Deserialize<'a>. Now suppose I have a generic structGenericStruct<T>whereT: MyTrait. I want the struct to contain a message, so I put a thing of typeT::MessageTypeinside the struct. I would likeGenericStructto also beDeserializeable now, so I#[derive(Deserialize)].Concretely, the code
compiles in 1.31.1-stable and fails in 1.33.0-nightly with error message
Furthermore, if the commented lines are uncommented, and the first
typeline inMyTraitis commented out, the code now compiles in stable and nightly.I don't believe this is version-specific behavior in serde. I would like to make a neater minimal testcase, but I don't know of any auto-derivable traits that only take a lifetime as a parameter.