Closed
Description
The following code:
fn foo(mut first: &u8, second: &u8) {
first = second;
}
fn main() {}
produces the following error:
error[E0623]: lifetime mismatch
--> src/lib.rs:2:13
|
1 | fn foo(mut first: &u8, second: &u8) {
| --- --- these two types are declared with different lifetimes...
2 | first = second;
| ^^^^^^ ...but data from `second` flows into `first` here
We could suggest changing the signature to fn foo<'a>(mut first: &'a u8, second: &'a u8)
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Lifetimes / regionsArea: Suggestions generated by the compiler applied by `cargo fix`Category: An issue proposing an enhancement or a PR with one.Diagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.