fix: preserve where clause when builtin derive

This commit is contained in:
austaras 2024-02-04 11:35:27 +08:00
parent e9d3565cd1
commit dad0fdb13f
3 changed files with 50 additions and 5 deletions

View file

@ -1373,3 +1373,34 @@ pub fn attr_macro() {}
"#,
);
}
#[test]
fn clone_with_type_bound() {
check_types(
r#"
//- minicore: derive, clone, builtin_impls
#[derive(Clone)]
struct Float;
trait TensorKind: Clone {
/// The primitive type of the tensor.
type Primitive: Clone;
}
impl TensorKind for Float {
type Primitive = f64;
}
#[derive(Clone)]
struct Tensor<K = Float> where K: TensorKind
{
primitive: K::Primitive,
}
fn foo(t: Tensor) {
let x = t.clone();
//^ Tensor<Float>
}
"#,
);
}