Skip to content

Commit 3141262

Browse files
committed
add known-bug test for unsound issue 98117
1 parent 3c5de9a commit 3141262

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// check-pass
2+
// known-bug: #98117
3+
4+
// Should fail. Functions are responsible for checking the well-formedness of
5+
// their own where clauses, so this should fail and require an explicit bound
6+
// `T: 'static`.
7+
8+
use std::fmt::Display;
9+
10+
trait Static: 'static {}
11+
impl<T> Static for &'static T {}
12+
13+
fn foo<S: Display>(x: S) -> Box<dyn Display>
14+
where
15+
&'static S: Static,
16+
{
17+
Box::new(x)
18+
}
19+
20+
fn main() {
21+
let s = foo(&String::from("blah blah blah"));
22+
println!("{}", s);
23+
}

0 commit comments

Comments
 (0)