-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant 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.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
I tried this code:
fn check(a: Option<&i32>, b: &i32) -> bool {
a == Some(b)
}
I expected to see this happen: Code compiles and works as expected.
Switching the equality around like this compiles successfully and works as expected:
fn check(a: Option<&i32>, b: &i32) -> bool {
Some(b) == a
}
Alternatively explicitly forcing both references to a shared lifetime works too:
fn check<'c>(a: Option<&'c i32>, b: &'c i32) -> bool {
a == Some(b)
}
Instead, this happened: error[E0495]: cannot infer an appropriate lifetime for automatic coercion due to conflicting requirements
Meta
https://play.rust-lang.org/?gist=9bd7c205c280df1ea37bb49cd3ecca25&version=stable&backtrace=0
Metadata
Metadata
Assignees
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant 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.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.