add : new UI test

This commit is contained in:
lms0806
2026-04-15 12:52:23 +09:00
parent a87c9b9603
commit 96fb37ae60
3 changed files with 28 additions and 2 deletions
@@ -8,8 +8,9 @@ LL | num *= 2;
|
help: consider making this binding mutable
|
LL | for &(mut num) num in nums {
| +++++++++
LL - for &num in nums {
LL + for &(mut num) in nums {
|
error: aborting due to 1 previous error
@@ -0,0 +1,9 @@
//! regression test for <https://github.com/rust-lang/rust/issues/155030>
fn main() {
let nums: [u32; 3] = [1, 2, 3];
for num in nums {
num *= 2; //~ ERROR cannot assign twice to immutable variable `num`
println!("{num}");
}
}
@@ -0,0 +1,16 @@
error[E0384]: cannot assign twice to immutable variable `num`
--> $DIR/borrowck_for_loop_pattern_assignment.rs:6:9
|
LL | for num in nums {
| --- first assignment to `num`
LL | num *= 2;
| ^^^^^^^^ cannot assign twice to immutable variable
|
help: consider making this binding mutable
|
LL | for mut num in nums {
| +++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0384`.