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
16 changes: 16 additions & 0 deletions tests/ui/borrowck/async-trait-proposes-let-binding.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Regression test for <https://github.com/rust-lang/rust/issues/119686>.
//@ edition: 2024
struct A;
pub trait Trait1 {
async fn func() -> ();
}

impl Trait1 for A {
async fn func() -> () {
let p = std::convert::identity(&("".to_string()));
//~^ ERROR temporary value dropped while borrowed
let _q = p;
}
}

fn main() {}
16 changes: 16 additions & 0 deletions tests/ui/borrowck/async-trait-proposes-let-binding.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
error[E0716]: temporary value dropped while borrowed
--> $DIR/async-trait-proposes-let-binding.rs:10:41
|
LL | let p = std::convert::identity(&("".to_string()));
| ^^^^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
| |
| creates a temporary value which is freed while still in use
LL |
LL | let _q = p;
| - borrow later used here
|
= note: consider using a `let` binding to create a longer lived value

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0716`.
Loading