Repository navigation
Associated type equality in trait bounds not properly matched #37883
Copy link
Copy link
Closed
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)Area: Lazy normalization (tracking issue: #60471)A-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.T-langRelevant to the language teamRelevant to the language team
Description
Activity
- added a commit that references this issue
on Dec 4, 2016 - addedA-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-trait-systemArea: Trait systemArea: Trait system
on Dec 28, 2016 Smaller test case (Playground):
pub trait Foo<T> { } pub trait Bar: Foo<<Self as Bar>::Quux> { type Quux; } pub trait Arthur { type Wibble: Bar<Quux=()>; } pub fn assert_is_foo<A: Foo<()>>() { } pub fn assert_is_bar<B: Bar<Quux=()>>() { } pub fn test<A: Arthur>() { let _: <A::Wibble as Bar>::Quux = (); assert_is_bar::<A::Wibble>(); assert_is_foo::<A::Wibble>(); // the trait bound `<A as Arthur>::Wibble: Foo<()>` is not satisfied }This code (in the body of
test) knows thatA::Wibble: Barand that<A::Wibble as Bar>::Quux = (), but not thatA::Wibble: Foo<()>.- addedF-associated_type_bounds`#![feature(associated_type_bounds)]``#![feature(associated_type_bounds)]`T-langRelevant to the language teamRelevant to the language team
on Nov 5, 2019 Current output:
error[E0277]: cannot multiply `<E as EuclideanSpace>::Real` to `<E as EuclideanSpace>::Coordinates` --> src/main.rs:25:26 | 24 | fn powf(&self, n: <E::Coordinates as Module>::Ring) -> E::Coordinates { | - help: consider further restricting the associated type: `where <E as EuclideanSpace>::Coordinates: std::ops::Mul<<E as EuclideanSpace>::Real>` 25 | self.to_vector() * n | ^ no implementation for `<E as EuclideanSpace>::Coordinates * <E as EuclideanSpace>::Real` | = help: the trait `std::ops::Mul<<E as EuclideanSpace>::Real>` is not implemented for `<E as EuclideanSpace>::Coordinates` error[E0308]: mismatched types --> src/main.rs:25:28 | 25 | self.to_vector() * n | ^ expected Module::Ring, found EuclideanSpace::Real | = note: expected type `<<E as EuclideanSpace>::Coordinates as Module>::Ring` found type `<E as EuclideanSpace>::Real`error[E0277]: the trait bound `<A as Arthur>::Wibble: Foo<()>` is not satisfied --> src/main.rs:10:5 | 4 | pub fn assert_is_foo<A: Foo<()>>() { } | ------------- ------- required by this bound in `assert_is_foo` ... 7 | pub fn test<A: Arthur>() { | - help: consider further restricting the associated type: `where <A as Arthur>::Wibble: Foo<()>` ... 10 | assert_is_foo::<A::Wibble>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo<()>` is not implemented for `<A as Arthur>::Wibble`- addedA-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)Area: Lazy normalization (tracking issue: #60471)
on Jul 11, 2020 - addedE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
on Feb 2, 2021 This now compiles.
- removedF-associated_type_bounds`#![feature(associated_type_bounds)]``#![feature(associated_type_bounds)]`
on Feb 2, 2021 - added 2 commits that reference this issue
on Feb 2, 2021 - added a commit that references this issue
on Sep 6, 2022 - addedA-trait-systemArea: Trait systemArea: Trait systemand removedA-trait-systemArea: Trait systemArea: Trait system
on Dec 21, 2024
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)Area: Lazy normalization (tracking issue: #60471)A-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.T-langRelevant to the language teamRelevant to the language team
I might be missing something but I believe the following (playpen) should compile but does not:
In
self.to_vector() * n, the compiler seems to understand that<E::Coordinates as Module>::Ring>is the same thing asE::Realbut fails to applies theMul<<Self as Module>::Ring, Output = Self>trait fromModule.