2024-07-18 10:37:19 -05:00
|
|
|
//@ revisions: current next
|
|
|
|
//@ ignore-compare-mode-next-solver (explicit revisions)
|
|
|
|
//@[next] compile-flags: -Znext-solver
|
2023-04-22 12:31:00 -05:00
|
|
|
|
|
|
|
use std::fmt::Display;
|
|
|
|
|
|
|
|
trait Static: 'static {}
|
|
|
|
impl<T> Static for &'static T {}
|
|
|
|
|
|
|
|
fn foo<S: Display>(x: S) -> Box<dyn Display>
|
|
|
|
where
|
|
|
|
&'static S: Static,
|
|
|
|
{
|
|
|
|
Box::new(x)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let s = foo(&String::from("blah blah blah"));
|
2024-07-18 10:37:19 -05:00
|
|
|
//~^ ERROR temporary value dropped while borrowed
|
2023-04-22 12:31:00 -05:00
|
|
|
println!("{}", s);
|
|
|
|
}
|