Files
rust/tests/ui
bors fcf3006e01 Auto merge of #113199 - b-naber:slice-pattern-type-inference, r=lcnr
Infer type in irrefutable slice patterns with fixed length as array

Fixes https://github.com/rust-lang/rust/issues/76342

In irrefutable slice patterns with a fixed length, we can infer the type as an array type. We now choose to prefer some implementations over others, e.g. in:

```
struct Zeroes;

const ARR: [usize; 2] = [0; 2];
const ARR2: [usize; 2] = [2; 2];

impl Into<&'static [usize; 2]> for Zeroes {
    fn into(self) -> &'static [usize; 2] {
        &ARR
    }
}

impl Into<&'static [usize]> for Zeroes {
    fn into(self) -> &'static [usize] {
        &ARR2
    }
}

fn main() {
    let &[a, b] = Zeroes.into();
}
```

We now prefer the impl candidate `impl Into<&'static [usize; 2]> for Zeroes`, it's not entirely clear to me that this is correct, but given that the slice impl would require a type annotation anyway, this doesn't seem unreasonable.

r? `@lcnr`
2023-08-03 11:48:33 +00:00
..
2023-07-17 22:06:32 +00:00
2023-07-24 18:04:35 +02:00
2023-07-28 20:15:12 +02:00
2023-01-30 20:12:19 +00:00
2023-05-30 13:03:40 +02:00
2023-07-17 22:06:32 +00:00
2023-05-08 17:58:01 -03:00
2023-07-03 09:12:15 +02:00
2023-08-01 23:12:03 +00:00
2023-01-30 20:12:19 +00:00
2023-07-10 20:09:28 +00:00
2023-07-28 22:23:21 +02:00
2023-04-29 13:01:46 +01:00
2023-07-28 11:20:11 +00:00
2023-07-30 14:02:21 +03:00
2023-07-29 11:47:26 +02:00
2023-06-29 16:24:07 +03:00
2023-06-26 08:56:32 +00:00
2023-08-02 15:38:00 +00:00
2023-04-03 09:24:11 +02:00
2023-07-30 15:40:32 -04:00
2023-04-19 19:13:45 +00:00
2023-06-20 19:46:01 -04:00
2023-05-08 03:36:30 +00:00
2023-05-29 12:07:41 -03:00
2023-03-29 18:04:44 -04:00
2023-08-01 23:12:03 +00:00
2023-06-12 20:24:48 +08:00
2023-04-29 13:01:46 +01:00
2023-05-12 00:10:52 +00:00
2023-03-08 00:00:18 +00:00
2023-04-13 22:10:26 -05:00
2023-04-13 22:10:26 -05:00
2023-03-08 00:00:18 +00:00
2023-03-08 00:00:18 +00:00