mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
lower adjusts in simple index except the last one
This commit is contained in:
parent
8a6ca86247
commit
d7fe4e2fa8
2 changed files with 27 additions and 1 deletions
|
@ -564,6 +564,25 @@ fn f(x: [(i32, u8); 10]) {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn index() {
|
||||
check_diagnostics(
|
||||
r#"
|
||||
//- minicore: coerce_unsized, index, slice
|
||||
fn f() {
|
||||
let x = [1, 2, 3];
|
||||
x[2] = 5;
|
||||
//^^^^^^^^ 💡 error: cannot mutate immutable variable `x`
|
||||
let x = &mut x;
|
||||
//^^^^^^ 💡 error: cannot mutate immutable variable `x`
|
||||
let mut x = x;
|
||||
//^^^^^ 💡 weak: variable does not need to be mutable
|
||||
x[2] = 5;
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn overloaded_index() {
|
||||
check_diagnostics(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue