mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
24 lines
478 B
Rust
24 lines
478 B
Rust
//@ check-pass
|
|
//@ known-bug: #98117
|
|
|
|
// Should fail. Functions are responsible for checking the well-formedness of
|
|
// their own where clauses, so this should fail and require an explicit bound
|
|
// `T: 'static`.
|
|
|
|
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"));
|
|
println!("{}", s);
|
|
}
|