about summary refs log tree commit diff
path: root/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-unwind.diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-06-07 13:00:24 +0000
committerbors <bors@rust-lang.org>2023-06-07 13:00:24 +0000
commit085a3112ae9e11c0cdfbcbc3413919fe9e39e8d2 (patch)
treee57744d8febae34b406b9c9dee55f5a188b32856 /tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-unwind.diff
parent1c25885bd249ac1af07baf797e5feff95eb95bf1 (diff)
parent4f0c6fac176d136687436390ae085ac0279b3ba6 (diff)
downloadrust-085a3112ae9e11c0cdfbcbc3413919fe9e39e8d2.tar.gz
rust-085a3112ae9e11c0cdfbcbc3413919fe9e39e8d2.zip
Auto merge of #15000 - lowr:fix/builtin-derive-bound-for-assoc, r=HKalbasi
fix: only generate trait bound for associated types in field types

Given the following definitions:

```rust
trait Trait {
    type A;
    type B;
    type C;
}

#[derive(Clone)]
struct S<T: Trait>
where
    T::A: Send,
{
    qualified: <T as Trait>::B,
    shorthand: T::C,
}
```

we currently expand the derive macro to:

```rust
impl<T> Clone for S<T>
where
    T: Trait + Clone,
    T::A: Clone,
    T::B: Clone,
    T::C: Clone,
{ /* ... */ }
```

This does not match how rustc expands it. Specifically, `Clone` bounds for `T::A` and `T::B` should not be generated.

The criteria for associated types to get bound seem to be 1) the associated type appears as part of field types AND 2) it's written in the shorthand form. I have no idea why rustc doesn't consider qualified associated types (there's even a comment that suggests they should be considered; see rust-lang/rust#50730), but it's important to follow rustc.
Diffstat (limited to 'tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-unwind.diff')
0 files changed, 0 insertions, 0 deletions