about summary refs log tree commit diff
path: root/tests/ui/wf/wf-in-where-clause-static.rs
blob: 8ee654ef7cff4015a93752ff49705a22355329e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver

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"));
    //~^ ERROR temporary value dropped while borrowed
    println!("{}", s);
}