mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Rollup merge of #155295 - lapla-cogito:issue_154350, r=JohnTitor
Fix misleading "borrowed data escapes outside of function" diagnostic Fixes rust-lang/rust#154350 Fall back to `report_general_error()` when `fr_name_and_span` is `None` in function items, since the "escaping data" framing is only appropriate for closures capturing outside variables.
This commit is contained in:
@@ -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() {}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user