Skip to content

Commit 2fc136b

Browse files
gburgessivGrigorenkoPV
authored andcommitted
add known-bug test for unsoundness issue rust-lang#108425
Part of the resolution to rust-lang#105107
1 parent d7c5937 commit 2fc136b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// known-bug: #108425
2+
// check-pass
3+
#![feature(type_alias_impl_trait)]
4+
use std::fmt::Display;
5+
6+
type Opaque<'a> = impl Sized + 'static;
7+
fn define<'a>() -> Opaque<'a> {}
8+
9+
trait Trait {
10+
type Assoc: Display;
11+
}
12+
impl<'a> Trait for Opaque<'a> {
13+
type Assoc = &'a str;
14+
}
15+
16+
// ======= Exploit =======
17+
18+
fn extend<T: Trait + 'static>(s: T::Assoc) -> Box<dyn Display> {
19+
Box::new(s)
20+
}
21+
22+
fn main() {
23+
let val = extend::<Opaque<'_>>(&String::from("blah blah blah"));
24+
println!("{}", val);
25+
}

0 commit comments

Comments
 (0)