about summary refs log tree commit diff
path: root/tests/ui/indexing/index_message.stderr
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-08-03 11:48:33 +0000
committerbors <bors@rust-lang.org>2023-08-03 11:48:33 +0000
commitfcf3006e0133365ecd26894689c086387edcbecb (patch)
treec2c51f1713a61cf3520fdf1748fa153e63fcfb9d /tests/ui/indexing/index_message.stderr
parentc115ec11d2087050dc12c5c83959979aa98bb3e5 (diff)
parent5a9af37370bc220bc395939d878c64547e3466d0 (diff)
downloadrust-fcf3006e0133365ecd26894689c086387edcbecb.tar.gz
rust-fcf3006e0133365ecd26894689c086387edcbecb.zip
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`
Diffstat (limited to 'tests/ui/indexing/index_message.stderr')
0 files changed, 0 insertions, 0 deletions