Open
Description
openedon Mar 19, 2019
struct Foo<'a> { a: &'a usize }
fn get_account_value<'l>(
flag: bool,
a: &'l mut Foo,
b: &'l mut Foo,
) {
let _ = if flag { a } else { b };
}
Produces the following output:
error[E0623]: lifetime mismatch
--> src/main.rs:8:34
|
5 | a: &'l mut Foo,
| ---
6 | b: &'l mut Foo,
| --- these two types are declared with different lifetimes...
7 | ) {
8 | let _ = if flag { a } else { b };
| ^ ...but data from `b` flows into `a` here
error[E0623]: lifetime mismatch
--> src/main.rs:8:34
|
5 | a: &'l mut Foo,
| --- these two types are declared with different lifetimes...
6 | b: &'l mut Foo,
| ---
7 | ) {
8 | let _ = if flag { a } else { b };
| ^ ...but data from `a` flows into `b` here
error: aborting due to 2 previous errors
It seems like the borrow checker could handle this case better. Particularly, the fact that Foo
has a lifetime makes the errors more puzzling than they need to be.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsArea: Lifetimes / regionsArea: Lifetimes / regionsCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.Bugs fixed, but only when NLL is enabled.Bugs fixed, but only when NLL is enabled.Relevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.