Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|| (*category == ConstraintCategory::Assignment
&& self.regioncx.universal_regions().defining_ty.is_fn_def())
|| self.regioncx.universal_regions().defining_ty.is_const()
|| (fr_name_and_span.is_none()
&& self.regioncx.universal_regions().defining_ty.is_fn_def())
{
return self.report_general_error(errci);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Regression test for https://github.com/rust-lang/rust/issues/154350

fn func<'a>(f: impl FnOnce(fn(&'a i32)), x: fn(&'static i32)) {
f(x);
//~^ ERROR lifetime may not live long enough
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: lifetime may not live long enough
--> $DIR/fn-ptr-lifetime-mismatch-with-impl-trait-arg.rs:4:5
|
LL | fn func<'a>(f: impl FnOnce(fn(&'a i32)), x: fn(&'static i32)) {
| -- lifetime `'a` defined here
LL | f(x);
| ^^^^ argument requires that `'a` must outlive `'static`

error: aborting due to 1 previous error

Loading