rust/compiler
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
..
rustc
rustc_abi
rustc_arena
rustc_ast Auto merge of #114353 - nnethercote:parser-ast-cleanups, r=petrochenkov 2023-08-03 04:26:42 +00:00
rustc_ast_lowering
rustc_ast_passes
rustc_ast_pretty Remove MacDelimiter. 2023-08-03 09:03:30 +10:00
rustc_attr [rustc_attr][nit] Replace filter + is_some with map_or. 2023-08-01 12:39:32 -07:00
rustc_baked_icu_data
rustc_borrowck Remove constness from TraitPredicate 2023-08-02 15:38:00 +00:00
rustc_builtin_macros Remove MacDelimiter. 2023-08-03 09:03:30 +10:00
rustc_codegen_cranelift
rustc_codegen_gcc Auto merge of #105545 - erikdesjardins:ptrclean, r=bjorn3 2023-08-01 19:44:17 +00:00
rustc_codegen_llvm Rollup merge of #114079 - compiler-errors:closure-upvars, r=oli-obk 2023-08-02 13:46:54 +02:00
rustc_codegen_ssa Auto merge of #105545 - erikdesjardins:ptrclean, r=bjorn3 2023-08-01 19:44:17 +00:00
rustc_const_eval Rollup merge of #114363 - RalfJung:interpret-not-miri, r=jackh726 2023-08-03 08:12:39 +02:00
rustc_data_structures Rollup merge of #114306 - ttsugriy:push_str, r=wesleywiser 2023-08-01 17:39:12 +02:00
rustc_driver
rustc_driver_impl
rustc_error_codes
rustc_error_messages
rustc_errors
rustc_expand Remove MacDelimiter. 2023-08-03 09:03:30 +10:00
rustc_feature
rustc_fluent_macro
rustc_fs_util
rustc_graphviz
rustc_hir
rustc_hir_analysis Remove constness from TraitPredicate 2023-08-02 15:38:00 +00:00
rustc_hir_pretty
rustc_hir_typeck Auto merge of #113199 - b-naber:slice-pattern-type-inference, r=lcnr 2023-08-03 11:48:33 +00:00
rustc_incremental
rustc_index
rustc_infer Remove constness from TraitPredicate 2023-08-02 15:38:00 +00:00
rustc_interface
rustc_lexer
rustc_lint Auto merge of #112431 - Urgau:cast_ref_to_mut_improvments, r=Nilstrieb 2023-08-02 11:25:13 +00:00
rustc_lint_defs
rustc_llvm Auto merge of #113339 - lqd:respect-filters, r=tmiasko 2023-08-01 23:15:20 +00:00
rustc_log
rustc_macros
rustc_metadata Auto merge of #113292 - MU001999:fix/issue-113222, r=Nilstrieb 2023-08-03 00:53:01 +00:00
rustc_middle Rollup merge of #114363 - RalfJung:interpret-not-miri, r=jackh726 2023-08-03 08:12:39 +02:00
rustc_mir_build
rustc_mir_dataflow Use upvar_tys in more places, make it a list 2023-08-01 23:19:31 +00:00
rustc_mir_transform Use upvar_tys in more places, make it a list 2023-08-01 23:19:31 +00:00
rustc_monomorphize avoid 'miri' when refering to the shared interpreter 2023-08-02 16:52:03 +02:00
rustc_parse Remove MacDelimiter. 2023-08-03 09:03:30 +10:00
rustc_parse_format
rustc_passes
rustc_plugin_impl
rustc_privacy Remove constness from TraitPredicate 2023-08-02 15:38:00 +00:00
rustc_query_impl
rustc_query_system
rustc_resolve
rustc_serialize
rustc_session
rustc_smir clean up, use opaque types 2023-08-01 17:48:20 +03:00
rustc_span
rustc_symbol_mangling avoid 'miri' when refering to the shared interpreter 2023-08-02 16:52:03 +02:00
rustc_target Auto merge of #112922 - g0djan:godjan/wasi-threads, r=wesleywiser 2023-08-02 01:01:48 +00:00
rustc_trait_selection Remove constness from TraitPredicate 2023-08-02 15:38:00 +00:00
rustc_traits
rustc_transmute
rustc_ty_utils Rollup merge of #114079 - compiler-errors:closure-upvars, r=oli-obk 2023-08-02 13:46:54 +02:00
rustc_type_ir