Programming Search⌘K

Rust errors and diagnostics, page 2 of 3

The error codes and warnings of Rust, with the message that each one prints and what causes it. This page has 512 cards.

A value is borrowed as mutable while a shared borrow is live E0502

The program takes a mutable borrow, for example with a call to push, while a shared reference to the same value is still used later. Use the shared reference before the mutable borrow, or copy the data out first.

Code
E0502
Severity
error
Message
cannot borrow `{}` as mutable because it is also borrowed as immutable
Message
cannot borrow `{}` as immutable because it is also borrowed as mutable

Source: doc.rust-lang.org. JSON record. This entry is a card. Help write this page.

A value is moved out of a borrowed reference E0507

The program moves a field or a value out through a reference. A reference does not own the value, so it cannot give the value away. Borrow the field, clone it, or use std::mem::take or Option::take to leave a value in its place.

Code
E0507
Severity
error
Message
cannot move out of `{}` which is behind a shared reference
Message
cannot move out of `{}` which is behind a mutable reference

Source: doc.rust-lang.org. JSON record. This entry is a card. Help write this page.

Reference to a local value returned from a function E0515

A function returns a reference to a local variable or a temporary, which dies when the function returns. Return the value itself, or a reference into an argument.

Code
E0515
Severity
error
Message
cannot return reference to local variable `{}`
Message
cannot return value referencing local variable `{}`
Message
cannot return reference to temporary value

Source: doc.rust-lang.org. JSON record. This entry is a card. Help write this page.