Closed
Description
I tried this code:
use std::fmt::Debug;
struct ConstrainedStruct<X: Copy> {
x: X
}
trait InsufficientlyConstrainedGeneric<X=()> where {
fn return_the_constrained_type(&self, x: X) -> ConstrainedStruct<X> {
ConstrainedStruct { x }
}
}
fn main() { }
I expected to see this happen:
10 | trait InsufficientlyConstrainedGeneric<X=()> where X: std::marker::Copy {
| ++++++++++++++++++++
just add the new predicate
Instead, this happened:
10 | trait InsufficientlyConstrainedGeneric<X=()> where where X: std::marker::Copy {
| ++++++++++++++++++++++++++
I noticed this because a change to the compiler caused two predicates to get added, so even without an empty where clause (so with none), you'd get where X: std::marker::Copy where X: std::marker::Copy
, because the usual suggestion application logic does not see that there is a conflict, because the spans don't actually overlap.
Meta
rustc --version --verbose
:
1.78 (nightly, but also happens on earlier stables)