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_const_index-0.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
array-break-length.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
array-break-length.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
array-not-vector.rs Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
array-not-vector.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
bounds-check-no-overflow.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
box-of-array-of-drop-1.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
box-of-array-of-drop-2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
byte-literals.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
cast-in-array-size.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
check-static-slice.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
copy-out-of-array-1.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
destructure-array-1.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
dst-raw-slice.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
empty-mutable-vec.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
estr-slice.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
evec-slice.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
fixed_length_copy.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
huge-largest-array.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
infer_array_len.rs add test, bless tests 2023-07-17 22:00:43 +00:00
issue-15730.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-18425.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-69103-extra-binding-subslice.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-69103-extra-binding-subslice.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ivec-pass-by-value.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
match_arr_unknown_len.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
mutability-inherits-through-fixed-length-vec.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
mutable-alias-vec.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
nested-vec-1.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
nested-vec-2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
nested-vec-3.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
new-style-fixed-length-vec.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
rcvr-borrowed-to-slice.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repeat_empty_ok.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repeat_empty_ok.stderr Remove extra # from url 2024-01-24 00:41:45 +01:00
repeated-vector-syntax.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
show-boxed-slice.rs Adjust compiler tests for unused_tuple_struct_fields -> dead_code 2024-01-02 15:34:37 -05:00
slice_binary_search.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
slice_is_sorted_by_borrow.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
slice-2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
slice-2.stderr Improve spans for indexing expressions 2023-08-04 13:17:39 +02:00
slice-mut-2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
slice-mut-2.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
slice-mut.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
slice-panic-1.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
slice-panic-2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
slice-to-vec-comparison.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
slice.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
subslice-only-once-semantic-restriction.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
subslice-only-once-semantic-restriction.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
subslice-patterns-const-eval-match.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
subslice-patterns-const-eval.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
suggest-array-length.fixed Move /src/test to /tests 2023-01-11 09:32:08 +00:00
suggest-array-length.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
suggest-array-length.stderr Bless tests 2024-01-13 12:46:58 -05:00
variance-vec-covariant.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
vec-dst.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
vec-fixed-length.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
vec-late-init.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
vec-macro-no-std.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
vec-macro-rvalue-scope.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
vec-macro-with-brackets.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
vec-macro-with-comma-only.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
vec-matching-autoslice.rs remove illegal_floating_point_literal_pattern lint 2024-01-26 17:25:02 +01:00
vec-matching-fixed.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
vec-matching-fold.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
vec-matching-legal-tail-element-borrow.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
vec-matching.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
vec-mut-iter-borrow.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
vec-repeat-with-cast.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
vec-res-add.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
vector-cast-weirdness.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
vector-cast-weirdness.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
vector-no-ann-2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
vector-no-ann.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
vector-no-ann.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00