-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-coercionsArea: implicit and explicit `expr as Type` coercionsArea: implicit and explicit `expr as Type` coercionsA-varianceArea: Variance (https://doc.rust-lang.org/nomicon/subtyping.html)Area: Variance (https://doc.rust-lang.org/nomicon/subtyping.html)C-bugCategory: This is a bug.Category: This is a bug.P-mediumMedium priorityMedium priorityT-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.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Description
I tried this code:
trait Array {
type Item;
}
trait Platform {
type Assoc: Array<Item = Self::Assoc2>;
type Assoc2;
}
struct Message<A, B>
where
A: Array<Item = B>,
{
pub field: A,
}
impl<A, B> Clone for Message<A, B>
where
A: Array<Item = B>,
{
fn clone(&self) -> Self {
todo!()
}
}
fn clone<P: Platform>(x: &Message<P::Assoc, P::Assoc2>) {
let x: Message<_, _> = Clone::clone(x);
}
I expected it to work.
Instead, this happened:
error[E0282]: type annotations needed
--> src/lib.rs:31:32
|
31 | Enum::Variant(Clone::clone(x))
| ^ cannot infer type for reference `&Message<<P as Platform>::Assoc, _>`
I regressed this in #129059. I have no idea yet why it's happening! This also could be minimized further, I think.
Metadata
Metadata
Assignees
Labels
A-coercionsArea: implicit and explicit `expr as Type` coercionsArea: implicit and explicit `expr as Type` coercionsA-varianceArea: Variance (https://doc.rust-lang.org/nomicon/subtyping.html)Area: Variance (https://doc.rust-lang.org/nomicon/subtyping.html)C-bugCategory: This is a bug.Category: This is a bug.P-mediumMedium priorityMedium priorityT-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.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.