Could not compile `storing_lists_vectors`

Hello everyone. I practice using vectors. I wanted to iterate over mutable references to each element of the mutable vector in order to make changes to all elements. But somehow I got an error. I'm a beginner and would appreciate everyone's help!
My code:

fn main() {
    let mut s = vec![10, 20, 30];
    for i in &mut s {
        *i += 10;
        println!("{}", i);
    }
}

Error: could not compile storing_lists_vectors

Additional info:

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.55.0 (c8dfcfe04 2021-09-06) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack

Seems there's something wrong with your Rust installation. Someone on the forum maybe be able to help you debug it. Until you get that sorted out, you can use The Playground to run small programs like this one.

1 Like

Thanks a lot! The point is that I run other programs just fine, loops, arrays, enumerations - they work as they should. My problem only turns out in the case of vectors.

Solution: I run cargo clean and everything works now.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.