mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
add : new UI test
This commit is contained in:
@@ -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`.
|
||||
Reference in New Issue
Block a user