-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regions
Description
fn test() -> *mut for<'a> Fn(&'a usize) { // change to *const and it'll work
if let Some(_) = Some(1) { // not sure why I have to do this
loop{}
} else {
loop{}
}
}
fn main() {}
<anon>:2:5: 6:6 error: cannot infer an appropriate lifetime for lifetime parameter 'a in generic type due to conflicting requirements
<anon>:2 if let Some(_) = Some(1) { // not sure why I have to do this
<anon>:3 loop{}
<anon>:4 } else {
<anon>:5 loop{}
<anon>:6 }
note: in expansion of if let expansion
<anon>:2:5: 6:6 note: expansion site
note: first, the lifetime cannot outlive lifetime ReSkolemized(0, BrNamed(0:7, 'a(61)))...
<anon>:2:5: 6:6 note: ...so that types are compatible (expected `for<'a> core::ops::Fn(&'a usize) + 'static`, found `core::ops::Fn(&usize) + 'static`)
<anon>:2 if let Some(_) = Some(1) { // not sure why I have to do this
<anon>:3 loop{}
<anon>:4 } else {
<anon>:5 loop{}
<anon>:6 }
note: in expansion of if let expansion
<anon>:2:5: 6:6 note: expansion site
<anon>:2:5: 6:6 note: but, the lifetime must be valid for the if let at 2:4...
<anon>:2 if let Some(_) = Some(1) { // not sure why I have to do this
<anon>:3 loop{}
<anon>:4 } else {
<anon>:5 loop{}
<anon>:6 }
note: in expansion of if let expansion
<anon>:2:5: 6:6 note: expansion site
<anon>:2:5: 6:6 note: ...so type `*mut core::ops::Fn(&usize)` of expression is valid during the expression
<anon>:2 if let Some(_) = Some(1) { // not sure why I have to do this
<anon>:3 loop{}
<anon>:4 } else {
<anon>:5 loop{}
<anon>:6 }
note: in expansion of if let expansion
<anon>:2:5: 6:6 note: expansion site
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/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'assertion failed: !ty.needs_infer()', ../src/librustc_typeck/lib.rs:155
Metadata
Metadata
Assignees
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regions