forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add known-bug test for unsound issue 98117
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// 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); | ||
} |