1
Fork 0
rust/tests/ui/array-slice-vec
Matthias Krüger 0b7f0ff230
Rollup merge of #117614 - RalfJung:static-mut-refs, r=davidtwco,oli-obk
static mut: allow mutable reference to arbitrary types, not just slices and arrays

For historical reasons, we allow this:
```rust
static mut ARRAY: &'static mut [isize] = &mut [1];
```
However, we do not allow this:
```rust
static mut INT: &'static mut isize = &mut 1;
```

I think that's terribly inconsistent. I don't care much for `static mut`, but we have to keep it around for backwards compatibility and so we have to keep supporting it properly in the compiler. In recent refactors of how we deal with mutability of data in `static` and `const`, I almost made a fatal mistake since I tested `static mut INT: &'static mut isize = &mut 1` and concluded that we don't allow such `'static` mutable references even inside `static mut`. After all, nobody would expect this to be allowed only for arrays and slices, right?!?? So for the sake of our own sanity, and of whoever else reverse engineers these rules in the future to understand what the Rust compiler accepts or does not accept, I propose that we accept this for all types, not just arrays and slices.
2024-02-10 13:12:28 +01:00
..
array-break-length.rs
array-break-length.stderr
array-not-vector.rs
array-not-vector.stderr
array_const_index-0.rs
array_const_index-0.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
array_const_index-1.rs
array_const_index-1.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
array_const_index-2.rs
bounds-check-no-overflow.rs
box-of-array-of-drop-1.rs
box-of-array-of-drop-2.rs
byte-literals.rs
cast-in-array-size.rs
check-static-slice.rs
copy-out-of-array-1.rs
destructure-array-1.rs
dst-raw-slice.rs
empty-mutable-vec.rs
estr-slice.rs
evec-slice.rs
fixed_length_copy.rs
huge-largest-array.rs
infer_array_len.rs add test, bless tests 2023-07-17 22:00:43 +00:00
issue-15730.rs
issue-18425.rs
issue-69103-extra-binding-subslice.rs
issue-69103-extra-binding-subslice.stderr
ivec-pass-by-value.rs
match_arr_unknown_len.rs
match_arr_unknown_len.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
mut-vstore-expr.rs
mutability-inherits-through-fixed-length-vec.rs
mutable-alias-vec.rs
nested-vec-1.rs
nested-vec-2.rs
nested-vec-3.rs
new-style-fixed-length-vec.rs
rcvr-borrowed-to-slice.rs
repeat_empty_ok.rs
repeat_empty_ok.stderr Remove extra # from url 2024-01-24 00:41:45 +01:00
repeated-vector-syntax.rs
show-boxed-slice.rs Adjust compiler tests for unused_tuple_struct_fields -> dead_code 2024-01-02 15:34:37 -05:00
slice-2.rs
slice-2.stderr Improve spans for indexing expressions 2023-08-04 13:17:39 +02:00
slice-mut-2.rs
slice-mut-2.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
slice-mut.rs
slice-mut.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
slice-of-zero-size-elements.rs
slice-panic-1.rs
slice-panic-2.rs
slice-pat-type-mismatches.rs address review 2023-07-17 22:06:32 +00:00
slice-pat-type-mismatches.stderr address review 2023-07-17 22:06:32 +00:00
slice-to-vec-comparison.rs
slice-to-vec-comparison.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
slice.rs
slice_binary_search.rs
slice_is_sorted_by_borrow.rs
subslice-only-once-semantic-restriction.rs
subslice-only-once-semantic-restriction.stderr
subslice-patterns-const-eval-match.rs
subslice-patterns-const-eval.rs
suggest-array-length.fixed
suggest-array-length.rs
suggest-array-length.stderr Bless tests 2024-01-13 12:46:58 -05:00
variance-vec-covariant.rs
vec-dst.rs
vec-fixed-length.rs
vec-late-init.rs
vec-macro-no-std.rs
vec-macro-rvalue-scope.rs
vec-macro-with-brackets.rs
vec-macro-with-comma-only.rs
vec-macro-with-comma-only.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
vec-macro-with-trailing-comma.rs
vec-matching-autoslice.rs remove illegal_floating_point_literal_pattern lint 2024-01-26 17:25:02 +01:00
vec-matching-fixed.rs
vec-matching-fold.rs
vec-matching-legal-tail-element-borrow.rs
vec-matching.rs
vec-mut-iter-borrow.rs
vec-mut-iter-borrow.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
vec-overrun.rs
vec-repeat-with-cast.rs
vec-res-add.rs
vec-res-add.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
vec-tail-matching.rs
vector-cast-weirdness.rs
vector-cast-weirdness.stderr
vector-no-ann-2.rs
vector-no-ann.rs
vector-no-ann.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00